Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

AddressSanitizer: attempting free on address which was not malloc()-ed #1007

Open
bfollington opened this issue Nov 30, 2023 · 0 comments
Open
Labels

Comments

@bfollington
Copy link
Collaborator

Originally experienced when debugging and backgrounding the app on iOS. The issue is actually triggered by:

  • Building with XCode 15+
  • Debugging on-device with iOS 17
  • Attempting to free the noosphere pointer
=================================================================
==26864==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x00011a808200 in thread T285
    #0 0x1066a7438 in wrap_free+0x98 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64e+0x53438)
    #1 0x102835874 in rocksdb_close+0x14 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1023e5874)
    #2 0x102805418 in alloc::sync::Arc$LT$T$C$A$GT$::drop_slow::h476aa3e756ee03ab+0x30 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1023b5418)
    #3 0x102368bec in core::ptr::drop_in_place$LT$noosphere_core..api..client..Client$LT$alloc..sync..Arc$LT$alloc..boxed..Box$LT$dyn$u20$ucan..crypto..key..KeyMaterial$GT$$GT$$C$noosphere_storage..db..SphereDb$LT$noosphere_storage..implementation..rocks_db..RocksDbStorage$GT$$GT$$GT$::h405f027e000580f7+0x30 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x101f18bec)
    #4 0x10236f784 in alloc::sync::Arc$LT$T$C$A$GT$::drop_slow::hf686189162cad500+0x14 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x101f1f784)
    #5 0x102366d84 in core::ptr::drop_in_place$LT$noosphere_core..context..context..SphereContext$LT$noosphere_storage..implementation..rocks_db..RocksDbStorage$GT$$GT$::hdfb7e7d2f5ed2ef7 (.llvm.666093863421975433)+0x38 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x101f16d84)
    #6 0x10236f5f0 in alloc::sync::Arc$LT$T$C$A$GT$::drop_slow::h50dc0a03a318e4c3+0x1c (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x101f1f5f0)
    #7 0x10252ebf8 in _$LT$alloc..collections..btree..map..IntoIter$LT$K$C$V$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h9bc0625aaf696f09+0x30 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1020debf8)
    #8 0x10252eae0 in _$LT$alloc..collections..btree..map..BTreeMap$LT$K$C$V$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h6b05e31e6d6c7338+0x24 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1020deae0)
    #9 0x10236f648 in alloc::sync::Arc$LT$T$C$A$GT$::drop_slow::h529b8231b3aff826+0x1c (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x101f1f648)
    #10 0x10252ff6c in noosphere::ffi::noosphere::ns_free::h6b02754419a46515+0x1c (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1020dff6c)
    #11 0x10252ffd8 in ns_free+0x20 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1020dffd8)
    #12 0x1018432a8 in Subconscious.Noosphere.deinit+0x3b8 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1013f32a8)
    #13 0x101843a48 in Subconscious.Noosphere.__deallocating_deinit+0x15c (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1013f3a48)
    #14 0x189b4dd84 in <redacted>+0x34 (/usr/lib/swift/libswiftCore.dylib:arm64e+0x3a6d84)
    #15 0x189b4f420 in <redacted>+0x84 (/usr/lib/swift/libswiftCore.dylib:arm64e+0x3a8420)
    #16 0x100b85554 in Subconscious.Sphere.deinit+0x109c (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x100735554)
    #17 0x100b857a0 in Subconscious.Sphere.__deallocating_deinit+0x15c (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1007357a0)
    #18 0x189b4dd84 in <redacted>+0x34 (/usr/lib/swift/libswiftCore.dylib:arm64e+0x3a6d84)
    #19 0x189b4f420 in <redacted>+0x84 (/usr/lib/swift/libswiftCore.dylib:arm64e+0x3a8420)
    #20 0x101cf8e04 in Subconscious.NoosphereService.reset() -> ()+0xa40 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x1018a8e04)
    #21 0x1019eaf34 in (2) suspend resume partial function for closure #1 () async -> Subconscious.AppAction in static Subconscious.AppModel.resetNoosphereService(state: Subconscious.AppModel, environment: Subconscious.AppEnvironment) -> ObservableStore.Update<Subconscious.AppModel>+0xf0 (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Subconscious:arm64+0x10159af34)
    #22 0x19b442c28 in <redacted>+0x19c (/usr/lib/swift/libswift_Concurrency.dylib:arm64e+0x41c28)

Address 0x00011a808200 is a wild pointer inside of access range of size 0x000000000001.
SUMMARY: AddressSanitizer: bad-free (/private/var/containers/Bundle/Application/DF509556-7C0A-45A5-A614-BAE614F194E3/Subconscious.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64e+0x53438) in wrap_free+0x98
Thread T285 created by T284 here:
    <empty stack>

Thread T284 created by T0 here:
    <empty stack>

==26864==ABORTING

Disabled ASAN avoids the issue. @jsantell suspects that facebook/rocksdb#11598 (comment) may be the root cause.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant