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

[SR-10254] leak sanitizer doesn't symbolicate stack traces on Linux #52654

Closed
weissi opened this issue Apr 1, 2019 · 4 comments
Closed

[SR-10254] leak sanitizer doesn't symbolicate stack traces on Linux #52654

weissi opened this issue Apr 1, 2019 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@weissi
Copy link
Member

weissi commented Apr 1, 2019

Previous ID SR-10254
Radar rdar://61911130
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 88bd615932b5e6b02507fdd6026caa6a

duplicates:

  • SR-12601 Address Sanitizer's leak output not symbolicated

Issue Description:

The attached project leaks 100 objects when running the tests.

When running on macOS with Swift 5.0, it correctly reports the leak (amongst other noise/leaks in XCTests but that's a different issue) with nice symbolication:

$ ASAN_OPTIONS=detect_leaks=1 jw-swift-5.0 swift test --sanitize=address
[3/3] Linking ./.build/x86_64-apple-macosx/debug/lsantestPackageTests.xctest/Contents/MacOS/lsantestPackageTests
Test Suite 'All tests' started at 2019-04-01 11:39:41.869 am
Test Suite 'lsantestPackageTests.xctest' started at 2019-04-01 11:39:41.870 am
Test Suite 'lsantestTests' started at 2019-04-01 11:39:41.870 am
Test Case '-[lsantestTests.lsantestTests testExample]' started.
Test Case '-[lsantestTests.lsantestTests testExample]' passed (0.086 seconds).
Test Suite 'lsantestTests' passed at 2019-04-01 11:39:41.956 am.
     Executed 1 test, with 0 failures (0 unexpected) in 0.086 (0.086) seconds
Test Suite 'lsantestPackageTests.xctest' passed at 2019-04-01 11:39:41.956 am.
     Executed 1 test, with 0 failures (0 unexpected) in 0.086 (0.086) seconds
Test Suite 'All tests' passed at 2019-04-01 11:39:41.956 am.
     Executed 1 test, with 0 failures (0 unexpected) in 0.086 (0.087) seconds

=================================================================
==76978==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2400 byte(s) in 100 object(s) allocated from:
    #​0 0x1002c1ce3 in wrap_malloc (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x5bce3)
    #​1 0x107ee3398 in swift_slowAlloc (libswiftCore.dylib:x86_64+0x2c9398)
    #&#8203;2 0x107ee3413 in _swift_allocObject_(swift::TargetHeapMetadata<swift::InProcess> const*, unsigned long, unsigned long) (libswiftCore.dylib:x86_64+0x2c9413)
    #&#8203;3 0x1047e2f67 in Leaky.__allocating_init() lsantest.swift
    #&#8203;4 0x1047e3c9d in doStuff() lsantest.swift:19
    #&#8203;5 0x1047e43a3 in lsantestTests.testExample() lsantestTests.swift:6
    #&#8203;6 0x1047e4478 in @objc lsantestTests.testExample() <compiler-generated>
    #&#8203;7 0x7fff38bad07b in __invoking___ (CoreFoundation:x86_64h+0x4a07b)
    #&#8203;8 0x7fff38bacf4e in -[NSInvocation invoke] (CoreFoundation:x86_64h+0x49f4e)
    #&#8203;9 0x10102db85 in __24-[XCTestCase invokeTest]_block_invoke_2.204 (XCTest:x86_64+0x2db85)
    #&#8203;10 0x1010b7e76 in -[XCTMemoryChecker _assertInvalidObjectsDeallocatedAfterScope:] (XCTest:x86_64+0xb7e76)
    #&#8203;11 0x101037c5d in -[XCTestCase assertInvalidObjectsDeallocatedAfterScope:] (XCTest:x86_64+0x37c5d)
    #&#8203;12 0x10102db15 in __24-[XCTestCase invokeTest]_block_invoke.198 (XCTest:x86_64+0x2db15)
    #&#8203;13 0x1010a18da in -[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] (XCTest:x86_64+0xa18da)
    #&#8203;14 0x1010a17f7 in -[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] (XCTest:x86_64+0xa17f7)
    #&#8203;15 0x10102d72e in __24-[XCTestCase invokeTest]_block_invoke (XCTest:x86_64+0x2d72e)
    #&#8203;16 0x1010a74aa in -[XCUITestContext performInScope:] (XCTest:x86_64+0xa74aa)
    #&#8203;17 0x10102d31d in -[XCTestCase testContextPerformInScope:] (XCTest:x86_64+0x2d31d)
    #&#8203;18 0x10102d3c9 in -[XCTestCase invokeTest] (XCTest:x86_64+0x2d3c9)
    #&#8203;19 0x10102ef3b in __26-[XCTestCase performTest:]_block_invoke_2 (XCTest:x86_64+0x2ef3b)
    #&#8203;20 0x1010a18da in -[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] (XCTest:x86_64+0xa18da)
    #&#8203;21 0x1010a17f7 in -[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] (XCTest:x86_64+0xa17f7)
    #&#8203;22 0x10102ee52 in __26-[XCTestCase performTest:]_block_invoke.328 (XCTest:x86_64+0x2ee52)
    #&#8203;23 0x1010af9e6 in +[XCTContext runInContextForTestCase:block:] (XCTest:x86_64+0xaf9e6)
    #&#8203;24 0x10102e5c4 in -[XCTestCase performTest:] (XCTest:x86_64+0x2e5c4)
    #&#8203;25 0x1010812e3 in -[XCTest runTest] (XCTest:x86_64+0x812e3)
    #&#8203;26 0x101028cfd in __27-[XCTestSuite performTest:]_block_invoke (XCTest:x86_64+0x28cfd)
    #&#8203;27 0x101028427 in -[XCTestSuite _performProtectedSectionForTest:testSection:] (XCTest:x86_64+0x28427)
    #&#8203;28 0x101028724 in -[XCTestSuite performTest:] (XCTest:x86_64+0x28724)
    #&#8203;29 0x1010812e3 in -[XCTest runTest] (XCTest:x86_64+0x812e3)

[...]

when I run this on Linux however, all the symbols are missing:

johannes:/tmp/lsantest
$ docker run -it --rm --privileged   -v "$PWD:$PWD" -w "$PWD" -e ASAN_OPTIONS=detect_leaks=1 -e LSAN_OPTIONS=verbosity=1:log_threads=1 swift:5.0 swift test --sanitize=address
==26==AddressSanitizer: failed to intercept '__isoc99_printf'
==26==AddressSanitizer: failed to intercept '__isoc99_sprintf'
==26==AddressSanitizer: failed to intercept '__isoc99_snprintf'
==26==AddressSanitizer: failed to intercept '__isoc99_fprintf'
==26==AddressSanitizer: failed to intercept '__isoc99_vprintf'
==26==AddressSanitizer: failed to intercept '__isoc99_vsprintf'
==26==AddressSanitizer: failed to intercept '__isoc99_vsnprintf'
==26==AddressSanitizer: failed to intercept '__isoc99_vfprintf'
==26==AddressSanitizer: failed to intercept '__cxa_rethrow_primary_exception'
==26==AddressSanitizer: libc interceptors initialized
|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||
|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||
|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||
|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||
|| `[0x000000000000, 0x00007fff7fff]` || LowMem     ||
MemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff
redzone=16
max_redzone=2048
quarantine_size_mb=256M
thread_local_quarantine_size_kb=1024K
malloc_context_size=30
SHADOW_SCALE: 3
SHADOW_GRANULARITY: 8
SHADOW_OFFSET: 0x7fff8000
==26==Installed the sigaction for signal 11
==26==Installed the sigaction for signal 7
==26==Installed the sigaction for signal 8
==26==T0: stack [0x7ffe20710000,0x7ffe20f10000) size 0x800000; local=0x7ffe20f0f5a4
==26==AddressSanitizer Init done
Test Suite 'All tests' started at 2019-04-01 10:42:49.124
Test Suite 'debug.xctest' started at 2019-04-01 10:42:49.127
Test Suite 'lsantestTests' started at 2019-04-01 10:42:49.127
Test Case 'lsantestTests.testExample' started at 2019-04-01 10:42:49.128
Test Case 'lsantestTests.testExample' passed (0.001 seconds)
Test Suite 'lsantestTests' passed at 2019-04-01 10:42:49.128
     Executed 1 test, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite 'debug.xctest' passed at 2019-04-01 10:42:49.129
     Executed 1 test, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite 'All tests' passed at 2019-04-01 10:42:49.129
     Executed 1 test, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
==27==Processing thread 26.
==27==Stack at 0x7ffe20710000-0x7ffe20f10000 (SP = 0x7ffe20f0ee98).
==27==TLS at 0x7f21476d6000-0x7f21476d7140.

=================================================================
==26==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2400 byte(s) in 100 object(s) allocated from:
    #&#8203;0 0x5651f6d066e3  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xa86e3)
    #&#8203;1 0x7f21474b3c91  (/usr/lib/swift/linux/libswiftCore.so+0x3b5c91)
    #&#8203;2 0x5651f6c68f89  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xaf89)
    #&#8203;3 0x5651f6c69f99  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xbf99)
    #&#8203;4 0x5651f6c6b108  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xd108)
    #&#8203;5 0x5651f6c6a30b  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xc30b)
    #&#8203;6 0x5651f6c6b0f0  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xd0f0)
    #&#8203;7 0x7f21477c6e10  (/usr/lib/swift/linux/libXCTest.so+0x2ee10)
    #&#8203;8 0x7f21477c6e7b  (/usr/lib/swift/linux/libXCTest.so+0x2ee7b)
    #&#8203;9 0x7f21477c6de3  (/usr/lib/swift/linux/libXCTest.so+0x2ede3)
    #&#8203;10 0x7f21477b9ac6  (/usr/lib/swift/linux/libXCTest.so+0x21ac6)
    #&#8203;11 0x7f21477c58fc  (/usr/lib/swift/linux/libXCTest.so+0x2d8fc)
    #&#8203;12 0x7f21477c55cb  (/usr/lib/swift/linux/libXCTest.so+0x2d5cb)
    #&#8203;13 0x7f21477c9841  (/usr/lib/swift/linux/libXCTest.so+0x31841)
    #&#8203;14 0x7f21477c7427  (/usr/lib/swift/linux/libXCTest.so+0x2f427)
    #&#8203;15 0x7f21477c9841  (/usr/lib/swift/linux/libXCTest.so+0x31841)
    #&#8203;16 0x7f21477c7427  (/usr/lib/swift/linux/libXCTest.so+0x2f427)
    #&#8203;17 0x7f21477c9841  (/usr/lib/swift/linux/libXCTest.so+0x31841)
    #&#8203;18 0x7f21477c743f  (/usr/lib/swift/linux/libXCTest.so+0x2f43f)
    #&#8203;19 0x7f21477c9841  (/usr/lib/swift/linux/libXCTest.so+0x31841)
    #&#8203;20 0x7f21477c4452  (/usr/lib/swift/linux/libXCTest.so+0x2c452)
    #&#8203;21 0x5651f6c696fd  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xb6fd)
    #&#8203;22 0x7f2145088b96  (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

Direct leak of 264 byte(s) in 1 object(s) allocated from:
    #&#8203;0 0x5651f6d066e3  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xa86e3)
    #&#8203;1 0x7f21474d39c5  (/usr/lib/swift/linux/libswiftCore.so+0x3d59c5)

Direct leak of 264 byte(s) in 1 object(s) allocated from:
    #&#8203;0 0x5651f6d066e3  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xa86e3)
    #&#8203;1 0x7f21474cb1c5  (/usr/lib/swift/linux/libswiftCore.so+0x3cd1c5)

Direct leak of 264 byte(s) in 1 object(s) allocated from:
    #&#8203;0 0x5651f6d066e3  (/tmp/lsantest/.build/x86_64-unknown-linux/debug/lsantestPackageTests.xctest+0xa86e3)
    #&#8203;1 0x7f21474cc79f  (/usr/lib/swift/linux/libswiftCore.so+0x3ce79f)

SUMMARY: AddressSanitizer: 3192 byte(s) leaked in 103 allocation(s).
@belkadan
Copy link
Contributor

belkadan commented Apr 1, 2019

I didn't think we got any symbolication on Linux. Am I just misremembering?

@belkadan
Copy link
Contributor

belkadan commented Apr 1, 2019

*in-process symbolication

@weissi
Copy link
Member Author

weissi commented Apr 1, 2019

@belkadan that's correct for fatalErrors and the like but I couldn't remember what the sanitizer situation was...

@weissi
Copy link
Member Author

weissi commented Jul 2, 2019

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants