lmparppei / Beat

Beat - a simple and elegant screenwriting app for macOS
Other
175 stars 30 forks source link

1.92.8 Crash report #103

Closed ftolsson closed 2 years ago

ftolsson commented 2 years ago

Just updated to 1.92.8 and got a crash while writing — it might be caused by my plugin, but if so it's a crash I've never experienced in previous builds so there's probably something that has changed in the app regardless...

The (I suppose) most telling info is this:

Application Specific Information:
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x600001fdd380> was mutated while being enumerated.'
terminating with uncaught exception of type NSException
abort() called

But I'll send you the entire crashlog as a pm on discord if you want it. Here's hoping it was a one-off (or a seldom-off, at least).

lmparppei commented 2 years ago

Could you copy-paste the whole crash report or at least the callback stack?

ftolsson commented 2 years ago

Me and terminology... 😊

Here's hoping this is what you're asking for:

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x600001fdd380> was mutated while being enumerated.'
terminating with uncaught exception of type NSException
abort() called

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff2065b1db __exceptionPreprocess + 242
1   libobjc.A.dylib                     0x00007fff20394d92 objc_exception_throw + 48
2   CoreFoundation                      0x00007fff206d72f3 __NSFastEnumerationMutationHandler + 151
3   CoreFoundation                      0x00007fff205a8517 -[NSArray indexOfObject:] + 222
4   Beat                                0x0000000101d3bfd3 Beat + 614355
5   Beat                                0x0000000101d4cc32 Beat + 683058
6   CoreFoundation                      0x00007fff205c46fc __invoking___ + 140
7   CoreFoundation                      0x00007fff205c459d -[NSInvocation invoke] + 305
8   JavaScriptCore                      0x00007fff368f1f7f _ZN3JSC24ObjCCallbackFunctionImpl4callEP9JSContextP13OpaqueJSValuemPKPKS3_PS6_ + 431
9   JavaScriptCore                      0x00007fff368f1957 _ZN3JSCL34objCCallbackFunctionCallAsFunctionEPK15OpaqueJSContextP13OpaqueJSValueS4_mPKPKS3_PS6_ + 231
10  JavaScriptCore                      0x00007fff368f48d0 _ZN3JSC19APICallbackFunction8callImplINS_20ObjCCallbackFunctionEEExPNS_14JSGlobalObjectEPNS_9CallFrameE + 576
11  JavaScriptCore                      0x00007fff368811a4 llint_entry + 116597
12  JavaScriptCore                      0x00007fff3687f0a8 llint_entry + 108153
13  JavaScriptCore                      0x00007fff36864836 vmEntryToJavaScript + 216
14  JavaScriptCore                      0x00007fff36ed9796 _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 518
15  JavaScriptCore                      0x00007fff371146e4 _ZN3JSC12profiledCallEPNS_14JSGlobalObjectENS_15ProfilingReasonENS_7JSValueERKNS_8CallDataES3_RKNS_7ArgListE + 164
16  JavaScriptCore                      0x00007fff3652fb37 JSObjectCallAsFunction + 807
17  JavaScriptCore                      0x00007fff36632460 -[JSValue callWithArguments:] + 432
18  Beat                                0x0000000101d47cc9 Beat + 662729
19  libdispatch.dylib                   0x00007fff2033e623 _dispatch_call_block_and_release + 12
20  libdispatch.dylib                   0x00007fff2033f806 _dispatch_client_callout + 8
21  libdispatch.dylib                   0x00007fff20341e37 _dispatch_queue_override_invoke + 775
22  libdispatch.dylib                   0x00007fff2034e818 _dispatch_root_queue_drain + 326
23  libdispatch.dylib                   0x00007fff2034ef70 _dispatch_worker_thread2 + 92
24  libsystem_pthread.dylib             0x00007fff204e6417 _pthread_wqthread + 244
25  libsystem_pthread.dylib             0x00007fff204e542f start_wqthread + 15
lmparppei commented 2 years ago

The crash happens in ContinuousFountainParser after requesting for lines in a scene, because the .lines array was mutated while in a for loop. linesForScene was called in JS, so the crash itself was caused by your plugin, but the bug is probably mine. The method should make a copy of lines array if not in main thread.

lmparppei commented 2 years ago

NO! Actually, the mutation took place when trying to ask for the index of scene heading. I've already taken some steps to avoid this, but seemingly not enough.

ftolsson commented 2 years ago

I see -- me asking for that index, or you?

I was writing mid-scene, so theoretically a. it could be me, but b. it shouldn't be me because I should be debouncing stuff while writing. But who knows, once the code is large enough I guess lots of things are happening all the time... Main question though: Did you recently change something? Because most importantly c. this is a crash I've never seen before.

lmparppei commented 2 years ago

I changed some stuff in the Outline View, but that shouldn't cause this, because it relies on the same outline stuff. I'm pretty sure this was a rare one-off, where your JS code tried to ask for lines in a scene in the background, and at the same nanosecond, you managed to press a key.

I put an extra thread check into the method, so let's hope that fixes the problem. I'll post a beta tomorrow.

ftolsson commented 2 years ago

and at the same nanosecond, you managed to press a key.

Storytelling is all about timing!

ftolsson commented 2 years ago

Also: thanks! 👍

lmparppei commented 2 years ago

This should be fixed with the use of .safeLines. Let's open it up again if something happens.