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

[SR-15680] EXC_BAD_ACCESS error using withTaskGroup #57959

Open
swift-ci opened this issue Jan 3, 2022 · 2 comments
Open

[SR-15680] EXC_BAD_ACCESS error using withTaskGroup #57959

swift-ci opened this issue Jan 3, 2022 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 3, 2022

Previous ID SR-15680
Radar None
Original Reporter Stefan Springer (JIRA User)
Type Bug
Environment

Swift 5.5.2 on macOS 12.0.1 (ARM), UPDATE: also with macOS 12.1 (ARM)

Additional Detail from JIRA
Votes 0
Component/s swift
Labels Bug, Concurrency
Assignee None
Priority Medium

md5: cab31ad2eaa04857aab2c34d5f394e13

Issue Description:

I am getting EXC_BAD_ACCESS errors using withTaskGroup when using larger data. See my demo Swift package https://github.com/stefanspringer1/BadAccessDemo.git [UPDATE: better see the other repository mentioned in the next paragraph]. In my real project, I could avoid the error by keeping track outside of withTaskGroup of the date used, but then I cannot remove that data from the tracking (I then get EXC_BAD_ACCESS errors again), and this "trick" did not work for the demo project. It seems that the data just dissapears.

UPDATE: A second repository https://github.com/stefanspringer1/BadAccessDemo2.git is more succinct. Also see the discussion on https://forums.swift.org/t/exc-bad-access-using-withtaskgroup-depending-on-size-of-data/54506. I am getting an EXC_BAD_ACCESS when using withTaskGroup in this way, depending on how big the structure being built is, the structure being of same kind, and being completely read and then written, so the structure itself should be OK. The start of the crash data for the second repository is:


Translated Report (Full Report Below)

Process: BadAccessDemo2 [51166]
Path: /Users/USER/*/BadAccessDemo2
Identifier: BadAccessDemo2
Version: ???
Code Type: ARM-64 (Native)
Parent Process: zsh [47252]
Responsible: Terminal [47250]
User ID: 501

Date/Time: 2022-01-07 21:31:04.0692 +0100
OS Version: macOS 12.0.1 (21A559)
Report Version: 12
Anonymous UUID: AC3DEC9D-06B9-3E64-2D4B-44D808CBB77B

Sleep/Wake UUID: 6E6113C5-9465-476E-A068-3B373C450C7B

Time Awake Since Boot: 470000 seconds
Time Since Wake: 19757 seconds

System Integrity Protection: enabled

Crashed Thread: 1 Dispatch queue: com.apple.root.user-initiated-qos.cooperative

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000016fcdfff0
Exception Codes: 0x0000000000000002, 0x000000016fcdfff0
Exception Note: EXC_CORPSE_NOTIFY

Termination Reason: Namespace SIGNAL, Code 10 Bus error: 10
Terminating Process: exc handler [51166]

VM Region Info: 0x16fcdfff0 is in 0x16fcdc000-0x16fce0000; bytes after start: 16368 bytes before end: 15
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
Stack 16f4e0000-16fcdc000 [ 8176K] rw-/rwx SM=PRV thread 0
--> STACK GUARD 16fcdc000-16fce0000 [ 16K] --/rwx SM=NUL ... for thread 1
Stack 16fce0000-16fd68000 [ 544K] rw-/rwx SM=PRV thread 1

Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x1bdfbd954 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1bdfbdd00 mach_msg + 76
2 CoreFoundation 0x1be0c4e38 __CFRunLoopServiceMachPort + 372
3 CoreFoundation 0x1be0c32f0 __CFRunLoopRun + 1212
4 CoreFoundation 0x1be0c2694 CFRunLoopRunSpecific + 600
5 CoreFoundation 0x1be14ec28 CFRunLoopRun + 64
6 libswift_Concurrency.dylib 0x23b5e8ee8 swift_task_asyncMainDrainQueueImpl() + 40
7 libswift_Concurrency.dylib 0x23b5e8ec0 swift_task_asyncMainDrainQueue + 100
8 BadAccessDemo2 0x100127d04 BadAccessDemo2_main + 84
9 dyld 0x10059d0f4 start + 520

Thread 1 Crashed:: Dispatch queue: com.apple.root.user-initiated-qos.cooperative
0 libswiftCore.dylib 0x1cb3da1b4 swift_arrayDestroy + 4
1 libswiftCore.dylib 0x1cb125794 _DictionaryStorage.deinit + 268
2 libswiftCore.dylib 0x1cb1258c8 DictionaryStorage._deallocating_deinit + 16
3 libswiftCore.dylib 0x1cb3e7774 _swift_release_dealloc + 56
4 BadAccessDemo2 0x10015de14 XElement.deinit + 60
5 BadAccessDemo2 0x10015de48 XElement.__deallocating_deinit + 12
6 libswiftCore.dylib 0x1cb3e7774 _swift_release_dealloc + 56
7 libswiftCore.dylib 0x1cb3e8724 bool swift::HeapObjectSideTableEntry::decrementStrong<(swift::PerformDeinit)1>(unsigned int) + 292
8 BadAccessDemo2 0x10015de2c XElement.deinit + 84
9 BadAccessDemo2 0x10015de48 XElement.__deallocating_deinit + 12
10 libswiftCore.dylib 0x1cb3e7774 _swift_release_dealloc + 56
11 libswiftCore.dylib 0x1cb3e8724 bool swift::HeapObjectSideTableEntry::decrementStrong<(swift::PerformDeinit)1>(unsigned int) + 292
...

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 1, 2022

Comment by Stefan Springer (JIRA)

The reason might be a deep recursion of deinits, see https://bugs.swift.org/browse/SR-15803 for this issue.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@tomerd
Copy link
Member

tomerd commented May 17, 2022

cc @ktoso @DougGregor

@AnthonyLatsis AnthonyLatsis added run-time crash Bug → crash: Swift code crashed during execution crash Bug: A crash, i.e., an abnormal termination of software and removed swift labels Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features crash Bug: A crash, i.e., an abnormal termination of software run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

3 participants