Skip to content

[cxx-interop] Passing std.vector to print causes EXC_BAD_ACCESS #81862

Closed
@Drejzer

Description

@Drejzer

Description

Passing std.vector to print causes EXC_BAD_ACCESS.
There's also warning: the Swift runtime was unable to demangle the type of field ''. the mangled type name is 'or': unknown error. this field will show up as an empty tuple in Mirrors printed out just before the crash.

Reproduction

namespace cxx_target{
using StringVector = std::vector<std::string>;
}
import cxx_target

print(cxx_target.StringVector())

Expected behavior

Printing doesn't cause EXC_BAD_ACCESS.

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0

Additional information

https://forums.swift.org/t/passing-std-vector-to-print-crashes-is-that-expected/80188

Thread 0 crashed:

0 0x000000018f5ed9e4 _platform_strlen + 4 in libsystem_platform.dylib
1 0x00000001a112c5e8 swift_reflectionMirror_subscript + 296 in libswiftCore.dylib
2 0x00000001a0ea53f0 LazyMapSequence.Iterator.next() + 592 in libswiftCore.dylib
3 0x00000001a0e1635c _IteratorBox.next() + 104 in libswiftCore.dylib
4 0x00000001a0ec9a34 _adHocPrint_unlocked<A, B>(_:_:_:isDebugPrint:) + 1688 in libswiftCore.dylib
5 0x00000001a0e139d0 _print_unlocked<A, B>(_:_:) + 1324 in libswiftCore.dylib
6 0x00000001a0ed215c specialized _print<A>(_:separator:terminator:to:) + 280 in libswiftCore.dylib
7 0x00000001a0ed1424 print(_:separator:terminator:) + 176 in libswiftCore.dylib

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++run-time crashBug → crash: Swift code crashed during executionstandard libraryArea: Standard library umbrella

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions