Skip to content

Null pointer dereference in CFBundleGetAllBundles() #5208

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

Open
cmcgee1024 opened this issue May 6, 2025 · 0 comments
Open

Null pointer dereference in CFBundleGetAllBundles() #5208

cmcgee1024 opened this issue May 6, 2025 · 0 comments

Comments

@cmcgee1024
Copy link
Member

cmcgee1024 commented May 6, 2025

I am getting the following stack of a segmentation fault on Linux with Swift 6.1.0:

💣 Program crashed: Bad pointer dereference at 0x0000000000000000

Thread 0 crashed:

 0 0x0000ffff9b16b2dc _CFIsSwift + 12 in libFoundation.so
 1 0x0000ffff9b126500 CFBundleGetAllBundles + 211 in libFoundation.so
 2 0x0000ffff9af9850c specialized static Bundle.allBundlesRegardlessOfType.getter + 27 in libFoundation.so
 3 0x0000ffff9af98824 specialized Bundle.init(for:) + 499 in libFoundation.so
 4 static SWBBuildServiceConnection.buildServiceLocation(for:overridingServiceBundleURL:) + 3199 in swift-build at /swiftpm/.build/checkouts/swift-build/Sources/SwiftBuild/SWBBuildServiceConnection.swift:499:40

After some debugging, CFBundleGetAllBundles() is called with _allBundles. It creates a mutable copy of it using __CFArrayCreateMutableCopy0 and that does a CF_IS_SWIFT check. That check involves dereferencing the array for obj->isa and then segfaults.

Steps to reproduce:

swift run swift-build --package-path Fixtures/Miscellaneous/Plugins/MySourceGenPlugin --build-system swiftbuild --vv
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

1 participant