You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
0xpablo opened this issue
Jun 17, 2019
· 3 comments
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
The Dynamic Method Replacement feature only works if the replacements are in the same file.
Even if there are two unrelated types with replacements in different files, the compiler seems to only pick up the first replacement.
Additionally, if Whole Module Optimization is enabled and there are replacements in different files, the compiler crashes.
STR:
Create a new Command Line Tool (this happens in frameworks as well)
Create a type A in A.swift with a method foo()
Create a replacement of A.foo() inside A.swift
Create a type B in B.swift with a method bar()
Create a replacement of B.bar() inside B.swift
In main.swift, call A().foo() and B().bar().
Run the program and observe how only one replacement will be called.
(Additional steps to reproduce the crash)
8. Change the SWIFT_COMPILATION_MODE build setting to wholemodule
9. Compile the project
I attach a very simple Xcode project that shows the issue. wmo is not enabled so you can see that A's replacement does not work (the original implementation gets called).
The text was updated successfully, but these errors were encountered:
Hi aschwaighofer@apple.com (JIRA User), this is the issue a colleague of mine approached you for at WWDC. At that time we didn't know how to reproduce but we have been able to reduce the issue to a trivial example. We hope it's useful!
If you need us to dupe this in Radar or if we can do anything else to help let us know.
It looks like if I move the replacements together to a single file (but leave one of the class declarations in a different file, I also get a compiler crash and this time I got a stack dump):
When there are multiple object files with replacements the replacement sections from the individual object files get concatenated. We were only considering the first entry in that concatenation.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Attachment: Download
Environment
This is happening at least on:
Swift 5.1 (Xcode 10.11 b1)
macOS 10.14.5 and 10.15 b1
Additional Detail from JIRA
md5: 718db125b745e51289b765edac1e3086
Issue Description:
The Dynamic Method Replacement feature only works if the replacements are in the same file.
Even if there are two unrelated types with replacements in different files, the compiler seems to only pick up the first replacement.
Additionally, if Whole Module Optimization is enabled and there are replacements in different files, the compiler crashes.
STR:
A
inA.swift
with a methodfoo()
A.foo()
insideA.swift
B
inB.swift
with a methodbar()
B.bar()
insideB.swift
main.swift
, callA().foo()
andB().bar()
.(Additional steps to reproduce the crash)
8. Change the
SWIFT_COMPILATION_MODE
build setting towholemodule
9. Compile the project
Compilation will fail with the following error:
I attach a very simple Xcode project that shows the issue.
wmo
is not enabled so you can see that A's replacement does not work (the original implementation gets called).The text was updated successfully, but these errors were encountered: