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

Crash on MacOS when calling Clipboard.generalClipboard.clearData twice #3648

Open
ylazy opened this issue Jan 16, 2025 · 7 comments
Open

Crash on MacOS when calling Clipboard.generalClipboard.clearData twice #3648

ylazy opened this issue Jan 16, 2025 · 7 comments
Labels

Comments

@ylazy
Copy link

ylazy commented Jan 16, 2025

Problem Description

Describe your problem in detail. Include the following information:

  • Which AIR SDK did you use? AirSDK 51.1.3.1; AirSDK 32.0
  • Describe the affected environment: MacOS Sonoma 14.0 (VMWare); MacOS Sonoma 14.4.1 (real MacBook)
  • Can you reproduce it yourself, or did you get reports from other users? If so, how many users are affected (percentage)? All users affected.

Steps to Reproduce

I'm using curl to upload some files to a server. I'm using NativeProcess to do the job.
It's fine at the first time of uploading.
When I repeat that (the second time of uploading), my application exit (crash). Sometime it also happens at the first time of uploading.
This is the log:

2025-01-16 03:14:05.256 adl[1510:34591] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007ff8154ccff2 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff814fc4629 objc_exception_throw + 48
	2   CoreFoundation                      0x00007ff8155ac111 _CFThrowFormattedException + 202
	3   CoreFoundation                      0x00007ff8155ad781 -[__NSCFArray removeObjectAtIndex:].cold.1 + 41
	4   CoreFoundation                      0x00007ff8154ced6b -[__NSCFArray removeObjectAtIndex:] + 98
	5   CoreFoundation                      0x00007ff81544b357 -[NSMutableArray removeObject:] + 163
	6   Adobe AIR                           0x000000010979c33e startAIR + 7233442
	7   Adobe AIR                           0x000000010979c8f6 startAIR + 7234906
	8   Adobe AIR                           0x0000000109819b79 startAIR + 7747549
	9   Adobe AIR                           0x0000000109278455 startAIR + 1843385
	10  ???                                 0x000028b2f9eb1fbf 0x0 + 44749162225599
	11  ???                                 0x000028b2f9eb1dac 0x0 + 44749162225068
	12  ???                                 0x000028b2f9eb26f6 0x0 + 44749162227446
	13  ???                                 0x000028b2f9eb2f1c 0x0 + 44749162229532
	14  ???                                 0x0000144bb9b9761e 0x0 + 22315471042078
	15  ???                                 0x0000144bb9b98104 0x0 + 22315471044868
	16  ???                                 0x0000144bb9b9835a 0x0 + 22315471045466
	17  ???                                 0x0000144bb9bb2b64 0x0 + 22315471154020
	18  Adobe AIR                           0x000000010927245c startAIR + 1818816
	19  Adobe AIR                           0x0000000109724405 startAIR + 6742121
	20  Adobe AIR                           0x0000000109722cf2 startAIR + 6736214
	21  Adobe AIR                           0x000000010983f5d8 startAIR + 7901756
	22  Adobe AIR                           0x0000000109278455 startAIR + 1843385
	23  ???                                 0x00000f746037cccc 0x0 + 16992504892620
	24  ???                                 0x000005d86c008e57 0x0 + 6427083050583
	25  ???                                 0x0000144bb9b98577 0x0 + 22315471046007
	26  ???                                 0x0000144bb9bb2c04 0x0 + 22315471154180
	27  Adobe AIR                           0x000000010927245c startAIR + 1818816
	28  Adobe AIR                           0x0000000109724405 startAIR + 6742121
	29  Adobe AIR                           0x0000000109722cf2 startAIR + 6736214
	30  Adobe AIR                           0x000000010983f5d8 startAIR + 7901756
	31  Adobe AIR                           0x0000000109278455 startAIR + 1843385
	32  ???                                 0x00000f746037cccc 0x0 + 16992504892620
	33  ???                                 0x000005d86c008e57 0x0 + 6427083050583
	34  ???                                 0x0000144bb9b987cf 0x0 + 22315471046607
	35  ???                                 0x0000144bb9bb2c53 0x0 + 22315471154259
	36  Adobe AIR                           0x0000000109278b04 startAIR + 1845096
	37  Adobe AIR                           0x0000000109278455 startAIR + 1843385
	38  ???                                 0x0000003b1e2fb9cc 0x0 + 253909514700
	39  ???                                 0x000028b2f9e968fe 0x0 + 44749162113278
	40  ???                                 0x000028b2f9e9749a 0x0 + 44749162116250
	41  ???                                 0x0000144bb9b9d36c 0x0 + 22315471065964
	42  Adobe AIR                           0x000000010927245c startAIR + 1818816
	43  Adobe AIR                           0x0000000109724405 startAIR + 6742121
	44  Adobe AIR                           0x0000000109722cf2 startAIR + 6736214
	45  Adobe AIR                           0x000000010983f5d8 startAIR + 7901756
	46  Adobe AIR                           0x0000000109278455 startAIR + 1843385
	47  ???                                 0x00000f746037cccc 0x0 + 16992504892620
	48  ???                                 0x000005d86c008e57 0x0 + 6427083050583
	49  ???                                 0x000028b2f9e9798f 0x0 + 44749162117519
	50  Adobe AIR                           0x000000010927897a startAIR + 1844702
	51  Adobe AIR                           0x0000000109278c88 startAIR + 1845484
	52  Adobe AIR                           0x0000000109278455 startAIR + 1843385
	53  ???                                 0x00001f55414b1fc2 0x0 + 34451028123586
	54  ???                                 0x00001f55414b0f44 0x0 + 34451028119364
	55  Adobe AIR                           0x000000010927245c startAIR + 1818816
	56  Adobe AIR                           0x0000000109724405 startAIR + 6742121
	57  Adobe AIR                           0x0000000109722cf2 startAIR + 6736214
	58  Adobe AIR                           0x000000010983f5d8 startAIR + 7901756
	59  Adobe AIR                           0x0000000109278455 startAIR + 1843385
	60  ???                                 0x00000f746037cccc 0x0 + 16992504892620
	61  ???                                 0x000005d86c008e57 0x0 + 6427083050583
	62  ???                                 0x000005f37d447f50 0x0 + 6543336832848
	63  ???                                 0x000005f37d447914 0x0 + 6543336831252
	64  Adobe AIR                           0x000000010927245c startAIR + 1818816
	65  Adobe AIR                           0x0000000109724405 startAIR + 6742121
	66  Adobe AIR                           0x0000000109724d02 startAIR + 6744422
	67  Adobe AIR                           0x00000001098c545e startAIR + 8450242
	68  Adobe AIR                           0x00000001099d9f0a startAIR + 9583470
	69  Adobe AIR                           0x00000001099daaa8 startAIR + 9586444
	70  Adobe AIR                           0x00000001097b0303 startAIR + 7315303
	71  Adobe AIR                           0x00000001097afc07 startAIR + 7313515
	72  CoreFoundation                      0x00007ff81545a327 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	73  CoreFoundation                      0x00007ff81545a2c9 __CFRunLoopDoSource0 + 157
	74  CoreFoundation                      0x00007ff81545a094 __CFRunLoopDoSources0 + 215
	75  CoreFoundation                      0x00007ff815458d11 __CFRunLoopRun + 919
	76  CoreFoundation                      0x00007ff815458362 CFRunLoopRunSpecific + 557
	77  HIToolbox                           0x00007ff81fb8a819 RunCurrentEventLoopInMode + 292
	78  HIToolbox                           0x00007ff81fb8a626 ReceiveNextEventCommon + 665
	79  HIToolbox                           0x00007ff81fb8a371 _BlockUntilNextEventMatchingListInModeWithFilter + 66
	80  AppKit                              0x00007ff8189c8571 _DPSNextEvent + 880
	81  AppKit                              0x00007ff8189c72d3 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1304
	82  AppKit                              0x00007ff8189b8d11 -[NSApplication run] + 603
	83  Adobe AIR                           0x00000001090b5d9a Adobe AIR + 11674
	84  adl                                 0x000000010689aac2 _Z11RuntimeMainPKci + 168
	85  dyld                                0x00007ff814ff83a6 start + 1942
)
libc++abi: terminating due to uncaught exception of type NSException

If I manually run curl commands via Terminal or PowerShell multiple times, everything is ok.

What should I do now?

Thanks!

@ylazy ylazy added the Bug label Jan 16, 2025
@ajwfrost
Copy link
Collaborator

Hi

Can you please double-check the version of AIR that you're using there? you're mentioning "AirSDK 51.1.3.1; AirSDK 32.0" - but the call stack doesn't match up to 51.1.3.1 from what we can see. Not sure why there's mention of AIR 32?

Plus we'd need to know if it's running as arm64 (on Apple-silicon Mac) or x86_64 - I suspect the latter, looking at the instruction addresses, but it would be good to confirm that.

And this only happens when you're calling a NativeProcess? We couldn't see any relevant use of NSMutableArray removeObject in that code; is there any possibility of creating a simple SWF that you could share which reproduces the problem?

thanks

@ylazy
Copy link
Author

ylazy commented Jan 17, 2025

Hi @ajwfrost

I've tested with both AirSDK 32 and AirSDK 51, the same issue happened. The call stack above is what I got from AirSDK 32. This is the call stack from AirSDK 51:

2025-01-16 17:44:23.374 adl[1117:16321] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007ff80d8b2ff2 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff80d3aa629 objc_exception_throw + 48
	2   CoreFoundation                      0x00007ff80d992111 _CFThrowFormattedException + 202
	3   CoreFoundation                      0x00007ff80d993781 -[__NSCFArray removeObjectAtIndex:].cold.1 + 41
	4   CoreFoundation                      0x00007ff80d8b4d6b -[__NSCFArray removeObjectAtIndex:] + 98
	5   CoreFoundation                      0x00007ff80d831357 -[NSMutableArray removeObject:] + 163
	6   Adobe AIR                           0x000000010bd9c33e startAIR + 7233442
	7   Adobe AIR                           0x000000010bd9c8f6 startAIR + 7234906
	8   Adobe AIR                           0x000000010be19b79 startAIR + 7747549
	9   Adobe AIR                           0x000000010b878455 startAIR + 1843385
	10  ???                                 0x00001d73cfe1c61f 0x0 + 32383246124575
	11  ???                                 0x00001d73cfe1c40c 0x0 + 32383246124044
	12  ???                                 0x00001d73cfe1cd56 0x0 + 32383246126422
	13  ???                                 0x00001d73cfe1d57c 0x0 + 32383246128508
	14  ???                                 0x00000dd973d8806e 0x0 + 15227602632814
	15  ???                                 0x00000dd973d88b54 0x0 + 15227602635604
	16  ???                                 0x00000dd973d88daa 0x0 + 15227602636202
	17  ???                                 0x00000dd973da1f1c 0x0 + 15227602738972
	18  Adobe AIR                           0x000000010b87245c startAIR + 1818816
	19  Adobe AIR                           0x000000010bd24405 startAIR + 6742121
	20  Adobe AIR                           0x000000010bd22cf2 startAIR + 6736214
	21  Adobe AIR                           0x000000010be3f5d8 startAIR + 7901756
	22  Adobe AIR                           0x000000010b878455 startAIR + 1843385
	23  ???                                 0x0000091041a57ccc 0x0 + 9965425491148
	24  ???                                 0x00002aee33c08e57 0x0 + 47202558840407
	25  ???                                 0x00000dd973d88fc7 0x0 + 15227602636743
	26  ???                                 0x00000dd973da1fbc 0x0 + 15227602739132
	27  Adobe AIR                           0x000000010b87245c startAIR + 1818816
	28  Adobe AIR                           0x000000010bd24405 startAIR + 6742121
	29  Adobe AIR                           0x000000010bd22cf2 startAIR + 6736214
	30  Adobe AIR                           0x000000010be3f5d8 startAIR + 7901756
	31  Adobe AIR                           0x000000010b878455 startAIR + 1843385
	32  ???                                 0x0000091041a57ccc 0x0 + 9965425491148
	33  ???                                 0x00002aee33c08e57 0x0 + 47202558840407
	34  ???                                 0x00000dd973d8921f 0x0 + 15227602637343
	35  ???                                 0x00000dd973da200b 0x0 + 15227602739211
	36  Adobe AIR                           0x000000010b878b04 startAIR + 1845096
	37  Adobe AIR                           0x000000010b878455 startAIR + 1843385
	38  ???                                 0x00001326156f8094 0x0 + 21054289313940
	39  ???                                 0x00000fea55f58056 0x0 + 17499138916438
	40  ???                                 0x00000fea55f58bf2 0x0 + 17499138919410
	41  ???                                 0x00000dd973d8ddbc 0x0 + 15227602656700
	42  Adobe AIR                           0x000000010b87245c startAIR + 1818816
	43  Adobe AIR                           0x000000010bd24405 startAIR + 6742121
	44  Adobe AIR                           0x000000010bd22cf2 startAIR + 6736214
	45  Adobe AIR                           0x000000010be3f5d8 startAIR + 7901756
	46  Adobe AIR                           0x000000010b878455 startAIR + 1843385
	47  ???                                 0x0000091041a57ccc 0x0 + 9965425491148
	48  ???                                 0x00002aee33c08e57 0x0 + 47202558840407
	49  ???                                 0x00000fea55f590e7 0x0 + 17499138920679
	50  Adobe AIR                           0x000000010b87897a startAIR + 1844702
	51  Adobe AIR                           0x000000010b878c88 startAIR + 1845484
	52  Adobe AIR                           0x000000010b878455 startAIR + 1843385
	53  ???                                 0x0000300b455a3fc2 0x0 + 52824966315970
	54  ???                                 0x0000300b455a2f44 0x0 + 52824966311748
	55  Adobe AIR                           0x000000010b87245c startAIR + 1818816
	56  Adobe AIR                           0x000000010bd24405 startAIR + 6742121
	57  Adobe AIR                           0x000000010bd22cf2 startAIR + 6736214
	58  Adobe AIR                           0x000000010be3f5d8 startAIR + 7901756
	59  Adobe AIR                           0x000000010b878455 startAIR + 1843385
	60  ???                                 0x0000091041a57ccc 0x0 + 9965425491148
	61  ???                                 0x00002aee33c08e57 0x0 + 47202558840407
	62  ???                                 0x000029c51505bf50 0x0 + 45926437994320
	63  ???                                 0x000029c51505b914 0x0 + 45926437992724
	64  Adobe AIR                           0x000000010b87245c startAIR + 1818816
	65  Adobe AIR                           0x000000010bd24405 startAIR + 6742121
	66  Adobe AIR                           0x000000010bd24d02 startAIR + 6744422
	67  Adobe AIR                           0x000000010bec545e startAIR + 8450242
	68  Adobe AIR                           0x000000010bfd9f0a startAIR + 9583470
	69  Adobe AIR                           0x000000010bfdaaa8 startAIR + 9586444
	70  Adobe AIR                           0x000000010bdb0303 startAIR + 7315303
	71  Adobe AIR                           0x000000010bdafc07 startAIR + 7313515
	72  CoreFoundation                      0x00007ff80d840327 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	73  CoreFoundation                      0x00007ff80d8402c9 __CFRunLoopDoSource0 + 157
	74  CoreFoundation                      0x00007ff80d840094 __CFRunLoopDoSources0 + 215
	75  CoreFoundation                      0x00007ff80d83ed11 __CFRunLoopRun + 919
	76  CoreFoundation                      0x00007ff80d83e362 CFRunLoopRunSpecific + 557
	77  HIToolbox                           0x00007ff817f70819 RunCurrentEventLoopInMode + 292
	78  HIToolbox                           0x00007ff817f70626 ReceiveNextEventCommon + 665
	79  HIToolbox                           0x00007ff817f70371 _BlockUntilNextEventMatchingListInModeWithFilter + 66
	80  AppKit                              0x00007ff810dae571 _DPSNextEvent + 880
	81  AppKit                              0x00007ff810dad2d3 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1304
	82  AppKit                              0x00007ff810d9ed11 -[NSApplication run] + 603
	83  Adobe AIR                           0x000000010b6b5d9a Adobe AIR + 11674
	84  adl                                 0x0000000108e86ac2 _Z11RuntimeMainPKci + 168
	85  dyld                                0x00007ff80d3de3a6 start + 1942
)
libc++abi: terminating due to uncaught exception of type NSException

Sometimes I got the call stack from the debug console. Sometimes I see a popup dialog that contains the call stack. Sometimes the application just crash and exit with nothing to see at all.

I've tested on two machine:

  • MacOS Sonoma 14.0 running in a virtual machine on Windows 11. Virtualized chipset is displaying as: Unknown.
  • MacOS Sonoma 14.4.1 running in Macbook M1 - ARM processor.

I don't know whether the issue happened when I called a NativeProcess API or not. But it must be related to NativeProcess API. Because it happened at the end of uploading (after uploading complete). And if I replace curl to another tool and doing a similiar task, the issue did not happened.

Currently it's not possible to share the application that I'm working with, because it's running through a VPN and using password. But I'll try to create a simple application to see if the issue happens with another server with no VPN connection.

Thank you!

@ajwfrost
Copy link
Collaborator

Presumably that call stack was from the 14.0 Sonoma on the VM. If you're able to reproduce it on the M1, it would be good, and please confirm the full version code for the runtime. Call stacks with ARM code are a bit easier to analyse (RISC) rather than x86_64 (variable-width instructions..)

The above doesn't look any different from the AIR 32 one; your call stack from the other issue looked different in some aspects, but the final part of the call stack (where it comes out of JIT code and then ends up with a few functions before the removeObject call) starts with what looks like a math-type operation, and the disassembly at that point doesn't show any further function calls... so I don't think we've got the correct match from the debug file here against the crash log there..

thanks

@ylazy
Copy link
Author

ylazy commented Jan 18, 2025

Hi @ajwfrost
With the help of debugger tools, I finally found out where the problem is:

Video_250118213217_Slice_Slice.mp4

My application crashed at this line:

Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, text);

the value of text is https://static.eclick.vn/html5/vs_040/ads/m/mobifone/2024/12/28/12345/300x600/test/dfp/pc/std/fixed/index.html

It's strange that the issue only happended at the second time of uploading. The first time of uploading, the value of text is https://static.eclick.vn/html5/vs_039/ads/m/mobifone/2024/12/28/12345/300x600/test/dfp/pc/std/fixed/index.html (39 vs 40).

And since I can connect to the debugger, I didn't see the crash stack call anymore.

@ylazy
Copy link
Author

ylazy commented Jan 18, 2025

This simple code will cause the app crash on MacOS:

Clipboard.generalClipboard.clearData(ClipboardFormats.TEXT_FORMAT);
Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, "foo/123");
Clipboard.generalClipboard.clearData(ClipboardFormats.TEXT_FORMAT);
Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, "bar/456"); // CRASH

I'm sorry. You're right. This issue is not related to NativeProcess. When I use another tool, the issue did not happen because there's an error after uploading then the code above did not run.

@ajwfrost
Copy link
Collaborator

Thanks @ylazy - so the clipboard was one of those few locations in the code where removeObject is called. Looking at it, we are creating a mutable array - or at least, trying to - and then later on getting this and failing when trying to modify it.

I think the call to create the mutable array in the first place is wrong i.e. despite being a function call on the NSMutableArray class, I suspect it's returning a non-modifiable array. Although it does allow a call to addObject so maybe it's some internal workings of the Mac clipboard that settting/getting the list does not actually give you back the object that you set... I'll ask one of my colleagues to investigate property and make sure this gets sorted out!

FYI it's the clearData after the setData call that is putting this into a bad state such that the next setData call will crash it. So if you can avoid calling clearData you may be able to work around it?

thanks

@ylazy
Copy link
Author

ylazy commented Jan 21, 2025

FYI it's the clearData after the setData call that is putting this into a bad state such that the next setData call will crash it. So if you can avoid calling clearData you may be able to work around it?

Yes my app does not crash anymore if I only call setData.

Thank you!

@ylazy ylazy changed the title Crash on MacOS when using curl via NativeProcess to upload files Crash on MacOS when calling Clipboard.generalClipboard.clearData twice Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants