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-11293] swift-format crashes on ubuntu 19.04 #345

Closed
swift-ci opened this issue Aug 11, 2019 · 3 comments
Closed

[SR-11293] swift-format crashes on ubuntu 19.04 #345

swift-ci opened this issue Aug 11, 2019 · 3 comments
Labels
bug Something isn't working swift-format

Comments

@swift-ci
Copy link

Previous ID SR-11293
Radar None
Original Reporter cukier (JIRA User)
Type Bug
Environment

ubuntu 19.04

swift in my $PATH
Swift version 5.1-dev (LLVM 8d110eebee, Swift 89382f712a)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Bug
Assignee None
Priority Medium

md5: aad73f8681deb060cc0a19a6b3c5d9bd

Issue Description:

I cloned swift-format, ran `swift build` and after running `/swift-format/.build/debug/swift-format ./test.swift` I was greeted by

Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /home/cukier/Developer/swift-format/.build/checkouts/swift-syntax/Sources/SwiftSyntax/AtomicCounter.swift, line 42
Current stack trace:
0    libswiftCore.so                    0x00007ff502be8f00 swift_reportError + 50
1    libswiftCore.so                    0x00007ff502c581a0 _swift_stdlib_reportFatalErrorInFile + 115
2    libswiftCore.so                    0x00007ff502b826ee <unavailable> + 3626734
3    libswiftCore.so                    0x00007ff502b82867 <unavailable> + 3627111
4    libswiftCore.so                    0x00007ff50295dccd <unavailable> + 1379533
5    libswiftCore.so                    0x00007ff502b55728 <unavailable> + 3442472
6    libswiftCore.so                    0x00007ff50295d099 <unavailable> + 1376409
7    swift-format                       0x000055abd2842087 <unavailable> + 2969735
8    swift-format                       0x000055abd2841f49 <unavailable> + 2969417
9    libpthread.so.0                    0x00007ff5027c4197 <unavailable> + 70039
10   libswiftCore.so                    0x00007ff502c0a560 swift_once + 102
11   swift-format                       0x000055abd2841f37 <unavailable> + 2969399
12   swift-format                       0x000055abd2841f19 <unavailable> + 2969369
13   swift-format                       0x000055abd28a34af <unavailable> + 3368111
14   swift-format                       0x000055abd28a3442 <unavailable> + 3368002
15   swift-format                       0x000055abd28a4a56 <unavailable> + 3373654
16   swift-format                       0x000055abd28a53bd <unavailable> + 3376061
17   swift-format                       0x000055abd28a80f6 <unavailable> + 3387638
18   swift-format                       0x000055abd28a92b0 <unavailable> + 3392176
19   swift-format                       0x000055abd274879b <unavailable> + 1947547
20   swift-format                       0x000055abd2dd0ed2 <unavailable> + 8797906
21   swift-format                       0x000055abd2dd2bd0 <unavailable> + 8805328
22   swift-format                       0x000055abd2dd2630 <unavailable> + 8803888
23   libc.so.6                          0x00007ff5018faa80 __libc_start_main + 235
24   swift-format                       0x000055abd263b87a <unavailable> + 845946
Illegal instruction (core dumped)

It doesn't happen on macos.

@allevato
Copy link
Collaborator

I've also run into this on Linux, but admittedly it's not a platform that I'm regularly able to test on.

This appears to be an issue in swift-syntax; if I remember correctly, the call to dlsym here is returning nil instead of the pointer to the symbol that's statically linked into the executable:

https://github.com/apple/swift-syntax/blob/master/Sources/SwiftSyntax/AtomicCounter.swift#L42

I think the fact that SwiftSyntax uses dlsym to find that C function at runtime might mean that any Linux clients will be forced to pass something like --export-dynamic to the linker.

@akyrtzi, do you have any insight here?

@akyrtzi
Copy link
Member

akyrtzi commented Aug 19, 2019

Whoa, I wasn't aware the `dlsym` trick is not working for linux. The point of this was to avoid needing to add a separate module, that would also have to be present for `import SwiftSyntax` to work, for just a single C function.

But instead of this trick, we could probably be able to use the `@_implementationOnly import` feature that was introduced in swift-5.1

@allevato
Copy link
Collaborator

apple/swift-syntax#140 fixes the underlying issue in SwiftSyntax, but I'll wait to close this out until swift-format has been updated to depend on a version that includes that change.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swift-format
Projects
None yet
Development

No branches or pull requests

3 participants