realm-swift icon indicating copy to clipboard operation
realm-swift copied to clipboard

Xcode 14.3 (clang 14.0.3) crash on alloc_slab.cpp

Open dabaicaifen opened this issue 1 year ago • 11 comments

How frequently does the bug occur?

Always

Description

I recently upgraded to Xcode 14.3 and our application always failed at Xcode analyze task.

I can reproduce the issue with a fresh new project, just add Realm references, and run Analyze from Xcode.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

Run Analyze from Xcode.

Version

10.38.3

What Atlas Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

16.4

Build environment

Xcode version: 14.3 Dependency manager and version: 10.38.3

dabaicaifen avatar May 11 '23 14:05 dabaicaifen

Hi @dabaicaifen I was able to reproduce your issue on my local and it seems like your finding are correct. I'm generating a report with the issues which may be causing this to happen, and try to solve them.

dianaafanador3 avatar May 24 '23 10:05 dianaafanador3

I've occasionally run the clang static analyzer on our code and it's generally just been a mix of false positives and irrelevant things, so we've never set it as a goal to get zero warnings from it. It looks like there's currently a few very minor correct things and a bunch of incorrect things.

tgoyne avatar May 25 '23 15:05 tgoyne

Any update?

dabaicaifen avatar Jun 09 '23 14:06 dabaicaifen

@dabaicaifen There are a couple of PR (https://github.com/realm/realm-swift/pull/8249 and https://github.com/realm/realm-core/pull/6675) which solve some of the warnings

dianaafanador3 avatar Jun 12 '23 11:06 dianaafanador3

While there are a handful of static analyzer warnings, they are very unlikely to be related to a crash in alloc_slab and we will need details about the actual problem you are hitting to be able to do anything.

tgoyne avatar Jul 25 '23 15:07 tgoyne

While there are a handful of static analyzer warnings, they are very unlikely to be related to a crash in alloc_slab and we will need details about the actual problem you are hitting to be able to do anything.

I can easily reproduce the crash with a fresh new project, have you tried it? @tgoyne

dabaicaifen avatar Jul 26 '23 14:07 dabaicaifen

@dabaicaifen Could you send us a sample app that reproduces this issue?

leemaguire avatar Jul 26 '23 14:07 leemaguire

We do indeed have tests and they don't crash.

tgoyne avatar Jul 26 '23 16:07 tgoyne

We do indeed have tests and they don't crash.

@tgoyne please use this demo https://github.com/dabaicaifen/RealmDemo/tree/analyze-crash, the branch is analyze-crash. And use Xcode 14.3 or 14.3.1.

dabaicaifen avatar Jul 26 '23 19:07 dabaicaifen

I can confirm that this issue exists and continues to be a thorn when using Realm. The warnings are not the problem, but rather a segmentation fault on alloc_slab.cpp.

Here's a stack trace of the issue on my local machine:

Analyze /Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/SourcePackages/checkouts/realm-core/src/realm/alloc_slab.cpp normal arm64 (in target 'RealmCore' from project 'RealmDatabase')
    cd /Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/SourcePackages/checkouts/realm-core
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /Users/daniel/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache -target arm64-apple-ios11.0-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=c++17 -fmodules -gmodules -fmodules-cache-path\=/Users/daniel/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/daniel/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -fmodule-name\=RealmCore -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -DSWIFT_PACKAGE -DDEBUG\=1 -DREALM_DEBUG -DREALM_NO_CONFIG -DREALM_INSTALL_LIBEXECDIR\= -DREALM_ENABLE_ASSERTIONS\=1 -DREALM_ENABLE_ENCRYPTION\=1 -DREALM_ENABLE_SYNC\=1 -DREALM_ENABLE_GEOSPATIAL\=0 -DREALM_VERSION_MAJOR\=13 -DREALM_VERSION_MINOR\=17 -DREALM_VERSION_PATCH\=1 -DREALM_VERSION_EXTRA\=\"\" -DREALM_VERSION_STRING\=\"13.17.1\" -DREALM_HAVE_SECURE_TRANSPORT\=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -fvisibility-inlines-hidden -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -D__clang_analyzer__ -Xclang -analyzer-output\=plist-multi-file -Xclang -analyzer-config -Xclang report-in-main-source-file\=true -Xclang -analyzer-config -Xclang nullability:NoDiagnoseCallsToSystemHeaders\=true -Xclang -analyzer-checker -Xclang security.insecureAPI.UncheckedReturn -Xclang -analyzer-checker -Xclang security.insecureAPI.getpw -Xclang -analyzer-checker -Xclang security.insecureAPI.gets -Xclang -analyzer-checker -Xclang security.insecureAPI.mkstemp -Xclang -analyzer-checker -Xclang security.insecureAPI.mktemp -Xclang -analyzer-disable-checker -Xclang security.insecureAPI.rand -Xclang -analyzer-disable-checker -Xclang security.insecureAPI.strcpy -Xclang -analyzer-checker -Xclang security.insecureAPI.vfork -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/SourcePackages/checkouts/realm-core/src/external/IntelRDFPMathLib20U2/LIBRARY/src -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Products/Debug-iphonesimulator/include -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/SourcePackages/checkouts/realm-core/src -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/SourcePackages/checkouts/realm-core/src/external -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/SourcePackages/checkouts/realm-core/src -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Intermediates.noindex/RealmDatabase.build/Debug-iphonesimulator/RealmCore.build/DerivedSources-normal/arm64 -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Intermediates.noindex/RealmDatabase.build/Debug-iphonesimulator/RealmCore.build/DerivedSources/arm64 -I/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Intermediates.noindex/RealmDatabase.build/Debug-iphonesimulator/RealmCore.build/DerivedSources -F/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Products/Debug-iphonesimulator/PackageFrameworks -F/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk/Developer/Library/Frameworks -fmodule-map-file\=/Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Intermediates.noindex/GeneratedModuleMaps-iphonesimulator/Bid.modulemap -DXcode -MMD -MT dependencies -MF /Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Intermediates.noindex/RealmDatabase.build/Debug-iphonesimulator/RealmCore.build/StaticAnalyzer/RealmDatabase/RealmCore/normal/arm64/alloc_slab.d --analyze /Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/SourcePackages/checkouts/realm-core/src/realm/alloc_slab.cpp -o /Users/daniel/Library/Developer/Xcode/DerivedData/Dedupe-agmuulpzqfztnhhawthmaxautyvs/Build/Intermediates.noindex/RealmDatabase.build/Debug-iphonesimulator/RealmCore.build/StaticAnalyzer/RealmDatabase/RealmCore/normal/arm64/alloc_slab.plist

clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-ios11.0-simulator
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/2m/3v9gxmxn5pjdpnd1tljpdffh0000gq/T/alloc_slab-ba8761.cpp
clang: note: diagnostic msg: /var/folders/2m/3v9gxmxn5pjdpnd1tljpdffh0000gq/T/alloc_slab-ba8761.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/daniel/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

********************
Command Analyze failed with a nonzero exit code

laud avatar Aug 02 '23 18:08 laud

Are there any solutions I can apply now?

woin2ee avatar Sep 14 '23 12:09 woin2ee