Skip to content

Compilation Error in Sentry React Native 6.10.0: Custom Allocator std::allocator_traits Issue #4715

Closed
@archan0621

Description

@archan0621

Important

Note from the maintainers: This issue affects many libraries, not just Sentry. It is caused by Xcode 16.3 removing a non-standard C++ feature. Read on for details. Note that if all else fails, using Xcode 16.2 should still work.

  • We shipped a fix for this in @sentry/react-native 6.10.0.
    • If you use sentry-dart, upgrade to 8.14.0+. sentry-cocoa includes the fix in release 8.46.0+.
    • If you use one of the fixed versions and still encounter the issue, it is very likely that you use another affected library (read on for more info on popular affected libraries).
    • If you update all your known affected dependencies to fixed versions, and still encounter the problem, make sure you perform clean builds (delete all build artefacts, including derived data). If that doesn't help, try removing them one by one and take it from there.
  • React Native versions 0.76.8 and lower are affected - you should upgrade to 0.76.9+ to fix this issue. They will not release fixes for versions before 0.76. You can read up on the details in their GH issue
  • Expo is also affected, they set up a separate info page about packages and fix versions: https://expo.dev/changelog/xcode-16-3-patches

Even though it is fixed on our side, we'll keep this issue open for a little while longer for easier discovery (ppl often don't search closed issues).


What React Native libraries do you use?

React Native without Frameworks

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.10.0

How does your development environment look like?

After upgrading from iOS sdk version 18.4, our iOS project fails to compile. The error appears to be related to a custom allocator (ThreadMetadataInnerHashMapAllocator) used within Sentry’s profiling code. Specifically, the compiler reports that the custom allocator does not meet the requirements of std::allocator_traits. For example, error messages include references to “rebinding an allocator to the same type should result in using the same object” and “No type named ‘value_type’”, which suggest that the allocator’s definitions (possibly regarding const qualifiers and required member types) are not in line with standard expectations.

Sentry.init()

Sentry.init({
  dsn: '',
  tracesSampleRate: 1.0,
  integrations: [new HttpClient()],
  beforeSend(event) {
    event.tags = {...event.tags, version: version};
    return event;
  },
  sendDefaultPii: true,
});

Steps to Reproduce

  1. Upgrade iOS SDK to 18.4
  2. Clean the iOS project by deleting Podfile.lock, the Pods/ directory, and Xcode’s DerivedData.
  3. Run pod install --repo-update in the iOS directory.
  4. Attempt to build the project in Xcode.

Expected Result

Build Success

Actual Result

Build failed with error

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.4.sdk/usr/include/c++/v1/__memory/allocator_traits.h:378:17 Static assertion failed due to requirement 'is_same<std::allocator<const sentry::profiling::ThreadMetadataCache::ThreadHandleMetadataPair>, std::allocator<int>>::value': [allocator.requirements] states that rebinding an allocator to the same type should result in the original allocator


/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.4.sdk/usr/include/c++/v1/__memory/allocator.h:95:17 Static assertion failed due to requirement '!is_const<const sentry::profiling::ThreadMetadataCache::ThreadHandleMetadataPair>::value': std::allocator does not support const types


/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.4.sdk/usr/include/c++/v1/__type_traits/enable_if.h:28:58 No type named 'type' in 'std::enable_if<false, int>'; 'enable_if' cannot be used to disable this declaration


/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.4.sdk/usr/include/c++/v1/vector:427:50 No type named 'value_type' in 'std::allocator<const sentry::profiling::ThreadMetadataCache::ThreadHandleMetadataPair>'

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions