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-12601] Address Sanitizer's leak output not symbolicated #55046

Open
weissi opened this issue Apr 15, 2020 · 7 comments
Open

[SR-12601] Address Sanitizer's leak output not symbolicated #55046

weissi opened this issue Apr 15, 2020 · 7 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@weissi
Copy link
Member

weissi commented Apr 15, 2020

Previous ID SR-12601
Radar rdar://problem/61911130
Original Reporter @weissi
Type Bug
Additional Detail from JIRA
Votes 1
Component/s
Labels Bug
Assignee danliew (JIRA)
Priority Medium

md5: c9e192c914759aaaab37f207bc0d6f0a

is duplicated by:

  • SR-10254 leak sanitizer doesn't symbolicate stack traces on Linux

Issue Description:

Even in debug mode (and even with -g), ASan's output isn't symbolicated on Linux 🙁

Repro:

1. Create /tmp/test.swift with the following content

public class MemoryLeaker {
    var closure: () -> Void = { () }

    public init() {}

    public func doNothing() {}

    public func doSomethingThatLeaks() {
        self.closure = {
            // This will leak as it'll create a permanent reference cycle:
            //
            //     self -> self.closure -> self
            self.doNothing()
        }
    }
}

@inline(never) // just to be sure to get this in a stack trace
func myFunctionDoingTheAllocation() {
    let thing = MemoryLeaker()
    thing.doSomethingThatLeaks()
}

myFunctionDoingTheAllocation()

and run in docker (straight from macOS)

docker run -it --rm --privileged -w /tmp -v /tmp:/tmp swift:5.2 bash -c 'swiftc -sanitize=address -g test.swift &&  ./test'

the output is

/usr/bin/ld.gold: warning: Cannot export local symbol '__asan_extra_spill_area'

=================================================================
==1==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #​0 0x559e61100c8d  (/tmp/test+0x95c8d)
    #​1 0x7f2cb51446b1  (/usr/lib/swift/linux/libswiftCore.so+0x3cb6b1)
    #​2 0x559e611312ce  (/tmp/test+0xc62ce)
    #​3 0x559e611304c3  (/tmp/test+0xc54c3)
    #​4 0x7f2cb3dc8b96  (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).
@compnerd
Copy link
Collaborator

@weissi - pretty sure that is expected, you should use llvm-symbolizer on the output to symbolize the stack.

@weissi
Copy link
Member Author

weissi commented Apr 15, 2020

@compnerd I don't think so, for two reasons: 1) We should make the users' lives as easy as we can. 2) See https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#using-leaksanitizer .

@weissi
Copy link
Member Author

weissi commented Apr 15, 2020

@swift-ci create

@weissi
Copy link
Member Author

weissi commented Apr 15, 2020

CC @kubamracek/@AnnaZaks

@swift-ci
Copy link
Collaborator

Comment by Dan Liew (JIRA)

@weissi Could you point me at the Docker image you used? The sanitizers have support to use `llvm-symbolizer` to symbolize in-process so this should work out of the box provided `llvm-symbolizer` can be found at runtime.

@weissi
Copy link
Member Author

weissi commented Apr 18, 2020

danliew (JIRA User) it’s the official Swift docker image, here’s the dockerhub link: https://hub.docker.com/layers/swift/library/swift/5.2.2/images/sha256-b87ba67d39ff1900590091df251063ccdf3567512feae7d68b086c584c312d59?context=explore

llvm-symbolizer might be missing in the official images? @gwynne/@shahmishal/@tomerd

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@zg
Copy link

zg commented Mar 12, 2023

Is there any update for this issue?

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

4 participants