sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

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

Open archan0621 opened this issue 1 year ago • 38 comments

[!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>'

archan0621 avatar Apr 01 '25 02:04 archan0621

[!IMPORTANT] 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).

kahest avatar Apr 03 '25 08:04 kahest

i've updated our app to "react-native": "~0.77.1" and applied updates recommended here but i still have a compilation error on sentry

Image

I'm using "@sentry/react-native": "~6.10.0"

gdespirito avatar Apr 04 '25 15:04 gdespirito

@gdespirito you need to update to "@sentry/react-native": "~6.10.0", see https://github.com/getsentry/sentry-react-native/issues/4715#issuecomment-2774904579

kahest avatar Apr 04 '25 15:04 kahest

@gdespirito you need to update to "@sentry/react-native": "~6.10.0", see #4715 (comment)

Still facing the issue. am using react native expo.

shameemkpofficial-git avatar Apr 05 '25 09:04 shameemkpofficial-git

This doesnt seem to be fixed on version 6.10 was something missed?

fbritoferreira avatar Apr 05 '25 23:04 fbritoferreira

fixed for mi on 6.10.0

intentodepirata avatar Apr 06 '25 12:04 intentodepirata

@shameemkpofficial-git Please check the SDK 52 patches for Xcode 16.3 and https://github.com/getsentry/sentry-react-native/issues/4715#issuecomment-2774904579 for more details on this issue.

antonis avatar Apr 07 '25 07:04 antonis

This doesnt seem to be fixed on version 6.10 was something missed?

@fbritoferreira please also make sure that you have React Native 0.76.9+. See https://github.com/getsentry/sentry-react-native/issues/4715#issuecomment-2774904579 for more details on this.

antonis avatar Apr 07 '25 07:04 antonis

For me the issue was I downgraded Xcode back to 16.2, but I didn't actually removed or uninstalled 16.3.

Just switching versions in the Xcode setting, made this issue pop up everytime.

I used https://www.xcodes.app/ to actually uninstall xcode version 16.3 and now it works ✌️

bartoosten avatar Apr 07 '25 08:04 bartoosten

"@sentry/react-native": "^6.10.0" works fine now with Xcode 16.3 (16E140) - the only thing is that expo-doctor will complain expecting 6.3.0 but I guess that will be fixed on Expo's side 🤞

@sentry/[email protected] - expected version: ~6.3.0

HishamOmran avatar Apr 07 '25 09:04 HishamOmran

If you don't have the option to upgrade your React Native, Expo, and Sentry version, downgrade to Xcode 16.2. These versions worked for me:

"@sentry/react-native": "^5.31.0",
"expo": "^51.0.5",
"react-native": "0.74.1",
Xcode: 16.2

ghasemikasra39 avatar Apr 07 '25 11:04 ghasemikasra39

"react-native": "0.75.3",

  1. Updated Xcode to 16.3
  2. Issue pop-up
  3. Updated Sentry to "^6.10.0" from "^6.1.0"
  4. Rtc folly issue
  5. Downgraded Xcode to 16.2
  6. Build succeeded
  7. What a mess

PS. 3 weeks after this does not work for me anymore because I can not resolve issue number 4 with downgrading to 16.2 .

bobanminic96 avatar Apr 10 '25 06:04 bobanminic96

Closing this now as it has been fixed on our side for a while. If you encounter this issue, read on for possible reasons and solutions.

[!IMPORTANT] 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

kahest avatar Apr 10 '25 08:04 kahest

For me the issue was I downgraded Xcode back to 16.2, but I didn't actually removed or uninstalled 16.3.

Just switching versions in the Xcode setting, made this issue pop up everytime.

I used https://www.xcodes.app/ to actually uninstall xcode version 16.3 and now it works ✌️

The working solution so far if someone does not want to upgrade or downgrade version. You just need to launch you app from xCodes app download it from link and it launch you desired version from there

ramzanbilal avatar May 06 '25 17:05 ramzanbilal

Still present when upgrading to Xcode 16.4 (iOS 18.5), just upgrade to the latest and reinstall the pods

eikhunter avatar Jun 24 '25 12:06 eikhunter

Getting it now when I upgraded my Mac to 26.

rgautam320 avatar Jun 27 '25 18:06 rgautam320

Also getting this on MacOS/iOS 26 (with latest sentry), did anyone find a solution?

ecoArcGaming avatar Jul 18 '25 15:07 ecoArcGaming

@ecoArcGaming Please check above for the details and solution to this issue. Note that React Native versions 0.76.8 and lower are still affected.

antonis avatar Jul 21 '25 04:07 antonis