[SR-696] EXC_BAD_ACCESS on returning a throwing Dictionary #43311
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
run-time crash
Bug → crash: Swift code crashed during execution
SILGen
Area → compiler: The SIL generation stage
Attachment: Download
Environment
Xcode 7.2.0 & 7.2.1
Additional Detail from JIRA
md5: 7b824fc2a06caeee5b99f3f8ad73bb66
Issue Description:
Summary
When creating a
Dictionary
literal containing values build from a throwing expression, the code often crashes with EXC_BAD_ACCESS (it seems while trying to release the dictionary being constructed)How to reproduce
Stacktrace
When crashing, the stacktrace looks like this (extract from REPL; had similar stacktrace in my full project in Xcode):
Observed with any compiler optimization level
I tried pasting that code in a
main.swift
and compiling it with bothswiftc main.swift
,swift -O main.swift
andswift -Onone main.swift
. No matter what, the crash happens with all three optimization levels when running the./main
compiled code.Complete example with multiple tested variants
Here are other various tests I tried and their result (see also attached file)
It seems whatever I try, as soon as I build a Dictionary literal with a throwing expression as value it might crash. Doesn't seem to happen when building an
Array
literal, only withDictionary
(or I've been very lucky after 20x tries with arrays).Attached sample code
The above code has been embedded in the attached file
main.swift
with#if
blocs for testing convenience. Simply useswiftc main.swift -DTEST1
then run./main
multiple times to reproduce the segfault using thetest1()
case; same fortest2()
, etc.The text was updated successfully, but these errors were encountered: