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

32 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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
223
1w
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
177
2w
[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
170
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
216
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
293
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 signal '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
857
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
5
1k
Nov ’24
Peculiar EXC_BAD_ACCESS, involving sparse matrices
Helo all, Currently, I'm working on an iOS app that performs measurement and shows the results to the user in a graph. I use a Savitzky-Golay filter to filter out noise, so that the graph is nice and smooth. However, the code that calculates the Savitzky-Golay coefficients using sparse matrices crashes sometimes, throwing an EXC_BAD_ACCESS. I tried to find out what the problem is by turning on Address Sanitizer and Thread Sanitizer, but, for some reason, the bad access exception isn't thrown when either of these is on. What else could I try to trace back the problem? Thanks in advance, CaS To reproduce the error, run the following: import SwiftUI import Accelerate struct ContentView: View { var body: some View { VStack { Button("Try", action: test) } .padding() } func test() { for windowLength in 3...100 { let coeffs = SavitzkyGolay.coefficients(windowLength: windowLength, polynomialOrder: 2) print(coeffs) } } } class SavitzkyGolay { static func coefficients(windowLength: Int, polynomialOrder: Int, derivativeOrder: Int = 0, delta: Int = 1) -> [Double] { let (halfWindow, remainder) = windowLength.quotientAndRemainder(dividingBy: 2) var pos = Double(halfWindow) if remainder == 0 { pos -= 0.5 } let X = [Double](stride(from: Double(windowLength) - pos - 1, through: -pos, by: -1)) let P = [Double](stride(from: 0, through: Double(polynomialOrder), by: 1)) let A = P.map { exponent in X.map { pow($0, exponent) } } var B = [Double](repeating: 0, count: polynomialOrder + 1) B[derivativeOrder] = Double(factorial(derivativeOrder)) / pow(Double(delta), Double(derivativeOrder)) return leastSquaresSolution(A: A, B: B) } static func leastSquaresSolution(A: [[Double]], B: [Double]) -> [Double] { let sparseA = A.sparseMatrix() var sparseAValuesCopy = sparseA.values var xValues = [Double](repeating: 0, count: A.transpose().count) var bValues = B sparseAValuesCopy.withUnsafeMutableBufferPointer { valuesPtr in let a = SparseMatrix_Double( structure: sparseA.structure, data: valuesPtr.baseAddress! ) bValues.withUnsafeMutableBufferPointer { bPtr in xValues.withUnsafeMutableBufferPointer { xPtr in let b = DenseVector_Double( count: Int32(B.count), data: bPtr.baseAddress! ) let x = DenseVector_Double( count: Int32(A.transpose().count), data: xPtr.baseAddress! ) #warning("EXC_BAD_ACCESS is thrown below") print("This code is executed...") let status = SparseSolve(SparseLSMR(), a, b, x, SparsePreconditionerDiagScaling) print("...but, if an EXC_BAD_ACCESS is thrown, this code isn't") if status != SparseIterativeConverged { fatalError("Failed to converge. Returned with error \(status).") } } } } return xValues } } func factorial(_ n: Int) -> Int { n < 2 ? 1 : n * factorial(n - 1) } extension Array where Element == [Double] { func sparseMatrix() -> (structure: SparseMatrixStructure, values: [Double]) { let columns = self.transpose() var rowIndices: [Int32] = columns.map { column in column.indices.compactMap { indexInColumn in if column[indexInColumn] != 0 { return Int32(indexInColumn) } return nil } }.reduce([], +) let sparseColumns = columns.map { column in column.compactMap { if $0 != 0 { return $0 } return nil } } var counter = 0 var columnStarts = [Int]() for sparseColumn in sparseColumns { columnStarts.append(counter) counter += sparseColumn.count } let reducedSparseColumns = sparseColumns.reduce([], +) columnStarts.append(reducedSparseColumns.count) let structure: SparseMatrixStructure = rowIndices.withUnsafeMutableBufferPointer { rowIndicesPtr in columnStarts.withUnsafeMutableBufferPointer { columnStartsPtr in let attributes = SparseAttributes_t() return SparseMatrixStructure( rowCount: Int32(self.count), columnCount: Int32(columns.count), columnStarts: columnStartsPtr.baseAddress!, rowIndices: rowIndicesPtr.baseAddress!, attributes: attributes, blockSize: 1 ) } } return (structure, reducedSparseColumns) } func transpose() -> Self { let columns = self.count let rows = self.reduce(0) { Swift.max($0, $1.count) } return (0 ..< rows).reduce(into: []) { result, row in result.append((0 ..< columns).reduce(into: []) { result, column in result.append(row < self[column].count ? self[column][row] : 0) }) } } }
11
0
922
Jul ’24
Issue running app when SIP disabled.
I've been developing an MacOS app for a while and everything was going smoothly until one of the testers reported that the app was crashing on launch. After investigation, we discovered that he had System Integrity Protection disabled. I could reproduce the error by disabling SIP: Library not loaded: @rpath/myframework.framework/myframework Referenced from: <4C129258-1BF8-3D30-9AFE-BF4206D0A767> /Applications/MyApp.app/Contents/MacOS/MyApp Reason: , (security policy does not allow @ path expansion) (terminated at launch; ignore backtrace) The app launches normally if I reenable SIP. I can't find information about "security policy does not allow @ path expansion". I'll appreciate if someone can point me in the right direction.
2
0
665
Jun ’24
Suppressing "Known Hang" warnings with PERFC_SUPPRESSION_FILE
Recently we have started refactoring some code to use Swift concurrency in Xcode 15.3. As we have added some new async methods and Tasks, new runtime warnings have emerged titled "Known Hang" and several are listed. None of the stack traces listed with these warnings are in areas directly modified but some of the same types/methods called are also called from the modified areas. So I can sort of understand why they are coming up...but they had to have been there before we added the Swift concurrency. Example of a tooltip with the warnings: My first query is: Are these warnings only issued when Swift concurrency is added/applied (as they were not there when using closures and mostly just off the main thread to network calls)? The documentation indicates these can all be suppressed by turning off the Thread Performance Checker BUT I would rather just suppress the few places as we refactor our codebase (as it is quite large). In that way, any new ones may be documented and we can decide to fix them now or later. I have tried to follow the instructions and added an environment variable PERFC_SUPPRESSION_FILE (in the Scheme) with a full path to a file formatted similarly to the example in the documentation. class:NSManagedObjectContext method:-[NSManagedObjectContext save:] My second query is: I have verified that the variable is set by reading it from the ProcessInfo. However, regardless of my settings, the runtime warnings are still presented. I could not find any examples or even any mention of others using this environment variable. I am reaching out with any advice or ideas to try. Has anyone successfully tried this or found an issue/alternative? Help me Mr. Wizard!
3
0
782
May ’24
Memory corruption crash
Hello! We are experiencing crashes on iOS both in debug and release builds in a game made in Godot 3.5.1. The main problem is that we don’t know where exactly the problem is and cannot understand how could we find a way to fix it. We don't expect that someone here will know how to fix this on Godot's side, but we would appreciate some help on how to get more info about the problem and potentially fix it. Debug builds: It is way more frequent in debug builds when we make a build, open it in Xcode, and install it directly on an iOS device. The first type of the crash in debug build is occurring like 70% of the time when the game is loading and trying to get into its main menu. The thing we are getting in Xcode looks like on first image below. Another type of crash happens when we open some save files and start the actual playable part of the game. It happens just after moving the character a few steps and it looks like on second image below. We are aware that the log recommends using breakpoints to find where exactly the problem is, but the thing is that we don’t know where we could do that in Xcode. We are not sure if we are missing something in Xcode or if we cannot do that when opening a project made in Godot. We tried many different builds with removed shader files, and scenes and changed different kinds of settings. We would get the same crash every time. When we made a new build, we cleared the build’s folder. Also, we occasionally deleted the .import folder of the project during development and reimported it. The problem occurred on many different iOS devices with more than 4GB of RAM. Release builds: These builds are uploaded on TestFlight. In release builds crashes wouldn’t occur like in debug builds. They would happen like totally randomly. In some testing sessions, it would happen like 10 minutes in the game, and in others in a few hours. Some testers couldn’t get the crash and altogether and we couldn’t find some repro steps to produce these crashes. In the attached files, you can find logs that we managed to collect from TestFlight. The most frequent type of the crash that we got, is following: Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS Additional info: From reading Apple’s documentation Investigating memory access crashes, we got it that the problem is in “Invalid memory fetch”, but we couldn’t find how this could help us with further investigation. When we used Address Sanitizer tool and made a build, suddently the game stopped crashing in debug builds like it did before. Also we then didn't receive logs in Xcode that would hint us that something is going on. Tried to build our project in newer version of Godot, but the problem still persisted. Used software and hardware: Godot 3.5.1 macOS, Ventura, 13.5 Xcode, 15.2 iPad Air (5th generation), 17.4.1 MacBook Pro, Apple M1 If you have some clues or ideas on how to fix this problem, please write it, it would mean us a lot. Don’t hesitate to ask questions if something is unclear. Thank you very much in advance!
2
0
1k
May ’24
xcode build error: Could not find path to clang binary to locate Address Sanitizer library
When I have the Address Sanitizer option turned off in Xcode(version 15.3), the project builds successfully. However, as soon as I enable the option, the build fails with the error message: 'Could not find path to clang binary to locate Address Sanitizer library.' I found libclang_rt.asan_ios_dynamic.dylib in the Xcode directory and added it to the build Phases -> Link Library with Libraries. However, I still get the same error. But when I create a new project and enable the Address Sanitizer option, it builds successfully.
1
0
653
Apr ’24
Callstack of a std::exception does not include the location of the throw
We have an C++ app which runs on multiple platforms and is build using the Qt framework. For a while we had issues with unexplainable stack traces reported by testflight users. Now I found out that if I just put throw std::runtime_error("something"); at the start of my main method the resulting crash call stack would not point to my main method. Is there something I can do (compiler flags/variables/code etc) to have the call stack from the actual throw show up in XCode and testflight?
3
0
545
Apr ’24
Lag on a complicated SwiftUI view on devices different than iPhone 13 mini
The problem, that I am currently facing is related to an electronic program guide screen. I will add a simplified example of what my initial implementation was. ScrollViewReader { ScrollView(axis: [.horizontal, .vertical]) { LazyVStack(pinnedViews: .sectionHeaders) { Section(header: TimelineView()) { ForEach(channels) { channel in LazyHStack(pinnedViews: .sectionHeaders) { Section(header: ChannelLogoView()) { ForEach(channel.programs) { program in ProgramCell(program) } } } } } } } The actual implementation included a lot more modifiers and code, but I never got it to work and gave up because most of the problems happening were so weird that there was no code explaining what is going on. Examples are cells appearing out of the view bounds or just disappearing when you scroll around. I thought those are happening because of the nested Lazy stack both with pinned views and I gave up on that approach. So next I decided to use PreferenceKey for updating the scroll position and offset both the views that need to be pinned based on that. The code looks something like that: GeometryReader { geoProxy in ScrollViewReader { scrollProxy in ScrollView([.vertical, .horizontal], showsIndicators: false) { ProgramGuideView() .background( GeometryReader { geometry in theme.primaryColor.preference( key: ScrollOffsetPreferenceKey.self, value: geometry.frame(in: .named(X)).origin ) } ) .onPreferenceChange(ScrollOffsetPreferenceKey.self) { point in self.position = point //Position is a @State held in the view } } } } On top of the grometry reader I have 2 overlays with offsets for the Channel headers and timeline view. In the program guide view I removed the Lazy stacks and used the normal ones and what was very crucial for this whole combination not to lag was using the drawingGroup() modifier. And it worked like a charm when testing on my iPhone 13 mini, but on all other devices that I have tested (14 Pro Max, 14 Pro, 13, Xs) it lags. The only difference that I am seeing is that on those phones when ran from Xcode an error gets logged - Bound preference key tried updating multiple times per frame. So my questions here are: What is the difference between the iPhone 13 mini and the rest of the deices, for this error to occur, and is there a way to overcome it? Do you have any suggestions on implementing a view like that using SwiftUI, or just improvement/optimisation ideas on the approaches described above? I am sorry if I have made any mistakes writing and copy-pasting the code in the snippets above. Also that I am not including the source code directly but I can definitely add more specifics if someone has interest in the problem. Thanks!
0
0
629
Mar ’24
Branch coverage data with UBSAN enable (UndefinedBehaviorSanitizer) in Xcode
Hi, On enabling UBSAN(UndefinedBehaviorSanitizer) on Xcode a dip in branch coverage is observed. Is this behaviour expected? If the answer is yes, is there a way to enable UBSAN without affecting branch coverage data? Below is the reference of same code base, branch coverage data with enable and disable UBSAN Xcode version: 14.3.1 With UBSAN enable: Total branches: 250733 No of branches hit: 47945 With UBSAN disable: Total branches: 38673 No of branches hit: 11220
0
0
490
Mar ’24