Crash stack isn't symbolicated correctly

I create a simple project to demonstrate C++ code crash symbolication.


The C++ code is crash.cpp:



#include "crash.h"

#include 

int* newPtr() {
  return new int[1];
}

void resetPtr(int** ptr) {
  *ptr = nullptr;
}

void usePtr(int* ptr) {
  int var = *ptr;
  var++;
  *ptr = var;
}

void testCrash() {
  int* ptr = newPtr();
  usePtr(ptr);
  resetPtr(&ptr);
  usePtr(ptr);
  resetPtr(nullptr);
  usePtr(ptr);
}



The Objective-C code calling it is ViewController.mm:



#import "ViewController.h"

#import "crash.h"

@interface ViewController ()

@end

@implementation ViewController {
    int _val;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // this could be symbolicated correctly
    //ViewController* vc = nil;
    //NSLog(@"%d", vc->_val);

    // this couldn't be symbolicated correctly
    testCrash();
    NSLog(@"test");
}

@end


The line number above is the same as source code.



It should crash at ViewController.mm:22 => crash.cpp:23 => crash.cpp:14, and that's exactly what I see in Xcode when I run the app in Xcode.


But when I disconnect with Xcode, and launch the app from home screen, then get the crash log using Xcode menu Window - Devices and Simulators - View Device Logs, but the symbolicated crash is:



Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   CrashExample                  0x000000010493230c usePtr(int*) + 25356 (crash.cpp:13)
1   CrashExample                  0x000000010493234c testCrash() + 25420 (crash.cpp:24)
2   CrashExample                  0x0000000104932480 -[ViewController viewDidLoad] + 25728 (ViewController.mm:23)
3   UIKitCore                      0x000000018ea0a36c -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104



All 3 frames are wrong!


I'm using Xcode 11.4.1 (11E503a), macOS 10.15.4 (19E287), iPhone 11 iOS 13.4.1.


Here is my test project: https://imgs.piasy.com/2020-05-16-CrashExample.zip


Please help me, thanks!

Accepted Reply

Any help? Please!

I don’t have a quick answer for you, alas. My advice is that you open a DTS tech support incident so that you can discuss this with our Tools Guy™.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

Any help? Please!

Any help? Please!

I don’t have a quick answer for you, alas. My advice is that you open a DTS tech support incident so that you can discuss this with our Tools Guy™.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Hi eskimo, thank you for the lead, I get more information from DTS engineer.