Skip to content
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

Crash when startWithApplicationToken is called #301

Open
laurentaylormarshall opened this issue Aug 27, 2024 · 5 comments
Open

Crash when startWithApplicationToken is called #301

laurentaylormarshall opened this issue Aug 27, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@laurentaylormarshall
Copy link

laurentaylormarshall commented Aug 27, 2024

Description

On app launch, NewRelic.start(withApplicationToken: [token here]) crashes on iOS 15 and iOS 16 for classes that are marked as only available in iOS 17+. This is most likely the same type of issue as reported here: https://forum.newrelic.com/s/hubtopic/aAX8W0000008caqWAA/xcode-13-ios-14-crash

Steps to Reproduce

  • Create a new project where the minimum deployment is iOS 15.
  • Add the NewRelic.start(withApplicationToken: newRelicKey) method to the app delegate
  • Add a file to the project with the following code:
import SwiftData

@available(iOS 17.0, *)
@Model class SomeModel {
  var someProperty: Bool

  init(someProperty: Bool) {
    self.someProperty = someProperty
  }
}

and/or

import Foundation

@available(iOS 17.0, *)
@Observable class SomeObservable {
  var someProperty: Bool

  init(someProperty: Bool) {
    self.someProperty = someProperty
  }
}
  • Run the app

Expected Behavior

The app should not crash due to New Relic.

Relevant Logs / Console output

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region.  Bytes before following region: 4341972992
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   102cd4000-106050000 [ 51.5M] r-x/r-x SM=COW  ...7/--.app/--
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [1919]

Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   ???                           	               0x0 ???
1   libswiftCore.dylib            	       0x1b27918c8 swift::MetadataCacheEntryBase<(anonymous namespace)::SingletonMetadataCacheEntry, int>::doInitialization(swift::MetadataWaitQueue::Worker&, swift::MetadataRequest) + 468
2   libswiftCore.dylib            	       0x1b27802d8 swift_getSingletonMetadata + 880
3   --                           	       0x1052b4e30 type metadata accessor for SomeObservable + 44
4   libobjc.A.dylib               	       0x1b189c2b4 realizeClassMaybeSwiftMaybeRelock(objc_class*, locker_mixin<lockdebug::lock_mixin<objc_lock_base_t> >&, bool) + 184
5   libobjc.A.dylib               	       0x1b187d7b4 look_up_class + 148
6   NewRelic                      	       0x10aa6e3bc NRMA__generateClassTrees + 136
7   NewRelic                      	       0x10aa6e2cc 0x10aa48000 + 156364
8   libdispatch.dylib             	       0x1bfbd8fdc _dispatch_client_callout + 20
9   libdispatch.dylib             	       0x1bfbda828 _dispatch_once_callout + 32
10  NewRelic                      	       0x10aa6e274 0x10aa48000 + 156276
11  NewRelic                      	       0x10aa74a78 0x10aa48000 + 182904
12  NewRelic                      	       0x10aa7474c 0x10aa48000 + 182092
13  NewRelic                      	       0x10aa77b08 0x10aa48000 + 195336
14  libdispatch.dylib             	       0x1bfbd8fdc _dispatch_client_callout + 20
15  libdispatch.dylib             	       0x1bfbda828 _dispatch_once_callout + 32
16  NewRelic                      	       0x10aa77aa4 0x10aa48000 + 195236
17  NewRelic                      	       0x10aa7782c 0x10aa48000 + 194604
18  --                           	       0x10333a4dc specialized AppDelegate.application(_:didFinishLaunchingWithOptions:) + 3200
19  --                           	       0x103330fb0 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 136
20  UIKitCore                     	       0x1baaeac54 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 300
21  UIKitCore                     	       0x1baaea378 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 2848
22  UIKitCore                     	       0x1baae9354 -[UIApplication _runWithMainScene:transitionContext:completion:] + 856
23  UIKitCore                     	       0x1baae8fcc -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 176
24  UIKitCore                     	       0x1bab337f0 -[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 48
25  UIKitCore                     	       0x1bab32848 -[UIApplication _run] + 852
26  UIKitCore                     	       0x1bab324d0 UIApplicationMain + 340
27  --                           	       0x103338b3c main + 68
28  dyld                          	       0x1d6e5e960 start + 2528

Your Environment

Xcode 15.4
iOS 16.4 simulator
New Relic v7.5.1 via SPM

@laurentaylormarshall laurentaylormarshall added the bug Something isn't working label Aug 27, 2024
@cdillard-NewRelic
Copy link
Member

cdillard-NewRelic commented Aug 28, 2024

Hi @laurentaylormarshall . We've asked Apple about this Swift language bug. I will follow up with a possible code workaround you can use to get around Apples Swift language bug.
This is not an issue with the New Relic iOS agent. I've created a ticket in our JIRA system to track Apples progress fixing this and our workarounds.

@cdillard-NewRelic
Copy link
Member

Hi @laurentaylormarshall , I forgot to mention that this is an issue that can be fixed by disabling InteractionTracing as well, if you don't need to use that. We'll look into the code change to workaround this.

See below code , call this before caling NewRelic.start.. This will result in InteractionTracing being disabled and you should not experience the crash.

        NewRelic.disableFeatures([
            NRMAFeatureFlags.NRFeatureFlag_InteractionTracing
        ])

@laurentaylormarshall
Copy link
Author

Thank you @cdillard-NewRelic , that does seem to prevent the crash! However, interaction tracking for iOS 15 and 16 users is still valuable to us, so a long term fix is what we're ultimately looking for.

@laurentaylormarshall
Copy link
Author

@cdillard-NewRelic Have you filed a Feeback Assistant ticket in addition to the forum link that you posted?

@cdillard-NewRelic
Copy link
Member

Hi @laurentaylormarshall , we haven't sent Apple the Feedback Assistant request yet but I'll make a note in our JIRA system to send this up soon. Thanks for the reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants