Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-12179] Windows, compiling w/o speculative devirtualization produces unstable binaries #3270

Closed
lxbndr opened this issue Feb 11, 2020 · 4 comments

Comments

@lxbndr
Copy link
Contributor

lxbndr commented Feb 11, 2020

Previous ID SR-12179
Radar rdar://problem/59496026
Original Reporter @lxbndr
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Apple Swift version 5.2-dev (LLVM 88d1013b2e, Swift 7177f4a730)
Target: x86_64-unknown-windows-msvc

Additional Detail from JIRA
Votes 0
Component/s Compiler, Foundation
Labels Bug, Foundation, Windows
Assignee @compnerd
Priority Medium

md5: bc89c69d3a5f5a94258b547fe2202d02

Issue Description:

After commit 5285bf7200d2999812a79df35ff2eebd41cc7ee7 noticeable part of Foundation tests on Windows became unstable.

Compiling with -enable-spec-devirt makes tests stable again.

Stack traces are different for different call sites. Mostly "Illegal Instruction" somewhere in Foundation.dll. Common in all cases: always related to bridged classes. In case below it is _NSCFConstantString.

The easiest steps I found (and most informative at the same time):

  1. Replace content of TestFoundation\main.swift with sample code:
import Foundation
_ = Bundle.main.infoDictionary // <- crash

2. Build and run TestFoundation target

Reconstructed stack:

swiftCore.dll         swift::TargetOpaqueExistentialContainer<swift::InProcess>::projectValue Line 31     swift\stdlib\public\runtime\ExistentialContainer.cpp(31)
swiftCore.dll         swift::TargetExistentialTypeMetadata<swift::InProcess>::projectValue Line 1858      swift\include\swift\ABI\Metadata.h(1858)
swiftCore.dll         tryDynamicCastBoxedSwiftValue Line 1904                                             swift\stdlib\public\runtime\Casting.cpp(1904)
swiftCore.dll         swift_dynamicCastImpl Line 2265                                                     swift\stdlib\public\runtime\Casting.cpp(2265)
...
Foundation.dll        Dictionary._conditionallyBridgeFromObjectiveC(_:result:) Line 70                    Foundation\Dictionary.swift(70)  // "guard let k = key as? Key", key is _NSCFConstantString
Foundation.dll        Dictionary._unconditionallyBridgeFromObjectiveC(_:) Line 91                         Foundation\Dictionary.swift(91)
Foundation.dll        NSDictionary._bridgeToSwift() Line 731                                              Foundation\NSDictionary.swift(731)
Foundation.dll        _StructTypeBridgeable._bridgeToAny() Line 50                                        Foundation\Bridging.swift(50)
Foundation.dll        __SwiftValue.fetch(nonOptional:) Line 164                                           Foundation\Bridging.swift(164)
Foundation.dll        __SwiftValue.fetch(_:) Line 82                                                      Foundation\Bridging.swift(82)
Foundation.dll        Bundle.infoDictionary Line 366                                                      Foundation\Bundle.swift(366)
...

@lxbndr
Copy link
Contributor Author

lxbndr commented Feb 11, 2020

cc @compnerd

@lxbndr
Copy link
Contributor Author

lxbndr commented Feb 14, 2020

Had opportunity to check this on slightly newer build, still reproducible.
LLVM 9505d8980c, Swift 1d2d8d4aee

@beccadax
Copy link
Contributor

@swift-ci create

@compnerd
Copy link
Collaborator

compnerd commented Apr 1, 2020

This was the compiler optimizing away the initializer (reasonably). This has been resolved for now (added a {{@inline(never)}} function call with the result).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants