Application hung (infinite loop) if the same class-name is used twice for different classes with event tables
|Reported by:||gal_wxwidgets||Owned by:|
Notes and references
The bug + patch is also available with Ubuntu bug https://launchpad.net/bugs/735462
What you expected to happen
The wxwidgets should check for duplicate insertion into the event table and flag a duplicate insert of the same class as an erro
What happened instead
The second insert (of the same table) did succeed and create a cycle within the linked list.
On initialization, the initialization of the linked list entered an infinite loop
Description of patch
Add a check for the error case of "duplicate insert into the linked-list of the event tables"
If a duplicate insert is detected, then issue an error and avoid the re-insert. It is then, the responsibility of the developer of the program, to fix the error within his code and to avoid using the same class name twice.
Reproducing the error case that this patch detect
- Create a class (within your program) that has the same class-name as a class that already exist within the wxwidgets code. Both classes should have event tables.
- Compile this code into your executable
- Link with a shared version of the wxwidgets libraries
- Start the application:
- The executable is initiated (before calling main()) - and the event table is added to the link list for the first time
- The shared libraries of the wxwidgets are initiated
- The event table from the wxwidgets shared library is resolved to the symbol from the executable (with the same name) and NOT to the symbol within the shared library
- The SAME event table is added for the SECOND time into the linked list and create a cycle
- main() is called
- wxwidget is initialize - and it get stack with an infinite loop when trying to initiate the linked list of the event table
Creating the patch
- Get sources
svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH wxWidgets-2.8
- Apply the patch at http://trac.wxwidgets.org/browser/branches/WX_2_8_BRANCH/src/common/event.cpp#L815
- get diff
svn diff wxWidgets-2.8 > check-for-cycle-dependency.patch