swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.23k stars 10.32k forks source link

[SR-7583] simple TSan test program just crashes with latest master dev snapshot #50125

Open weissi opened 6 years ago

weissi commented 6 years ago
Previous ID SR-7583
Radar None
Original Reporter @weissi
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, Linux | |Assignee | None | |Priority | Medium | md5: ad1d36cf8bac1dcbc29eceb22776f5ac

Issue Description:

this simple program (which should run TSan clean but doesn't on 4.1 (SR-7582)) now just crashes on the latest swift master dev snapshot:

import Dispatch

var a: Int = 0
let q = DispatchQueue(label: "q")
q.async {
    a += 1
}

let aViaThread = q.sync { () -> Int in
    a += 1
    return a
}

print(aViaThread)

see here what happens when compiled (with TSan, works fine without) & run:

$ /usr/local/swift/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a-ubuntu16.04/usr/bin/swiftc -sanitize=thread test.swift 
jweiss:/tmp
$ ./test 
Segmentation fault (core dumped)
-SEGV- jweiss:/tmp
$ /usr/local/swift/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a-ubuntu16.04/usr/bin/lldb ./test
(lldb) target create "./test"
Current executable set to './test' (x86_64).
(lldb) run
Process 32445 launched: './test' (x86_64)
Process 32445 stopped
* thread #​1, name = 'test', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #​0: 0x0000000000000000
error: memory read failed for 0x0
Target 0: (test) stopped.
(lldb) bt
* thread #​1, name = 'test', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #​0: 0x0000000000000000
    frame #​1: 0x00005555555d6bab test`::MonotonicNanoTime() at sanitizer_linux_libcdep.cc:754
    frame #​2: 0x00005555555b0648 test`::PopulateFreeArray() at sanitizer_allocator_primary64.h:700
    frame #​3: 0x00005555555b0235 test`::GetFromAllocator() at sanitizer_allocator_primary64.h:136
    frame #​4: 0x00005555555afe99 test`::Refill() at sanitizer_allocator_local_cache.h:111
    frame #​5: 0x00005555555afb47 test`::Allocate() at sanitizer_allocator_local_cache.h:47
    frame #​6: 0x00005555555ad4a3 test`::Allocate() at sanitizer_allocator_combined.h:62
    frame #​7: 0x00005555555ac627 test`::user_alloc_internal() at tsan_mman.cc:157
    frame #​8: 0x00005555555acb17 test`::user_calloc() at tsan_mman.cc:183
    frame #​9: 0x000055555556018c test`::__interceptor_calloc() at tsan_interceptors.cc:684
    frame #​10: 0x00007ffff6f29627
(lldb) 
belkadan commented 6 years ago

cc @kubamracek