TKG was trying to port another one of his games over to ENIGMA and found a new bug with instance change. I've checked it out and widdled it down to a real simple reproducible case. I have a feeling it may have been caused by #999. Basically, if you call instance change in an object's collision event when it is colliding with two other instances it will crash in instance_system.cpp in unlink_main on the line:
if (a->prev) a->prev->next = a->next;
Here are steps to reproduce it:
- Create a new game
- Create a new sprite of any size and fill it in black or w/e color
- Create 3 objects and delete their default events
obj_0's sprite to
- Add a collision event for
obj_0and add the instance change action with yes for perform events and to change it to
obj_1's sprite to
- Create a new room and place one
obj_1s overlapping the
- Run the game and it should segfault as soon as it launches
Here;s a download of the above reproducible in a gm81 file:
Here's a stack trace with me following these reproducible steps:
Program received signal SIGSEGV, Segmentation fault. 0x004b9f82 in enigma::unlink_main (whop=0x2234b80) at Universal_System/instance_system.cpp:373 373 if (a->prev) a->prev->next = a->next; (gdb) bt #0 0x004b9f82 in enigma::unlink_main (whop=0x2234b80) at Universal_System/instance_system.cpp:373 #1 0x00684d96 in enigma::OBJ_obj_0::deactivate (this=0x223c280) at C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectdeclarations.h:118 #2 0x00684ff6 in enigma::OBJ_obj_0::unlink (this=0x223c280) at C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectdeclarations.h:112 #3 0x00403e05 in enigma::instance_change_inst (obj=2, perf=true, inst=0x223c280) at Universal_System/instance_create.h:43 #4 0x0040476a in enigma_user::instance_change (obj=2, perf=true) at Universal_System/instance_create.h:111 #5 0x00679343 in enigma_user::action_change_object (obj=2, perf=true) at Universal_System/instance_create.h:107 #6 0x0040372e in enigma::OBJ_obj_0::myevent_collision_1 (this=0x223c280) at C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectfunctionality.h:41 #7 0x00684f04 in enigma::OBJ_obj_0::myevent_collision (this=0x223c280) at C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_objectdeclarations.h:85 #8 0x00402fa6 in enigma::ENIGMA_events () at C:/ProgramData/ENIGMA/Preprocessor_Environment_Editable/IDE_EDIT_events.h:91 #9 0x00408511 in WinMain@16 (hInstance=0x400000, hPrevInstance=0x0, lpCmdLine=0x105567 "", iCmdShow=10) at Platforms/Win32/WINDOWSmain.cpp:356 #10 0x0076936d in main () (gdb)
perform_events=false. Does it?
Never mind; I misread. I thought you were changing instances of
obj_0 or vice-versa (throwing the collision system into an infinite loop). This problem seems much simpler than that. Give me a minute.
Try replacing the code in
instance_creat.h:42-43) with a call to
instance_destroy(idn, perf). This should be how those two lines are written, anyway. That should fix it, and if not, we have a bigger problem on our hands (again).
I can confirm this fixes the reproducible case and TKG also said it fixes his game.