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

Compilation failure with Swift 5.1 #20

Closed
djones6 opened this issue Apr 29, 2019 · 4 comments
Closed

Compilation failure with Swift 5.1 #20

djones6 opened this issue Apr 29, 2019 · 4 comments
Assignees
Milestone

Comments

@djones6
Copy link
Contributor

djones6 commented Apr 29, 2019

Attempting to build BlueSignals on Linux (or a project which depends on it - such as Kitura) with the latest Swift 5.1 snapshot (swift-5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a) fails with:

Incorrect reconstructed type for $sSay7SignalsAAC6SignalO6signal_ys5Int32VXC6actiontGD
Original type:
(bound_generic_struct_type decl=Swift.(file).Array
  (tuple_type num_elements=2
    (tuple_type_elt name=signal
      (enum_type decl=Signals.(file).Signals.Signal@/home/djones6/swift501/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:38:14
        (parent=class_type decl=Signals.(file).Signals@/home/djones6/swift501/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:31:14)))
    (tuple_type_elt name=action
      (function_type representation=c escaping
        (input=function_params num_params=1
          (param
            (struct_type decl=Swift.(file).Int32)))
        (output=tuple_type num_elements=0)))))
Reconstructed type:
(bound_generic_struct_type decl=Swift.(file).Array
  (tuple_type num_elements=2
    (tuple_type_elt name=signal
      (enum_type decl=Signals.(file).Signals.Signal@/home/djones6/swift501/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:38:14
        (parent=class_type decl=Signals.(file).Signals@/home/djones6/swift501/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:31:14)))
    (tuple_type_elt name=action
      (function_type representation=c
        (input=function_params num_params=1
          (param
            (struct_type decl=Swift.(file).Int32)))
        (output=tuple_type num_elements=0)))))
Stack dump:
0.      Program arguments: /home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift -frontend -c -primary-file /home/djones6/swift501/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift -emit-module-path /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug/Signals.build/Signals~partial.swiftmodule -emit-module-doc-path /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug/Signals.build/Signals~partial.swiftdoc -emit-dependencies-path /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug/Signals.build/Signals.d -emit-reference-dependencies-path /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug/Signals.build/Signals.swiftdeps -target x86_64-unknown-linux -disable-objc-interop -sdk / -I /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug -enable-testing -g -module-cache-path /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -enable-anonymous-context-mangled-names -parse-as-library -module-name Signals -o /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug/Signals.build/Signals.swift.o -index-store-path /home/djones6/swift501/Kitura/.build/x86_64-unknown-linux/debug/index/store -index-system-modules
1.      While emitting IR SIL function "@$s7SignalsAAC4trap7signalsySayAB6SignalO6signal_ys5Int32VXC6actiontG_tFZ".
 for 'trap(signals:)' (at /home/djones6/swift501/Kitura/.build/checkouts/BlueSignals/Sources/Signals/Signals.swift:123:9)
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x48cca44]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x48ca660]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x48cce68]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fdfe639c390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7fdfe4adb428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fdfe4add02a]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x6e6689]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x6e6e5f]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x6e6b12]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x6de076]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x6ded3f]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x6f03c3]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x61c344]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x5865f8]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x586cd7]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x508e94]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x50451f]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x49fbdd]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fdfe4ac6830]
/home/djones6/.swiftenv/versions/5.1-DEVELOPMENT-SNAPSHOT-2019-04-17-a/usr/bin/swift[0x49f759]

This seems to relate to the @escaping attribute, and the various trap() function signatures. Specifically, there is one function that takes an array of (Signal,SigActionHandler) tuples, where the SigActionHandler is not explicitly marked as @escaping, however this is then passed to another trap() function where it is escaping.

I couldn't find a syntax that allows you to mark the SigActionHandler that is embedded in the tuple type as escaping, and to be honest I'm not sure how this currently compiles - the fact that it blows up (rather than producing a proper error) on 5.1 suggests it might be a compiler issue, but I'm not really sure.

@billabt
Copy link
Collaborator

billabt commented May 4, 2019

I don't think this is a problem (except maybe with the compiler). Early in Swift 4.2 snapshot cycle, I had virtually the same thing happen to me. The compiler would dump on that particular function. Since it was a compiler crash rather than an error, I reported it to Apple using the BlueSignals project as an example. They fixed it rather quickly. I'd say watch it and see if it continues to crash with subsequent snapshots and if so, file another bug report.

@djones6 djones6 self-assigned this May 22, 2019
@djones6 djones6 modified the milestones: 2019.09, 2019.11 May 22, 2019
@ianpartridge ianpartridge modified the milestones: 2019.11, 2019.12 Jun 5, 2019
@djones6
Copy link
Contributor Author

djones6 commented Jun 6, 2019

This still fails on the latest snapshot (5.1-DEVELOPMENT-SNAPSHOT-2019-05-29-a). It is already reported under SR-10335, I'll add a comment there.

@ianpartridge
Copy link
Contributor

Hopefully fixed by apple/swift#25423

@ianpartridge
Copy link
Contributor

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants