Skip to content

std::thread memory leaks #12988

@emaxx-google

Description

@emaxx-google

Sample program:

#include <thread>
int main() {
  std::thread([]{}).detach();
}

Compilation flags:

emcc main.cc -pthread -fsanitize=address -s INITIAL_MEMORY=134217728 -s EXIT_RUNTIME=1

Result (Emscripten 2.0.9):

=================================================================
==42==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x22f9f in wasm-function[675]+0x22f9f (a.out.wasm+0x22f9f)
    #1 0x1840 in wasm-function[57]+0x1840 (a.out.wasm+0x1840)
    #2 0x166d in wasm-function[56]+0x166d (a.out.wasm+0x166d)
    #3 0x3b9a in wasm-function[123]+0x3b9a (a.out.wasm+0x3b9a)
    #4 0x80000510  (JavaScript+0x510)
    #5 0x80001bd0 in callMain a.out.js:7120:13
    #6 0x80001bf6 in doRun a.out.js:7158:21
    #7 0x80001c02 in run a.out.js:7170:3

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x22f9f in wasm-function[675]+0x22f9f (a.out.wasm+0x22f9f)
    #1 0x8dd4 in wasm-function[225]+0x8dd4 (a.out.wasm+0x8dd4)
    #2 0x182c in wasm-function[57]+0x182c (a.out.wasm+0x182c)
    #3 0x166d in wasm-function[56]+0x166d (a.out.wasm+0x166d)
    #4 0x3b9a in wasm-function[123]+0x3b9a (a.out.wasm+0x3b9a)
    #5 0x80000510  (JavaScript+0x510)
    #6 0x80001bd0 in callMain a.out.js:7120:13
    #7 0x80001bf6 in doRun a.out.js:7158:21

Indirect leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x22f9f in wasm-function[675]+0x22f9f (a.out.wasm+0x22f9f)
    #1 0x1825 in wasm-function[57]+0x1825 (a.out.wasm+0x1825)
    #2 0x166d in wasm-function[56]+0x166d (a.out.wasm+0x166d)
    #3 0x3b9a in wasm-function[123]+0x3b9a (a.out.wasm+0x3b9a)
    #4 0x80000510  (JavaScript+0x510)
    #5 0x80001bd0 in callMain a.out.js:7120:13
    #6 0x80001bf6 in doRun a.out.js:7158:21
    #7 0x80001c02 in run a.out.js:7170:3

SUMMARY: AddressSanitizer: 32 byte(s) leaked in 3 allocation(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions