Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Weird problem/observation with Sequence remove()
Weird problem/observation with Sequence remove() [message #872040] Tue, 15 May 2012 11:04 Go to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Hi,

I noticed something really strange and am unsure what to do with it.

A simple representation of the problematic code (including my bug):
var index = 0;
while(index < list.size()) {
  var item = list.get(index);
  if(not item.allowProcess()) {
    index = index + 1;
    continue;
  }
  list.remove(index);
  index = 0;

  -- Process item and generate code (but absolutely not using list anymore!)
}

Note: that list (Sequence) dot not contain numbers/integers but a certain selection of the objects (extending EObject) of the model. The list got filled with something like diagram.getObjects().select(d|d.shouldSelect()).

The observant reader should notice the bug by now: list.remove(index) should have been list.removeAt(index).

So far so good.

My actual problem is that the example code did work for weeks!
A Windows user finally got an OutOfMemory error as item was processed a infinite amount of times. As it should be due to the bug.
All Mac and Linux users (including myself) did not experience any problems. Processing with large or small lists does not seem to matter.
Personally, I got really surprised by this!


So, the reason of this post: is the a known problem/bug? Are there differences between Windows and other OSes at all? (with respect to Epsilon of course Wink )


As I am kind of busy with deadlines, I did not yet have time to create a minimal example. If this is desired (because of the weirdness of this problem), please let me know and I'll try to make time for this.

[Updated on: Tue, 15 May 2012 11:07]

Report message to a moderator

Re: Weird problem/observation with Sequence remove() [message #872057 is a reply to message #872040] Tue, 15 May 2012 11:49 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Hi Maarten,

Actually, yes: that's a known bug that happens when storing integers in a collection. We've got a test for it, and oddly it passes in some operating systems (Windows) and fails in others (UNIX variants like MacOS X or Linux). It assumes that "remove(2)" is interpreted as "remove '2' from the collection", which is the other way around as in your sample code.

The problem here is that in some OS "remove(2)" is interpreted as "remove(int)" or "remove by index", and in other OS "remove(2)" is interpreted as "remove(Object)" = "remove the first occurrence of the element". We've pinned the bug to some odd difference in the way reflection and autoboxing work in the JVM across operating systems, but we haven't found yet a way to reliably work around it. removeAt is guaranteed to remove by index as you said, though.

Is this a showstopper for you, or would it be enough to document the issue for now?

Antonio

Re: Weird problem/observation with Sequence remove() [message #872078 is a reply to message #872057] Tue, 15 May 2012 12:19 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Hello Antonio,

Thanks for your detailed explanation. I am not storing integers in the collection, but other from this the problem is exactly as your describe.

As I noted earlier, I switched to removeAt() to remove a certain index (as I should have used from the start). So for this particular situation it is solved for me.

Only problem is that I do not know for sure, whether I did make this mistake in other places as well, which are 'accepted' because I develop and test under Linux.
So it is not a showstopper, but until yesterday I thought my code was ok. Now I need to check for remove() occurrences and verify they are correct... Smile

For the short term, a notice about this known issue, to warn (future) developers to be careful, in the documentation is good enough I suppose.
On the longer run, this definitely needs to be fixed of course.

Maarten
Re: Weird problem/observation with Sequence remove() [message #872080 is a reply to message #872078] Tue, 15 May 2012 12:24 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
By the way, are there other known differences between OSes (in EOL operations)?
Re: Weird problem/observation with Sequence remove() [message #872177 is a reply to message #872080] Tue, 15 May 2012 15:41 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

As far as we know, that's the only one. However, you should extend this issue to any class which has a pair of f(Object) and f(<primitive type>) methods: this is the most common instance of that general problem.

Please feel free to add yourself to the CC list of this bug and tell your story:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=339261

We probably need to revisit this problem and think more about it.
Previous Topic:Problem with EMFATIC file
Next Topic:Model caching problem
Goto Forum:
  


Current Time: Fri Apr 26 21:20:00 GMT 2024

Powered by FUDForum. Page generated in 0.03596 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top