Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac Simulator: Crashes and closes when error with image file path or name/extension #310

Open
jajern opened this issue Nov 26, 2021 · 16 comments
Assignees

Comments

@jajern
Copy link

jajern commented Nov 26, 2021

Describe the bug
If there is an error with a file name or path in the written code for display.newImage the simulator crashes. When it crashes it also closes the console so the only way I was able to find the bug was by running s screen recording of the console so I could replay the video and pause it when the error message displayed before the sim crashed.

To Reproduce
Steps to reproduce the behavior:

  1. create an object for display.newImage
  2. write in the wrong image file path or file extension
  3. Simulator crashes

Target platform and where build was made:

  • Device: MacBook Pro
  • OS: macOS 12.0.1
@jajern
Copy link
Author

jajern commented Dec 4, 2021

I noticed an additional type of error that also crashed the simulator on Mac:

example:
newGroupName = display.newGroup()
group:insert( newGroupNam )

The error was I had the "newGroupName" misspelled inside the insert method and that threw the error and crashed the simulator. The only way to know what the error was, I had to do a screen recording of the console so I could see what the error was that flashed on the console before it crashed and closed.

@Shchvova
Copy link
Contributor

Shchvova commented Dec 5, 2021

I couldn't reproduce this issue. Like, just having

newGroupName = display.newGroup()
group:insert( newGroupNam )

Doesn't crash anything, I am getting regular error message saying

ERROR: Runtime error
                    main.lua:2: attempt to index global 'group' (a nil value)
                    stack traceback:
                    	main.lua:2: in main chunk

This code doesn't crash either:

newGroupName = display.newGroup()
newGroupName:insert( asdf )

Error is

ERROR: Runtime error
                    main.lua:3: ERROR: table expected. If this is a function call, you might have used '.' instead of ':'
                    stack traceback:
                    	[C]: in function 'insert'
                    	main.lua:3: in main chunk

Also, tried original bug:

display.newImage("neverExisted.png")

only prints warning

WARNING: main.lua:2: Failed to find image 'neverExisted.png'

@jajern
Copy link
Author

jajern commented Dec 7, 2021

Thank you for testing on your end. I start noticing these crashes on a new MacBook with the m1 chip. I recently transferred from an Intel MacBook and did not have these problems on the Intel.

I am thinking these crashes could either be related to the simulator running on Apple Silicon MacBook, or some issue with transferring files/preferences from one Mac to another.

Is the machine you are using a MacBook with an M1 chip?

@scottrules44
Copy link
Contributor

scottrules44 commented Jul 19, 2022

This should be fixed new builds

@jajern
Copy link
Author

jajern commented Sep 17, 2022

Hi guys, I saw this was marked as fixed in build 3675. I am currently using build 3677 and am still experiencing Simulator crashing with errors. It is not happening with all errors and it is happening with different kinds of errors.

For example one type of error that caused the crash was when inserting an object into a group, the object name was misspelled in the insert code:
groupName:insert(misspelledObjectName)

Another type of error that caused the crash was code inside of the onRowRender function for a widget newTableView. The code inside the renderer was creating a newText object and the reference to the table was incorrect:
local rowTitle = display.newText( row, fullItemsList[row.index][1], 0, 0, nil, 14 )
I had left the [1] off the table reference which caused the error.

Most of the time the errors do display in the console but then the simulator and console crash and close so I am unable to read the error. I have to do a screen recording and then run the simulator again and then replay the recording to read the error.

This behavior was new since going to a M1max apple from an intel apple. I wish I could provide more information for you but these seem like normal coding errors that should show in the console.

Thank you.

@jajern
Copy link
Author

jajern commented Sep 17, 2022

Should I open a new issue for this?

@scottrules44
Copy link
Contributor

Should I open a new issue for this?

No, will reopen this and look it over the weekend

@scottrules44 scottrules44 reopened this Sep 17, 2022
@scottrules44 scottrules44 self-assigned this Sep 17, 2022
@scottrules44
Copy link
Contributor

scottrules44 commented Sep 19, 2022

@jajern I tried the original code provide but can get it to crash on m1 Mac mini

newGroupName = display.newGroup()
group:insert( newGroupNam )

@scottrules44
Copy link
Contributor

scottrules44 commented Sep 25, 2022

@jajern Can provide a demo/code of what causes the crash

@jajern
Copy link
Author

jajern commented Sep 25, 2022

@jajern Can provide a demo/code of what causes the crash
Let me check tomorrow to see if I can get another example

@jajern
Copy link
Author

jajern commented Sep 28, 2022

@scottrules44 Sorry for the delay, I tested again today by placing the code below into line:86 of "tab1.lua" in the "Widget Demo" sample code project that ships with Corona-3680. Spelling the object name right provides no errors, spelling it wrong cause the simulator to crash and close.

local nameTheGroup = display.newGroup()
sceneGroup:insert(nameTheGroupWrong)

The only thing I can think to share is the Apple Crash Report with you. It does contain some information in there that says "Corona Simulator" so it may be of help for you? I cannot make anything of it, that is beyond me. I don't think there is anything of safety concern in that file but I would still rather not post the file here publicly. If you would like that file I can send it to you.

@clang-clang-clang
Copy link
Contributor

@scottrules44 @jajern
Reproduced on M1 Pro Mac using version 3680.

Screenshot from screen recording:
image

Apple error report:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x195a22d98 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x195a57ee0 pthread_kill + 288
2   libsystem_c.dylib             	       0x195992340 abort + 168
3   libc++abi.dylib               	       0x195a12b08 abort_message + 132
4   libc++abi.dylib               	       0x195a02950 demangling_terminate_handler() + 336
5   libobjc.A.dylib               	       0x1958f8320 _objc_terminate() + 144
6   libc++abi.dylib               	       0x195a11ea4 std::__terminate(void (*)()) + 20
7   libc++abi.dylib               	       0x195a14c1c __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
8   libc++abi.dylib               	       0x195a14bc8 __cxa_throw + 140
9   libobjc.A.dylib               	       0x1958eff6c objc_exception_throw + 420
10  Corona Simulator              	       0x1027fd0f8 luai_objcthrow + 20
11  Corona Simulator              	       0x1027eedb8 lua_error + 12
12  Corona Simulator              	       0x1027ef240 luaL_error + 76
13  Corona Simulator              	       0x1028437fc Rtt::LuaProxy::GetProxy(lua_State*, int) + 112
14  Corona Simulator              	       0x102843870 Rtt::LuaProxy::GetProxyableObject(lua_State*, int) + 12
15  Corona Simulator              	       0x102849970 Rtt::LuaGroupObjectProxyVTable::Insert(lua_State*, Rtt::GroupObject*) + 96
16  Corona Simulator              	       0x102849b34 Rtt::LuaGroupObjectProxyVTable::insert(lua_State*) + 180
17  Corona Simulator              	       0x1027f61dc luaD_precall + 792
18  Corona Simulator              	       0x10280650c luaV_execute + 2500
19  Corona Simulator              	       0x1027f65b8 luaD_call + 132
20  Corona Simulator              	       0x1027fcf58 luai_objcttry + 40
21  Corona Simulator              	       0x1027f68d0 luaD_pcall + 88
22  Corona Simulator              	       0x1027eeb04 lua_pcall + 112
23  Corona Simulator              	       0x10282f2d8 Rtt::LuaContext::DoCall(lua_State*, int, int) + 108
24  Corona Simulator              	       0x10283a380 Rtt::LuaLibNative::AlertComplete(Rtt::LuaResource&, int, bool) + 200
25  AppKit                        	       0x198bf76ac -[NSAlert(NSAlertDeprecated) didEndAlert:returnCode:contextInfo:] + 84
26  AppKit                        	       0x198f38c3c NSWindowEndWindowModalSession + 388
27  AppKit                        	       0x19888e5c8 -[NSApplication(NSResponder) sendAction:to:from:] + 460
28  AppKit                        	       0x19888e3c4 -[NSControl sendAction:to:] + 96
29  AppKit                        	       0x19888e2cc __26-[NSCell _sendActionFrom:]_block_invoke + 152
30  AppKit                        	       0x19888e1c0 -[NSCell _sendActionFrom:] + 204
31  AppKit                        	       0x19888e0e4 -[NSButtonCell _sendActionFrom:] + 104
32  AppKit                        	       0x19888af30 NSControlTrackMouse + 1752
33  AppKit                        	       0x19888a82c -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 160
34  AppKit                        	       0x19888a6a0 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 740
35  AppKit                        	       0x198889910 -[NSControl mouseDown:] + 632
36  AppKit                        	       0x198887d80 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4528
37  AppKit                        	       0x1987fb100 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2444
38  AppKit                        	       0x1987fa50c -[NSWindow(NSEventRouting) sendEvent:] + 348
39  AppKit                        	       0x1987f94b4 -[NSApplication(NSEvent) sendEvent:] + 2780
40  AppKit                        	       0x198ab30f4 -[NSApplication _handleEvent:] + 76
41  AppKit                        	       0x19867b008 -[NSApplication run] + 636
42  AppKit                        	       0x19864c6fc NSApplicationMain + 1132
43  dyld                          	       0x102ddd08c start + 520

I did some research but no results. At first I thought it was related to NSAlertDeprecated in the report, but found that it was just skinning options, and then guessed it was similar to unhandledError, which can't catch errors in callbacks OnComplete, but why doesn't non Apple Silicon's crash? And the caller of AmIBeingDebugged, Rtt_UserBreak, should only be called when Rtt_DEBUG is defined, i.e. in debug mode, right?
I can help to test builds, just let me know.

@jajern
Copy link
Author

jajern commented Sep 29, 2022

@clang-clang-clang Thank you for mentioning that. I was starting to think I was the only one with the crashes and I needed to figure out what was wrong with my computer. :)

@scottrules44
Copy link
Contributor

@jajern @clang-clang-clang
Odd, I don't know why I am not getting a crash on my M1 MacBook Pro

Screen.Recording.2022-10-01.at.11.16.46.AM.mov

@clang-clang-clang
Copy link
Contributor

@jajern @clang-clang-clang Odd, I don't know why I am not getting a crash on my M1 MacBook Pro

Screen.Recording.2022-10-01.at.11.16.46.AM.mov

Odd, I will try to deep dive.

@clang-clang-clang
Copy link
Contributor

Sorry for the delay.

The reason was lua_error() throw an exception but uncaught on M1 Pro, Intel dosen't have this issue.
Solution not found yet.
And the reason may related to LLVM compact unwind stuff, but I tried to add linker option -no_compact_unwind, or -Wl,-no_compact_unwind directly pass to compiler, to rttplayer but still crashed.

Reproduced using main.lua below, be aware that group object should exist:

local namedGroup = display.newGroup()
display.getCurrentStage():insert( namedGroup_1 )

After crashed, message from console:

*** Terminating app due to uncaught exception of class '__NSCFConstantString'
terminating with uncaught exception of type __NSCFConstantString

When in debug mode, Rtt_DEBUG been set, Rtt_ASSERT(), Rtt_UserBreak() before the crash, so we need comment it out to get the real crash.

If you google apple silicon exception uncaught, you'll find a lot of similar issues like xamarin/xamarin-macios#16546, root-project/root#7541.

I hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants