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-7487] Segfault in interpreter when printing NSRegularExpression #4372

Open
alblue opened this issue Apr 20, 2018 · 3 comments
Open

[SR-7487] Segfault in interpreter when printing NSRegularExpression #4372

alblue opened this issue Apr 20, 2018 · 3 comments
Labels
bug Something isn't working LLDB for Swift REPL

Comments

@alblue
Copy link

alblue commented Apr 20, 2018

Previous ID SR-7487
Radar None
Original Reporter @alblue
Type Bug
Status Reopened
Resolution
Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug, REPL
Assignee None
Priority Medium

md5: ac1256c94df62a3aa7b0b4925b8f1b40

Issue Description:

When running Swift 4.1 on Linux, running the interpreter with the following results in a crash:

$ export C_INCLUDE_PATH=/usr/lib/swift/clang/include
$ export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH
$ swift
Welcome to Swift version 4.1 (swift-4.1-RELEASE). Type :help for assistance.
1> import Foundation
2> NSRegularExpression(pattern:"(.*)",options:[])
$R0: Foundation.NSRegularExpression = {
Foundation.NSObject = {}
Segmentation fault

Modifying to store the return value does not have this effect:

$ swift
Welcome to Swift version 4.1 (swift-4.1-RELEASE). Type :help for assistance.
1> import Foundation
2> _ = NSRegularExpression(pattern:"(.*)",options:[])
3> ^D

If the value is stored to an intermediate value, then printed, the error is seen:

swift
Welcome to Swift version 4.1 (swift-4.1-RELEASE). Type :help for assistance.
1> import Foundation
2> let a = NSRegularExpression(pattern:"(.*)",options:[])
a: Foundation.NSRegularExpression = {
Foundation.NSObject = {}
Segmentation fault

However, if the value is printed (with print or debugPrint) then we don't see the issue:

3> debugPrint(NSRegularExpression(pattern:"(.*)",options:[]))
<NSRegularExpression: 0x0000555555599ca0>
4> print(NSRegularExpression(pattern:"(.*)",options:[]))
<NSRegularExpression: 0x0000555555599ca0>
5>

So there is something in the way that the interpreter is trying to unpack or display the result that's causing the segfault.

Created on an Ubuntu runtime with Swift 4.1 release.

@belkadan
Copy link

jingham@apple.com (JIRA User), any ideas?

@swift-ci
Copy link

Comment by Jim Ingham (JIRA)

Would it be possible to get a crash dump? Maybe attach to lldb with lldb, and when it crashes do "bt all"...

@alblue
Copy link
Author

alblue commented Apr 23, 2018

I tried to get a crash dump, but running lldb(swift repl) from within an lldb kept stopping at the 'exec', presumably due to launching an inferior inferior process. In any case, it's fairly trivial to reproduce if you know the magic incantations necessary from lldb.

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift REPL
Projects
None yet
Development

No branches or pull requests

3 participants