Passing a C++ type to a C-style Swift function crashes: malloc: Heap corruption detected ***
#78292
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
I have a C-style Swift function that will be called from C++ later. This is my "callback":
And on the C++ side,
myCppFunc
looks like this:When running this, it crashes with the following error:
Note
When I replaced
SharedPtrOfString
withDouble
or evenstd.string
, it works. It's juststd::shared_ptr<...>
that makes it crash with a heap corruption error.Reproduction
Stack dump
Expected behavior
I expect the
shared_ptr
to be free'd fine instead of corrupting the heap.Environment
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Additional information
I have created a reproduction repro here: https://github.com/mrousavy/SwiftSharedPointerBugRepro
Just download and run this (I chose "Run on my Mac (Designed for iPad)") to see the bug.
The text was updated successfully, but these errors were encountered: