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).

Xcode Runtime Issues Documentation

Posts under Xcode Sanitizers and Runtime Issues tag

29 Posts
Sort by:
Post not yet marked as solved
2 Replies
83 Views
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!
Posted
by fury_ivan.
Last updated
.
Post not yet marked as solved
9 Replies
6.6k Views
I'm unable to run my app with ASAN enabled when targeting a physical iOS device. Simulator targets do work. With Xcode 12 and an iPad mini 4 running iOS 14 beta 1 I get the following error during app launch ==750==ERROR: AddressSanitizer failed to allocate 0xffffffffff9fc000 (-6307840) bytes at address 2db624000 (errno: 22) ==750==ReserveShadowMemoryRange failed while trying to map 0xffffffffff9fc000 bytes. Perhaps you're using ulimit -v With Xcode 11.5 and an iPad Air 2 running OS 12.4.1 the error is ==2177==Unable to find a memory range after restricting VM. ==2177==AddressSanitizer CHECK failed: /BuildRoot/Library/Caches/com.apple.xbs/Sources/clangcompilerrt/clang-1103.0.32.62/compiler-rt/lib/asan/asanmac.cc:92 "((0 && "cannot place shadow after restricting vm")) != (0)" (0x0, 0x0) <empty stack>==2177==AddressSanitizer CHECK failed: /BuildRoot/Library/Caches/com.apple.xbs/Sources/clangcompilerrt/clang-1103.0.32.62/compiler-rt/lib/asan/../sanitizercommon/sanitizermallocmac.inc:143 "((!asaninitisrunning)) != (0)" (0x0, 0x0) warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available. AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report. (lldb) thread info -s thread #1: tid = 0x1076c2, 0x000000011531e984 libclangrt.asaniosdynamic.dylib`__asan::AsanDie() My coworker is able to use ASAN with the same App using iPad Pro 10.5, iPadOS 13.5.1, Xcode 11.5 Are there any configuration changes I need to make to be able to use ASAN on my devices?
Posted
by smpeleato.
Last updated
.
Post not yet marked as solved
1 Replies
114 Views
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.
Posted
by chengqian.
Last updated
.
Post not yet marked as solved
3 Replies
133 Views
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?
Posted
by r64.
Last updated
.
Post not yet marked as solved
4 Replies
750 Views
Crash condition: when I update the Xcode version to 15.3 and run the iPhone to load the app on debug mode with the following diagnosing setting: Hardware Model: iPhone 14 pro Role: Foreground Date/Time: 2024-03-08 11:30 -0800 Launch Time: 2024-03-08 11:30 -0800 OS Version: iPhone OS 17.4(21E219) Exception Type: EXC_BREAKPOINT Exception Codes: (code=1, subcode=0x19b1eba48) Exception Note: EXC_BREAKPOINT Triggered by Thread: 1 Thread 1 Queue : com.apple.main-thread (serial) #0 0x000000019b1eba48 in xzm_malloc_zone_free_slow.cold.1 () #1 0x000000019b1e28d0 in xzm_malloc_zone_free_slow () #2 0x00000001a25ef1c8 in pas_try_deallocate_slow_no_cache () #3 0x00000001a10d32f8 in ***::String::String(__CFString const*) () #4 0x00000001a0494ab8 in WebKit::isFullWebBrowserOrRunningTest() () #5 0x00000001a09e1520 in WebKit::WebsiteDataStoreConfiguration::WebsiteDataStoreConfiguration(WebKit::IsPersistent, WebKit::WebsiteDataStoreConfiguration::ShouldInitializePaths) () #6 0x00000001a09d3ae0 in WebKit::WebsiteDataStore::defaultDataStore() () #7 0x00000001a05bc5e8 in +[WKWebsiteDataStore defaultDataStore] () #8 0x00000001a05b6624 in -[WKWebViewConfiguration websiteDataStore] () #9 0x00000001a0576850 in -[WKWebView _initializeWithConfiguration:] () #10 0x00000001a0577e04 in -[WKWebView initWithFrame:configuration:] () #11 0x0000000104cbf724 in -[AAChartView initConfigurationWithFrame:] at /Users/quinn/Documents/objcio/AAChartKit-master/AAChartKitLib/AAChartCreator/AAChartView.m:133 #12 0x0000000104cbf4e8 in -[AAChartView initWithFrame:] at /Users/quinn/Documents/objcio/AAChartKit-master/AAChartKitLib/AAChartCreator/AAChartView.m:115 #13 0x0000000104c133a4 in -[BasicChartVC setupAAChartView] at /Users/quinn/Documents/objcio/AAChartKit-master/AAChartKitDemo/ChartsDemo/BasicChartVC.m:99 #14 0x0000000104c13208 in -[BasicChartVC drawChart] at /Users/quinn/Documents/objcio/AAChartKit-master/AAChartKitDemo/ChartsDemo/BasicChartVC.m:86 #15 0x0000000104c12f9c in -[BasicChartVC viewDidLoad] at /Users/quinn/Documents/objcio/AAChartKit-master/AAChartKitDemo/ChartsDemo/BasicChartVC.m:66 #16 0x000000018d4e530c in -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] () #17 0x000000018d29bfb4 in -[UIViewController loadViewIfRequired] () #18 0x000000018d29a7a8 in -[UIViewController view] () #19 0x000000018d98a384 in -[UINavigationController _startCustomTransition:] () #20 0x000000018d39dca4 in -[UINavigationController _startDeferredTransitionIfNeeded:] () #21 0x000000018d39d3a0 in -[UINavigationController __viewWillLayoutSubviews] () #22 0x000000018d39d304 in -[UILayoutContainerView layoutSubviews] () #23 0x000000018d2b90f8 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] () #24 0x000000018c6e3e30 in CA::Layer::layout_if_needed(CA::Transaction*) () #25 0x000000018c6e39b4 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) () #26 0x000000018c6e9bb4 in CA::Context::commit_transaction(CA::Transaction*, double, double*) () #27 0x000000018c6e31bc in CA::Transaction::commit() () #28 0x000000018d331280 in _UIApplicationFlushCATransaction () #29 0x000000018d330d78 in _UIUpdateSequenceRun () #30 0x000000018d330468 in schedulerStepScheduledMainSection () #31 0x000000018d330524 in runloopSourceCallback () #32 0x000000018b04162c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ () #33 0x000000018b0408a8 in __CFRunLoopDoSource0 () #34 0x000000018b03f058 in __CFRunLoopDoSources0 () #35 0x000000018b03dd88 in __CFRunLoopRun () #36 0x000000018b03d968 in CFRunLoopRunSpecific () #37 0x00000001cf33b4e0 in GSEventRunModal () #38 0x000000018d4b0edc in -[UIApplication _run] () #39 0x000000018d4b0518 in UIApplicationMain () #40 0x0000000104d42ba8 in main at /Users/quinn/Documents/objcio/AAChartKit-master/AAChartKitDemo/main.m:38 #41 0x00000001ae55ed84 in start ()
Posted Last updated
.
Post not yet marked as solved
0 Replies
228 Views
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!
Posted Last updated
.
Post not yet marked as solved
0 Replies
168 Views
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
Posted Last updated
.
Post not yet marked as solved
0 Replies
157 Views
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
Posted Last updated
.
Post not yet marked as solved
2 Replies
339 Views
I can't figure out why this line of code complains that it's sometimes not being called from the main thread. Shouldn't the fact that this function has the @MainActor attribute on it result in the function being added to the main queue therefore processed on the main thread? Am I'm just naive to how the @MainActor attribute actually works?
Posted Last updated
.
Post not yet marked as solved
2 Replies
574 Views
Hello everyone, good day. For months now, I have been trying to get the iOS 17 simulator on my MacBook Pro. Unfortunately, it failed during the installation process. When it reached 100%, it showed 'installing,' but, regrettably, it failed and displayed the following error: (-67061 invalid signature (code or signature have been modified) Domain: SimDiskImageErrorDomain Code: 5 User Info: { DVTErrorCreationDateKey = "2024-02-02 13:57:23 +0000"; unusableErrorDetail = ""; } Has anyone ever come across this error? I would appreciate it if anyone could shed light on what it means and provide guidance on how to bypass it before attempting the installation again.
Posted Last updated
.
Post not yet marked as solved
1 Replies
448 Views
Hello everyone, good day. For months now, I have been trying to get the iOS 17 simulator on my MacBook Pro. Unfortunately, it failed during the installation process. When it reached 100%, it showed 'installing,' but, regrettably, it failed and displayed the following error: (-67061 invalid signature (code or signature have been modified) Domain: SimDiskImageErrorDomain Code: 5 User Info: { DVTErrorCreationDateKey = "2024-02-02 13:57:23 +0000"; unusableErrorDetail = ""; } Has anyone ever come across this error? I would appreciate it if anyone could shed light on what it means and provide guidance on how to bypass it before attempting the installation again.
Posted Last updated
.
Post marked as solved
2 Replies
614 Views
I was making the cancel button of the memo screen in my iOS memo application. But, when I clicked the cancel button, Thread 1: EXC_BREAKPOINT (code=1, subcode=0x18855e560) error appeared. I used dismiss(animate: true, completion: nil) code ComposeViewController Code import UIKit class ComposeViewController: UIViewController { @IBAction func close(_ sender: Any) { dismiss(animated: true, completion: nil). //this code was problem } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } //something more that is comment code '//' }
Posted Last updated
.
Post not yet marked as solved
8 Replies
734 Views
I'm having a hard time relying on TSAN to detect problems due to its rightful insistence on reporting data-races (I know, stick with me). Picture the following implementation of a lazily-allocated property in an Obj-C class: @interface MyClass { id _myLazyValue; // starts as nil as all other Obj-C ivars } @end @implementation MyClass - (id)myLazyValue { if (_myLazyValue == nil) { @synchronized(self) { if (_myLazyValue == nil) { _myLazyValue = <expensive computation> } } } return _myLazyValue; } @end The first line in the method is reading a pointer-sized chunk of memory outside of the protection provided by the @synchronized(...) statement. That same value may be written by a different thread within the execution of the @synchronized block. This is what TSAN complains about, but I need it not to. The code above ensures the ivar is written by at most one thread. The read is unguarded, but it is impossible for any thread to read a non-nil value back that is invalid, uninitialized or unretained. Why go through this trouble? Such a lazily-allocated property usually locks on @synchronized once, until (at most) one thread does any work. Other threads may be temporarily waiting on the same lock but again only while the value is being initialized. The cost of allocation and initialization is guaranteed to be paid once: multiple threads cannot initialize the value multiple times (that’s the reason for the second _myLazyValue == nil check within the scope of the @synchronized block). Subsequent accesses of the initialized property skip locking altogether, which is exactly the performance we want from a lazily-allocated, immutable property that still guarantees thread-safe access. Assuming there isn't a big embarrassing hole in my logic, is there a way to decorate specific portions of our sources (akin to #pragma statements that disable certain warnings) so that you can mark any read/write access to a specific value as "safe"? Is the most granular tool for this purpose the __attribute__((no_sanitize("thread")))? Ideally one would want to ask TSAN to ignore only specific read/writes, rather than the entire body of a function. Thank you!
Posted
by FxFactory.
Last updated
.
Post not yet marked as solved
3 Replies
4k Views
I am working on a library, a Swift package. We have quite a few properties on various classes that can change and we think the @Published property wrapper is a good way to annotate these properties as it offers a built-in way to work with SwiftUI and also Combine. Many of our properties can change on background threads and we've noticed that we get a purple runtime issue when setting the value from a background thread. This is a bit problematic for us because the state did change on a background thread and we need to update it at that time. If we dispatch it to the main queue and update it on the next iteration, then our property state doesn't match what the user expects. Say they "load" or "start" something asynchronously, and that finishes, the status should report "loaded" or "started", but that's not the case if we dispatch it to the main queue because that property doesn't update until the next iteration of the run loop. There also isn't any information in the documentation for @Published that suggests that you must update it on the main thread. I understand why SwiftUI wants it on the main thread, but this property wrapper is in the Combine framework. Also it seems like SwiftUI internally could ask to receive the published updates on the main queue and @Published shouldn't enforce a specific thread. One thing we are thinking about doing is writing our own property wrapper, but that doesn't seem to be ideal for SwiftUI integration and it's one more property wrapper that users of our package would need to be educated about. Any thoughts on direction? Is there anyway to break @Published from the main thread?
Posted
by rolson.
Last updated
.
Post not yet marked as solved
0 Replies
438 Views
Hello, I'm trying to build XNU with KASAN support. However I get error: clang: error: unsupported option '-fsanitize=kernel-hwaddress' for target 'arm64e-apple-darwin23.2.0' If I try to compile a non-kernel C code with -fsanitize=hwaddress, I get the same target error. But Apple ships HWASan kernels with KDK, which shows there is a clang which is capable of compiling hwasan code for arm64e. How can we compile hwasan sanitized code ourselves? Is it a private toolchain or released somewhere?
Posted Last updated
.
Post not yet marked as solved
2 Replies
530 Views
I didn't find any errors in my program, and Xcode didn't report any errors in the program code, but when I ran it, it inexplicably reported an error: Command CompileAssetCatalog failed with a nonzero exit code What should I do?
Posted
by lijiaxu.
Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
Hi! I noticed that when I use the simple Textfield in SwiftUI it generates unexpected error: -[RTIInputSystemClient remoteTextInputSessionWithID:performInputOperation:] perform input operation requires a valid sessionID 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. If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable. Here is the code example to repoduce the error: import SwiftUI struct ContentView: View { @State private var firstName = "" var body: some View { TextField("First name", text: $firstName) } } How it could be fixed ? Is it one of the bugs that came along with iOS 17 ? Thank you!
Posted Last updated
.