Noncopyable deinit causes compiler crash or miscompile with tsan #74042
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
triage needed
This issue needs more specific labels
Description
This copied from this forum post: https://forums.swift.org/t/noncopyable-type-has-deinit-called-before-init/72152
I have a test case where a noncopyable struct’s deinit is called twice, leading to memory corruption. This only happens when compiled with thread sanitizer.
On 5.10 this causes a miscompile on 6.0 nightly forum replies say that it crashes (I haven’t tried).
Reproduction
Stack dump
Expected behavior
I expected it to print this:
On swift 5.10 it prints Deinit once before Initing (unexpected) AND once after (expected). On swift 6.0 nightly it apparently crashes (see forum replies for this).
Environment
Version with miscompile:
$ swiftc --version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Version with crash:
Apple Swift version 6.0-dev (LLVM 4b0b1f9e1a69523, Swift 91a3abc)
Additional information
No response
The text was updated successfully, but these errors were encountered: