Xcode Sanitizers and Runtime Issues

RSS for tag

Xcode Runtime Issues are reports of programming errors found at run time. Issues can be found by variety of tools, including Address Sanitizer (ASan), Main Thread Checker (MTC), Thread Sanitizer (TSan), and Undefined Behavior Sanitizer (UBSan).

Posts under Xcode Sanitizers and Runtime Issues tag

24 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Swapping the `objectAtIndex:` method of `__NSArrayM` using `method_exchangeImplementations` will lead to continuous memory growth.
After swapping the -objectAtIndex: method using method_exchangeImplementations, it will cause continuous memory growth. Connect the iPhone and run the provided project. Continuously tap the iPhone screen. Observe Memory; it will keep growing. Sample code
1
0
38
1h
Possible thread performance checker bug
I'm experiencing some rare crash but only if I enable Xcode's "thread performance checker". The crash typically ends with these lines: std::_1::hash_table<std::_1::hash_value_type<long qosWaiterSignallerInvariantCheck ... and sometimes with "findPrimitiveInfoNoAssert" on the second line. I wonder if I am doing anything wrong, or is it a (hopefully known) issue in thread performance checker itself? It does look like some sort of data race bug, if to guess there's some internal dictionary that's not properly protected with a mutex or something. I'm using Xcode 16.4 running on macOS 15.5, building and running an app on iPhone with iOS 18.5. Cheers!
0
0
41
1w
FoundationModels Content Sanitizer Blocking Legitimate Text Processing
I'm developing a macOS application using the FoundationModels framework (LanguageModelSession) and encountering issues with the content sanitizer blocking legitimate text input. ** Issue Description:** The content sanitizer is flagging text strings that contain certain substrings, even when they represent legitimate technical content. For example: F_SEEL_***1S.wav (sE Electronics ***1S microphone model) Technical product identifiers Serial numbers and version codes ** Broader Concern:** The content sanitizer appears to be applying restrictions that seem inappropriate for user-owned content. Even if a filename were something like "human ***.wav", users should have the right to process their own legitimate files on their own devices without content filtering interference. ** Error Messages:** SensitiveContentSettings: Sanitizer model found unsafe content in value FoundationModels.LanguageModelSession.GenerationError error 2 ** Questions:** Is there a way to disable content sanitization for processing user-owned content? 2. What's the recommended approach for applications that need to handle arbitrary user text? 3. Are there APIs to process personal content without filtering restrictions? ** Environment:** macOS 26.0 FoundationModels framework LanguageModelSession Any guidance would be appreciated.
1
0
202
3w
Enabling Main Thread Checker in Xcode May Cause Category Method Implementation Conflicts for UI-Related Classes
​Environment​: Xcode Version: 16.0 (latest stable release) iOS Version: 18.3.1 Devices: physical devices Configuration: Main Thread Checker enabled (Edit Scheme &amp;gt; Run &amp;gt; Diagnostics) ​Issue Description​ When the ​Main Thread Checker​ is enabled, methods defined in a UIViewController category (e.g., supportedInterfaceOrientations) fail to execute, whereas the subclass implementation of the same method works as expected. This conflicts with the normal behavior where ​both implementations should be called. ​Steps to Reproduce​ 1、Declare a category method in UIViewController+Extend.m: // UIViewController+Extend.m @implementation UIViewController (Extend) - (UIInterfaceOrientationMask)supportedInterfaceOrientations { NSLog(@"category supportedInterfaceOrientations hit"); return UIInterfaceOrientationMaskAll; } @end 2、Override the same method in a subclass ,call super methed(ViewController.m): // ViewController.m @implementation ViewController - (UIInterfaceOrientationMask)supportedInterfaceOrientations { NSLog(@"subclass called supportedInterfaceOrientations called"); return [super supportedInterfaceOrientations]; // Expected to call the category implementation } @end 3、​Expected Behavior​ (Main Thread Checker ​disabled): subclass called supportedInterfaceOrientations called category supportedInterfaceOrientations hit 4、Actual Behavior​ (Main Thread Checker ​enabled): subclass called supportedInterfaceOrientations called // category supportedInterfaceOrientations hit ​Requested Resolution​ Please investigate: 1、Why Main Thread Checker disrupts category method invocation. 2、Whether this is a broader issue affecting other UIKit categories.
1
0
40
3w
AddressSanitizer __asan_cstring section and redzone padding behavior
Hi, I’m debugging an issue with AddressSanitizer (ASan) on macOS. I’ve noticed that strings placed in the __asan_cstring section are aligned and padded with redzones. When I attempt to copy a contiguous block of memory (e.g., memcpy(buf, asan_cstring, 4096)), ASan throws an out-of-bounds access error. On the other hand, strings in the __cstring section do not cause this problem, likely because they are laid out contiguously without redzone padding. Could you clarify: Are strings in __asan_cstring section aligned and padded individually with redzones? Is this redzone inserted after each global string for alignment or instrumentation purposes? Does this mean that bulk memory copies over this section (even if read-only) are inherently unsafe under ASan? Is there a recommended way to safely iterate or copy memory from __asan_cstring without triggering ASan violations? Any guidance on how redzones are managed in the __asan_cstring section would be very helpful.
0
0
45
May ’25
Xcode 16.3 and IOS 18.4 Update
So I use two MacBooks for work and different levels of projects, updated MacBook 1, and I was about to download and install Predictive Code Completion Model and IOS 18.4 Runtime. But doing the same for my second MacBook isn't working... I've been searching for days now, and the deadline for submission is fast approaching. I need help on this. At first, I thought it was a network thing and had to rush to my friends, but the same issue and nothing better IOS 18.4 Error `Download failed. Domain: DVTDownloadableErrorDomain Code: 41 User Info: { DVTErrorCreationDateKey = "2025-05-07 22:41:47 +0000"; } Download failed. Domain: DVTDownloadableErrorDomain Code: 41 Failed fetching catalog for assetType (com.apple.MobileAsset.iOSSimulatorRuntime), serverParameters ({ RequestedBuild = 22E238; }) Domain: DVTDownloadsUtilitiesErrorDomain Code: -1 Download failed due to not being scheduled or the download of the whole resource was not able to complete in the time allowed. (Catalog download for com.apple.MobileAsset.iOSSimulatorRuntime) Domain: com.apple.MobileAssetError.Download Code: 53 User Info: { checkTimeoutConditions = 1; } System Information macOS Version 15.4.1 (Build 24E263) Xcode 16.3 (23785) (Build 16E140) Timestamp: 2025-05-07T23:41:47+01:00` Predictive Code Completion Model `The operation couldn’t be completed. (IDELanguageModelKit.IDEModelDownloadAdapter.(unknown context at $1545d4bd8).DownloadError error 2.) Domain: IDELanguageModelKit.IDEModelDownloadAdapter.(unknown context at $1545d4bd8).DownloadError Code: 2 User Info: { DVTErrorCreationDateKey = "2025-05-07 22:42:56 +0000"; } There was an error transferring over the network. Domain: IDELanguageModelKit.IDEModelDownloadAdapter.(unknown context at $1545d4bd8).DownloadError Code: 2 System Information macOS Version 15.4.1 (Build 24E263) Xcode 16.3 (23785) (Build 16E140) Timestamp: 2025-05-07T23:42:56+01:00`
1
1
207
May ’25
EXC_BAD_ACCESS if Address or Thread Sanitizer is enabled
I'm getting EXC_BAD_ACCESS (code=2, address=0x7ff8a6e2fcce) when launching my app on the simulator with Address or Thread Sanitizer enabled. I'm running Xcode 16.3 (16E140) on macOS Sequoia 15.4.1 (24E263). The call stack looks like the following. On the device, there is no crash, but this message is printed to the console: malloc: nano zone abandoned due to inability to reserve vm space. (Not sure if it's related.) Does anybody know what is causing the crash? Thread 1 #0 0x0000000103361f5b in __sanitizer::MemoryMappingLayout::Next () #1 0x000000010336034b in __sanitizer::MemoryRangeIsAvailable () #2 0x000000010334db77 in __asan::InitializeShadowMemory () #3 0x0000000103395069 in __asan::AsanInitInternal() (.cold.1) () #4 0x000000010334d352 in __asan::AsanInitInternal () #5 0x0000000103394f65 in __asan_init.cold.1 () #6 0x000000010334d325 in __asan::AsanInitFromRtl () #7 0x0000000103343289 in wrap_malloc_default_zone () #8 0x00007ff801b15f86 in __malloc_init () #9 0x00007ffa160080be in libSystem_initializer () #10 0x000000010306eb11 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const () #11 0x000000010308f364 in invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const () #12 0x00000001030aad7c in invocation function for block in mach_o::Header::forEachSection(void (mach_o::Header::SectionInfo const&, bool&) block_pointer) const () #13 0x00000001030a83c9 in mach_o::Header::forEachLoadCommand () #14 0x00000001030a98c8 in mach_o::Header::forEachSection () #15 0x000000010308ef62 in dyld3::MachOAnalyzer::forEachInitializer () #16 0x000000010306e9ac in dyld4::Loader::findAndRunAllInitializers () #17 0x0000000103074da1 in dyld4::JustInTimeLoader::runInitializers () #18 0x00000001030807c5 in dyld4::APIs::runAllInitializersForMain () #19 0x000000010305efac in dyld4::prepare () #20 0x000000010305e36e in _dyld_sim_prepare () #21 0x000000010993b2a0 in dyld4::prepareSim () #22 0x0000000109939963 in dyld4::prepare () #23 0x000000010993981f in dyld4::start(dyld4::KernelArgs*, void*, void*)::$_0::operator()() const () #24 0x00000001099394da in start ()
8
1
264
Jun ’25
Remove old iOS Simulator Runtimes that are not listed in Xcode
Inside /Library/Developer/CoreSimulator I have 26GB (according to du -h) of old data that Xcode won't list under Window -> Devices & Simulators. Because of Apples decision to not let even the root user write in this directory I am unable to delete them with rm -r * or put them in the trash etc. The old runtimes are even listed in disk utility and can't be unmounted or delete from there - also due to missing permissions. How can I get rid of this if even Xcode won't list them? Also tried xcrun simctl delete all without success.
1
0
88
Apr ’25
My MacOS swift app refuses to close (When running on Monterrey, The app becomes unresponsive after it finishes all its work, and needs to be forcefully closed)
My MacOS swift app [myStuckApp5] refuses to close when running on Monterrey (The app becomes unresponsive after finishing its work, and needs to be forcefully closed). However, it closes as expected when running MacOS 13 and above. How can I troubleshoot this error? I'm attaching the content of the sys Log related to the app while it was stuck (too long to copy here...) This is the content of the related sys Log
0
0
325
Feb ’25
EXC_BAD_INSTRUCTION
public static func fetch(in context: NSManagedObjectContext, configurationBlock: (NSFetchRequest) -&amp;gt; () = { _ in }) -&amp;gt; [Self] { let request = NSFetchRequest(entityName: Self.entityName) configurationBlock(request) return try! context.fetch(request) } context.fetch(request), 'fetch' function has error. Thread 24: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
7
0
658
Mar ’25
dlopen problems with debug build, macOS SDK 15, and ASAN
Hello, There seems to be a regression with macOS SDK 15 and dynamically loading libraries if Address Sanitizer is turned on. Seems to only affect Debug builds, and .frameworks. I've also reported this via the Feedback Assistant: FB16513866 Here's a minimal repro, if anyone is interested: https://gist.github.com/peter-esik/6b00432e411be85333e14ae7d953966e I thought I'd post this here, as according to my web searches, this isn't a very well-known bug at this point.
2
0
263
Feb ’25
After building the project, the search form does not allow typing, but pasting works.
When I created a search box on the homepage, I was able to enter text in the input field while previewing in Xcode. However, after clicking "Build" and running the app, I couldn't type anything into the input field in the demo interface. Additionally, I received the following error message: If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable. Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem. How can I fix this issue? Here is my ContentView.swift code: import SwiftUI struct ContentView: View { @State private var searchText: String = "" @State private var isSearching: Bool = false var body: some View { NavigationStack { GeometryReader { geometry in VStack { Spacer() .frame(height: geometry.size.height.isNaN ? 0 : geometry.size.height * 0.3) VStack(spacing: 20) { Text("NMFC CODES LOOKUP") .font(.title2) .bold() TextField("Search...", text: $searchText) .textFieldStyle(PlainTextFieldStyle()) .padding(10) .frame(height: 40) .frame(width: geometry.size.width.isNaN ? 0 : geometry.size.width * 0.9) .background(Color.white) .cornerRadius(8) .overlay( HStack { Spacer() if !searchText.isEmpty { Button(action: { searchText = "" }) { Image(systemName: "xmark.circle.fill") .foregroundColor(.gray) .padding(.trailing, 8) } } } ) .overlay( RoundedRectangle(cornerRadius: 8) .stroke(Color.gray.opacity(0.5), lineWidth: 1) ) Button(action: { isSearching = true }) { Text("Search") .foregroundColor(.white) .frame(width: geometry.size.width * 0.9, height: 40) .background(Color.blue) .cornerRadius(8) } .disabled(searchText.isEmpty) Text("Created & Designed & Developed By Matt") .font(.caption) .foregroundColor(.gray) .padding(.top, 10) } Spacer() .frame(height: geometry.size.height * 0.7) } .frame(width: geometry.size.width) } .background(Color(red: 250/255, green: 245/255, blue: 240/255)) .navigationDestination(isPresented: $isSearching) { SearchResultsView(searchQuery: searchText) } } .background(Color(red: 250/255, green: 245/255, blue: 240/255)) .ignoresSafeArea() } } #Preview { ContentView() }
4
0
366
Feb ’25
Help needed to understand the issues from the app
Hi, There are total three errors from the app running on the device. First one is right after the app starts running on the device: Could not create a sandbox extension for '/var/containers/Bundle/Application/D4CBF093-EFB1-43C5-996D-7D5CB04BF643/appadmob.app' Below second issue comes when I dismiss the Interstitial Ad First responder issue detected: non-key window attempting reload - allowing due to manual keyboard (first responder window is <UIWindow: 0x10d11c700; frame = (0 0; 414 896); hidden = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x301749300>; backgroundColor = <UIDynamicSystemColor: 0x3002b3080; name = _windowBackgroundColor>; layer = <UIWindowLayer: 0x3019b7960>>, key window is <QUIWindow: 0x10880db00; baseClass = UIWindow; frame = (0 0; 414 896); gestureRecognizers = <NSArray: 0x3017276e0>; layer = <UIWindowLayer: 0x3019852f0>>) And the third issue below follows right after the second one: Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))" UserInfo={NSLocalizedFailureReason=((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))}> 0x118024480 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess NearSuspended Assertion' for process with PID=19180, error: (null) Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x3019254a0 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}} Also when I dismissed the interstitial ad, the screen looks greyed out, but when I touch the screen, the screen comes to normal. Could you please suggest any solution for the problems. Thanks,
2
0
2.1k
Dec ’24
Checking authorization status of AVCaptureDevice or CLLocation Manager gives runtime warnings in iOS 18
I have the following code in my ObservableObject class and recently XCode started giving purple coloured runtime issues with it (probably in iOS 18): Issue 1: Performing I/O on the main thread can cause slow launches. Issue 2: Interprocess communication on the main thread can cause non-deterministic delays. Issue 3: Interprocess communication on the main thread can cause non-deterministic delays. Here is the code: @Published var cameraAuthorization:AVAuthorizationStatus @Published var micAuthorization:AVAuthorizationStatus @Published var photoLibAuthorization:PHAuthorizationStatus @Published var locationAuthorization:CLAuthorizationStatus var locationManager:CLLocationManager override init() { // Issue 1 (Performing I/O on the main thread can cause slow launches.) cameraAuthorization = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) micAuthorization = AVCaptureDevice.authorizationStatus(for: AVMediaType.audio) photoLibAuthorization = PHPhotoLibrary.authorizationStatus(for: .addOnly) //Issue 1: Performing I/O on the main thread can cause slow launches. locationManager = CLLocationManager() locationAuthorization = locationManager.authorizationStatus super.init() //Issue 2: Interprocess communication on the main thread can cause non-deterministic delays. locationManager.delegate = self } And also in route Change notification handler of AVAudioSession.routeChangeNotification, //Issue 3: Hangs - Interprocess communication on the main thread can cause non-deterministic delays. let categoryPlayback = (AVAudioSession.sharedInstance().category == .playback) I wonder how checking authorisation status can give these issues? What is the fix here?
1
0
658
Dec ’24
[Bug] std::variant in containers triggers UBSan error in Xcode 16.x
I've discovered a bug in Xcode 16.0/16.1 where using std::variant in containers across compilation units triggers UBSan errors. This is a regression as it works correctly in Xcode 15.4. Here's a minimal reproduction case: [base.h] #pragma once #include <string> #include <variant> #include <forward_list> class Item { public: std::variant<std::monostate, std::string> value; }; typedef std::forward_list<Item> ItemList; class Test { public: void addItem(const Item& item); ItemList items; }; [base.cpp] #include "base.h" void Test::addItem(const Item& item) { items.push_front(item); } [main.cpp] #include "base.h" int main() { Test t; Item item; t.addItem(item); return 0; } To reproduce: Compile with UBSan enabled (-fsanitize=undefined) Occurs on both arm64 and x86_64 Occurs in both Xcode 16.0 and 16.1 Works correctly in Xcode 15.4 I've filed a Feedback Assistant report: FB15710420 Workaround: The issue can be avoided by implementing the addItem method in the header file instead of a separate compilation unit. Has anyone else encountered this issue? Are there other workarounds besides moving the implementation to the header?
4
0
440
Nov ’24
Debugging a macOS IPS dump
I have a macOS application built via command line (xcodebuild) using Xcode 16.1. Developed on ARM but end user is on Intel (same macOS 15.1). App crashed and they sent me a .IPS dump. From what MacGPT tells me: Reading an IPS (Incident Processing System) file from a macOS crash report in Xcode isn’t as straightforward as with iOS device logs. I can open the dump using Console. I see the IPS dump is partially symbolicated. Line in the dump says: Meteorologist 0x103e0348f 0x103d88000 + 504975 Referencing this article: Adding identifiable symbol names to a crash report | Apple Developer Documentation I run this command and see the same UUID for x86_64 as in the dump. dwarfdump --uuid /Users/ed/meteorologist/trunk/Build/Meteorologist.xcarchive/dSYMs/Meteorologist.app.dSYM/Contents/Resources/DWARF/Meteorologist I run this command: atos -arch x86_64 -o /Users/ed/meteorologist/trunk/Build/Meteorologist.xcarchive/dSYMs/Meteorologist.app.dSYM/Contents/Resources/DWARF/Meteorologist -l 0x103d88000 0x103e0348f And it says: fg: no current job Suggestions for what I’m missing?
1
0
639
Nov ’24
New phone and new xcode version fail
I recently bought a new phone and update xcode version to the latest. An app that I have been developing and worked perfectly fine would not be runned. I kept getting errors similar to below. Is that anything wrong with my setting or something? Class _TtC6SQLite6Backup is implemented in both /System/Library/PrivateFrameworks/LinkServices.framework/LinkServices (0x1f16db218) and /private/var/containers/Bundle/Application/E2xxxx2xxA-DF7B-xx-***-xxxxxxxx/xxxx.app/xxxxx.debug.dylib (0xxxxxx3d0). One of the two will be used. Which one is undefined.
1
0
712
Oct ’24
'Segmentation fault: 11' error after upgrading to the latest macOS version
Today I updated my macbook pro to macOS sequoia. with this I also downloaded the latest Xcode and visionOS 2 packages. I had a working project. Which did work with my vision pro which is updated to the latest visionOS 2. But now whenever I try to click on preview in xcode while editing a swift file I am receiving the following error: (lot of lines here) Library/Developer/Xcode/DerivedData/test2-fznbrpphddkqdaddrzamkayoajjm/Build/Intermediates.noindex/RealityKitContent.build/Debug-xrsimulator/RealityKitContent_RealityKitContent.build/DerivedSources/RealityAssetsGenerated/CustomComponentUSDInitializers.usda error: Tool terminated by ****** 'Segmentation fault: 11' I tried exiting and restarting my mac but the problem is not going away. Can someone help me with this? Thank you!
8
0
1.7k
Nov ’24
SwiftData/ModelContext.swift:3253: Fatal error: Failed to identify a store that can hold instances of SwiftData._KKMDBackingData<Presents_2024.Item> from [:]
I'm still getting this error (SwiftData/ModelContext.swift:3253: Fatal error: Failed to identify a store that can hold instances of SwiftData._KKMDBackingData<Presents_2024.Item> from [:]) in Xcode 16.1 Beta (16B5001e). The app works for a limited amount of time and then crashes with this error. It looks like the SwiftData model isn't being created properly and when a context is saved it crashes. Can you tell me if this error will be fixed in the next beta?
9
6
2.1k
Nov ’24