Hi,
i tried to add a testcase to the regression to find this bug. I noticed that there are already regression tests for objset which „should“ find this problem (adding item(s), then clear). However I could not reproduce the crash via a regression test.
Friedrich
Thanks for looking at the patch!
I changed the patch along the line you proposed in the previous comment. This works also. So the iterator is not corrupted during the _disconnect iterations.
In addition I installed boost version 1.65.1 on my system. However, that shows the same crash behavior. So it is not related to the version of boost.
username-removed-1661829 (a920a212) at 04 Oct 09:39
selection clear: First disconnect, then clear
I think this is the step where the iterator is invalidated - at least in my environment.
Hi Marc,
thanks for looking at the patch! I installed boost via Macports (1.59.0). The versions around are
The version I use is the latest one which is available on macports.
Regarding your other comment I am not too sure what you mean. You state that the iterator should not be invalidated but that is exactly what I see. Could you maybe elaborate how to iterate normally and clear at the end? The current implementation removes an element from the container and then iterates. The step of removal of the element from the container has invalidated the iterator (in my environment). My impression is that it is important to use
it = _container.erase(it)
to remove the element of the container and iterate in an implementation independent correct way. See for example a discussion here:
https://stackoverflow.com/questions/28325299/about-erasing-an-interator-of-a-boost-multiindex
I described the probem in the mailing list:
https://sourceforge.net/p/inkscape/mailman/message/36061951/
On MacOS El Capitan with XCode 7.3 inkscape crashes when a second item is drawn in the drawing area. The crash is triggered by clearing the selection from the previous drawing activity. The reason for the crash is that the iterator is corrupted because during iteration the objects are removed from the container.
This patch uses a safe way to remove items from the container and going to the next iteration. Using this patch, inkscape does not crash anymore.
username-removed-1661829 (9e706a36) at 03 Oct 20:08
Fix bug: crash - iterator corrupted by removing objects from container