Navigation Menu

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-14543] [5.4] Calling C module segfaults via CLI only #56895

Closed
0xTim opened this issue Apr 28, 2021 · 8 comments
Closed

[SR-14543] [5.4] Calling C module segfaults via CLI only #56895

0xTim opened this issue Apr 28, 2021 · 8 comments
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 regression run-time crash Bug → crash: Swift code crashed during execution swift 5.4

Comments

@0xTim
Copy link

0xTim commented Apr 28, 2021

Previous ID SR-14543
Radar rdar://77261002
Original Reporter @0xTim
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 12.5

Additional Detail from JIRA
Votes 3
Component/s Compiler
Labels Bug, 5.4Regression, Crash
Assignee None
Priority Medium

md5: d90e4cd9b7c7ab90c74f03d7cad1145e

Issue Description:

When running a Swift program that calls through to a C module, the program segfaults. This only occurs on the CLI, running via Xcode is fine. Looks like a regression for SR-12424

To recreate:

  • git clone https://github.com/0xTim/BCryptCrash.git

  • swift run

Expected

App prints out a password hash correctly

Actual:

BCryptCrash git:(main) swift run
[1/1] Planning build


* Build Completed![1]    92807 segmentation fault  swift run
@0xTim
Copy link
Author

0xTim commented Apr 28, 2021

Linux works fine

@weissi
Copy link
Member

weissi commented Apr 28, 2021

Interestingly, on Darwin, it runs fine under ASan:

$ swift run --sanitize=address
[1/1] Planning build

[1467/1467] Linking Run

* Build Completed!
[ INFO ] Hash is $2b$12$oFs4eQPvwBWY9gBUHFg/2.acCHteRzhu8V0MULyUDDT4iot3rC0b6

@weissi
Copy link
Member

weissi commented Apr 28, 2021

Ok, this looks like the return of rdar://63137100

* thread #​1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #​0: 0x00007fff2037f000 libsystem_platform.dylib`_platform_memmove$VARIANT$Haswell
    frame #​1: 0x000000010009b767 Run`Blowfish_initstate(c=0x00007ffeefbfd900) at blf.c:390:10
    frame #​2: 0x0000000100099d5c Run`bcrypt_hashpass(key="password", salt="e/aMjf5aj44DynWeZoOqq.", encrypted="", encryptedlen=140732920748192) at bcrypt.c:120:5
    frame #​3: 0x00000001008e144f Run`BCryptDigest.hash(plaintext="password", salt="$2b$12$e/aMjf5aj44DynWeZoOqq.", self=0x0000000102b04990) at Bcrypt.swift:70:29
    frame #​4: 0x00000001008e02a9 Run`BCryptDigest.hash(plaintext="password", cost=12, self=0x0000000102b04990) at Bcrypt.swift:37:25
    frame #​5: 0x0000000100003bb9 Run`configure(app=0x00000001028064e0) at configure.swift:12:31
    frame #​6: 0x00000001008d48f9 Run`main at main.swift:8:5
    frame #​7: 0x00007fff20357f3d libdyld.dylib`start + 1

I will debug this through and report more after lunch.

@weissi
Copy link
Member

weissi commented Apr 28, 2021

@swift-ci create

@weissi
Copy link
Member

weissi commented Apr 28, 2021

compiler emitting wrong code here, this is the return of SR-12424 / rdar://63137100

@swift-ci
Copy link
Collaborator

Comment by Vojtech Rylko (JIRA)

Happens also on Swift 5.5.

@0xTim
Copy link
Author

0xTim commented Jul 1, 2021

This is fixed in 5.4.2 and latest 5.5

@weissi
Copy link
Member

weissi commented Jul 1, 2021

Thanks Tim, this is also in Xcode 12.5.1. Closing this bug then.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the run-time crash Bug → crash: Swift code crashed during execution label Sep 17, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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 regression run-time crash Bug → crash: Swift code crashed during execution swift 5.4
Projects
None yet
Development

No branches or pull requests

4 participants