godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.13k stars 19.94k forks source link

Project crashes when ran from editor at random points. No output in debugger to indicate problem. #12664

Closed stubbsy345 closed 5 years ago

stubbsy345 commented 6 years ago

Operating system or device, Godot version, GPU Model and driver (if graphics related): OSX, Godot 3.0 alpha 2

Issue description: The game will crash sometimes when I free a node or get a node to enter the screen. This didn't appear to happen in earlier versions of godot 3.0. There is nothing present in the debugger to indicate why this is happening but I will include the crash report that I get when this occurs. Perhaps this is an issue with my code but considering this didn't seem to happen in earlier versions I don't believe it is, but I will continue look through it. At the end I have included the report I get when the programme crashes, I don't know if this is any use.

handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] 1   libsystem_platform.dylib            0x00007fffa5561b3a _sigtramp + 26
[2] RefPtr::unref() (in PixelDr) + 23
[3] -[GodotContentView unmarkText] (in PixelDr) + 123
[4] -[GodotContentView cancelComposition] (in PixelDr) + 27
[5] -[GodotContentView insertText:replacementRange:] (in PixelDr) + 661
[6] 6   AppKit                              0x00007fff8d85ac0b -[NSTextInputContext(NSInputContext_WithCompletion) insertText:replacementRange:completionHandler:] + 79
[7] 7   AppKit                              0x00007fff8e093df3 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2.379 + 108
[8] 8   AppKit                              0x00007fff8d85abb4 -[NSTextInputContext do_HandleTSMEvent_insertFixLenTextLoop:whileCondition:dispatchWorkEach:afterEachInsertText:continuation:] + 111
[9] 9   AppKit                              0x00007fff8e091c98 -[NSTextInputContext tryHandleTSMEvent_insertFixLenText_withContext:dispatchCondition:setupForDispatch:nestedWorkaroundCondition:nestedWorkaroundDispatchWork:loopCondition:dispatchWorkEach:afterEachInsertText:continuation:] + 387
[10] 10  AppKit                              0x00007fff8e0939c7 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke.314 + 4105
[11] 11  AppKit                              0x00007fff8d85a835 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 80
[12] 12  AppKit                              0x00007fff8d85a7b4 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 93
[13] 13  AppKit                              0x00007fff8d85a19f -[NSTextInputContext handleTSMEvent:completionHandler:] + 2221
[14] 14  AppKit                              0x00007fff8d859883 _NSTSMEventHandler + 321
[15] DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*)
[16] SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*)
[17] 17  HIToolbox                           0x00007fff8f101e3f SendEventToEventTargetWithOptions + 43
[18] 18  HIToolbox                           0x00007fff8f1596d6 SendTSMEvent_WithCompletionHandler + 408
[19] 19  HIToolbox                           0x00007fff8f159bb1 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 400
[20] 20  HIToolbox                           0x00007fff8f159a12 __SendFilterTextEvent_WithCompletionHandler_block_invoke + 215
[21] 21  HIToolbox                           0x00007fff8f159727 SendTSMEvent_WithCompletionHandler + 489
[22] 22  HIToolbox                           0x00007fff8f159511 SendFilterTextEvent_WithCompletionHandler + 236
[23] 23  HIToolbox                           0x00007fff8f1591d6 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 284
[24] 24  HIToolbox                           0x00007fff8f158f8c __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 296
[25] 25  HIToolbox                           0x00007fff8f158e32 __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 439
[26] 26  HIToolbox                           0x00007fff8f158bf9 TSMKeyEvent_WithCompletionHandler + 632
[27] 27  HIToolbox                           0x00007fff8f158948 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 251
[28] 28  HIToolbox                           0x00007fff8f158775 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 281
[29] 29  HIToolbox                           0x00007fff8f15848b __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 308
[30] 30  HIToolbox                           0x00007fff8f1581c2 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 300
[31] 31  HIToolbox                           0x00007fff8f15773a TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3604
[32] 32  AppKit                              0x00007fff8e09a3d1 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke.1077 + 116
[33] 33  AppKit                              0x00007fff8e099689 __204-[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:]_block_invoke.1003 + 121
[34] 34  AppKit                              0x00007fff8e0994f3 -[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:] + 285
[35] 35  AppKit                              0x00007fff8e099e1b -[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:] + 1515
[36] 36  AppKit                              0x00007fff8e099362 -[NSTextInputContext _handleEvent:allowingSyntheticEvent:] + 114
[37] 37  AppKit                              0x00007fff8d85828b -[NSView interpretKeyEvents:] + 232
[38] -[GodotContentView keyDown:] (in PixelDr) + 545
[39] 39  AppKit                              0x00007fff8dfba2cc -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 4086
[40] 40  AppKit                              0x00007fff8dfb8f0a -[NSWindow(NSEventRouting) sendEvent:] + 541
[41] 41  AppKit                              0x00007fff8de3e4a8 -[NSApplication(NSEvent) sendEvent:] + 4768
[42] -[GodotApplication sendEvent:] (in PixelDr) + 98
[43] OS_OSX::run() (in PixelDr) + 219
[44] main (in PixelDr) + 561
[45] 45  libdyld.dylib                       0x00007fffa5352235 start + 1
-- END OF BACKTRACE --
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

EDIT: Edited above error with error received from terminal on export as it is more readable.

stubbsy345 commented 6 years ago

Just as a note this happens both in the export and from the editor (at random, never always the same interaction or the same time). It seems to happen when I press SPACE BAR and after a little time of playing the game. When player is in an area 2d pressing SPACE, which is linked to the action "ui_interact", will open some screen. This screen is added to a GUI node in the main scene which is of the canvas layer class. I have a print("interact") statement under is_action_pressed("ui_interact") and when this crash occurs this does not print out so it doesn't appear to be a crash in my code as I imagine this would be printed and would then highlight the area of code in which this occured?

stubbsy345 commented 6 years ago

Seems to only occur after I have interacted with a node that calls to my HTTP Client script which is an autoloaded script. I can play the game with no error otherwise. But after I have sent a POST request to the server. At some point the game crashes when I try to interact with something else. I don't understand how this would impact this but for some reason it is interfering.

Zireael07 commented 6 years ago

hmm, I seem to recall some http request issue, you might want to search issues for it. Are you doing it in a thread?

stubbsy345 commented 6 years ago

I took it out of using a thread and this didn't seem to help I still get the same peculiar crash after I use HTTP Client, or though strangely, not immediately. Only when I interact with something else. I wonder if changing to use the HTTP request node might yield an improvement.

reduz commented 6 years ago

can you guys make an example project of what crashes? i cant seem to crash it on OSX

akien-mga commented 6 years ago

Many crashes have been fixed on all platforms since November, so assuming this was fixed. If you can still reproduce the exact same issue, please comment and provide an example project and steps to reproduce.

EstevanBR commented 6 years ago

I am getting this crash. same exact issue but I am using an HTTPRequest node Godot version 3.0.2

it happened w/ my ludum dare 41 submission. but my game uses the twitter API (so posting the project code would expose my api key). Ill try to create an example project with as little moving parts as possible

EstevanBR commented 6 years ago

Ok so I think it boils down to this:

A LineEdit Node is connected to a parent Node which has been deallocated already. When we enter a new scene, and LineEdit Node's partent node was deallocated, but inputting via keyboard causes the node to try and send a signal to the deallocated Node.

I can't confirm that having the LineEdit node be hidden after switching scenes will make it happen. and I can't confirm that HTTP even has anything to do with it.

Something I found interesting was if I add disconnect to the _exit_tree() method of the LineEdit node, the issue disappears.

  1. Have a scene, with a instanced Node that has a LineEdit, the LineEdit text entered is connected to the scene that has instanced it.
  2. Perform an HTTP Post request (unsure if this is actually related) using HTTPRequest node
  3. hide the LineEdit after text is entered (set_visible(false))
  4. change scenes to a new scene, so that the parent scene of step 1 will be deallocated / exit tree
  5. press any keyboard button/s
  6. crash

based on the logs it looks like the LineEdit object hasn't been deallocated yet, but the scene which it's connected to has been deallocated. IMO this explains why it is so inconsistent, because it's a race condition basically, and I would assume if you had a higher intensive program, the issue would appear more often.

Current path: /Users/ehernandez/Documents/Code/Godot/godot_issue_12664_example
Remote Debugger: Connection failed with status: '2', retrying in 1 msec.
OpenGL ES 3.0 Renderer: Intel HD Graphics 4000 OpenGL Engine
http request completed
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] 1   libsystem_platform.dylib            0x00007fffc9212b3a _sigtramp + 26
[2] 2   ???                                 0x0000000000000000 0x0 + 0
[3] Vector<wchar_t>::_copy_from(Vector<wchar_t> const&) (in godot.osx.tools.64) (vector.h:382)
[4] Vector<wchar_t>::operator=(Vector<wchar_t> const&) (in godot.osx.tools.64) (vector.h:396)
[5] String::operator=(String const&) (in godot.osx.tools.64) (ustring.h:63)
[6] LineEdit::_ime_text_callback(void*, String, Vector2) (in godot.osx.tools.64) (line_edit.cpp:1352)
[7] -[GodotContentView unmarkText] (in godot.osx.tools.64) (os_osx.mm:427)
[8] -[GodotContentView cancelComposition] (in godot.osx.tools.64) (os_osx.mm:453)
[9] -[GodotContentView insertText:replacementRange:] (in godot.osx.tools.64) (os_osx.mm:498)
[10] 10  AppKit                              0x00007fffb10c2c0b -[NSTextInputContext(NSInputContext_WithCompletion) insertText:replacementRange:completionHandler:] + 79
[11] 11  AppKit                              0x00007fffb18fbdf3 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2.379 + 108
[12] 12  AppKit                              0x00007fffb10c2bb4 -[NSTextInputContext do_HandleTSMEvent_insertFixLenTextLoop:whileCondition:dispatchWorkEach:afterEachInsertText:continuation:] + 111
[13] 13  AppKit                              0x00007fffb18f9c98 -[NSTextInputContext tryHandleTSMEvent_insertFixLenText_withContext:dispatchCondition:setupForDispatch:nestedWorkaroundCondition:nestedWorkaroundDispatchWork:loopCondition:dispatchWorkEach:afterEachInsertText:continuation:] + 387
[14] 14  AppKit                              0x00007fffb18fb9c7 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke.314 + 4105
[15] 15  AppKit                              0x00007fffb10c2835 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 80
[16] 16  AppKit                              0x00007fffb10c27b4 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 93
[17] 17  AppKit                              0x00007fffb10c219f -[NSTextInputContext handleTSMEvent:completionHandler:] + 2221
[18] 18  AppKit                              0x00007fffb10c1883 _NSTSMEventHandler + 321
[19] DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*)
[20] SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*)
[21] 21  HIToolbox                           0x00007fffb296be3f SendEventToEventTargetWithOptions + 43
[22] 22  HIToolbox                           0x00007fffb29c36d6 SendTSMEvent_WithCompletionHandler + 408
[23] 23  HIToolbox                           0x00007fffb29c3bb1 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 400
[24] 24  HIToolbox                           0x00007fffb29c3a12 __SendFilterTextEvent_WithCompletionHandler_block_invoke + 215
[25] 25  HIToolbox                           0x00007fffb29c3727 SendTSMEvent_WithCompletionHandler + 489
[26] 26  HIToolbox                           0x00007fffb29c3511 SendFilterTextEvent_WithCompletionHandler + 236
[27] 27  HIToolbox                           0x00007fffb29c31d6 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 284
[28] 28  HIToolbox                           0x00007fffb29c2f8c __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 296
[29] 29  HIToolbox                           0x00007fffb29c2e32 __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 439
[30] 30  HIToolbox                           0x00007fffb29c2bf9 TSMKeyEvent_WithCompletionHandler + 632
[31] 31  HIToolbox                           0x00007fffb29c2948 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 251
[32] 32  HIToolbox                           0x00007fffb29c2775 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 281
[33] 33  HIToolbox                           0x00007fffb29c248b __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 308
[34] 34  HIToolbox                           0x00007fffb29c21c2 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 300
[35] 35  HIToolbox                           0x00007fffb29c173a TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3604
[36] 36  AppKit                              0x00007fffb19023d1 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke.1077 + 116
[37] 37  AppKit                              0x00007fffb1901689 __204-[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:]_block_invoke.1003 + 121
[38] 38  AppKit                              0x00007fffb19014f3 -[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:] + 285
[39] 39  AppKit                              0x00007fffb1901e1b -[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:] + 1515
[40] 40  AppKit                              0x00007fffb1901362 -[NSTextInputContext _handleEvent:allowingSyntheticEvent:] + 114
[41] 41  AppKit                              0x00007fffb10c028b -[NSView interpretKeyEvents:] + 232
[42] -[GodotContentView keyDown:] (in godot.osx.tools.64) (os_osx.mm:961)
[43] 43  AppKit                              0x00007fffb18222cc -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 4086
[44] 44  AppKit                              0x00007fffb1820f0a -[NSWindow(NSEventRouting) sendEvent:] + 541
[45] 45  AppKit                              0x00007fffb16a64a8 -[NSApplication(NSEvent) sendEvent:] + 4768
[46] -[GodotApplication sendEvent:] (in godot.osx.tools.64) (os_osx.mm:148)
[47] OS_OSX::process_events() (in godot.osx.tools.64) (os_osx.mm:2256)
[48] OS_OSX::run() (in godot.osx.tools.64) (os_osx.mm:2345)
[49] main (in godot.osx.tools.64) (godot_main_osx.mm:100)
[50] 50  libdyld.dylib                       0x00007fffc9003235 start + 1
[51] 51  ???                                 0x0000000000000009 0x0 + 9
-- END OF BACKTRACE --

I've attatched a .zip with a working example. The issue appears in both 3.0.2 stable, and in my build that was made from 6faa96fb89ab33fe3a6b37eecca1c7cf2934ff75 godot_issue_12664_example.zip

void LineEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) {
    LineEdit *self = (LineEdit *)p_self;
    self->ime_text = p_text;
    self->ime_selection = p_selection;
    self->update();
}

maybe p_text is null when the crash happens. godot_issue_12664_example.zip

I have tried disconnecting the node in several places the crash still happens on my personal project

akien-mga commented 5 years ago

Is this still reproducible in the current master branch?

CC @bruvzg, the last comment refers to IME callbacks.

bruvzg commented 5 years ago

CC @bruvzg, the last comment refers to IME callbacks.

IME callbacks already removed and replaced with NOTIFICATION_OS_IME_UPDATE notification in #23923.

akien-mga commented 5 years ago

Assuming fixed then.

Please comment if you can still reproduce this crash.