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-4580] Tuple-swapping in REPL can segfault #4389

Closed
natecook1000 opened this issue Apr 13, 2017 · 8 comments
Closed

[SR-4580] Tuple-swapping in REPL can segfault #4389

natecook1000 opened this issue Apr 13, 2017 · 8 comments
Assignees
Labels
bug Something isn't working LLDB for Swift

Comments

@natecook1000
Copy link
Member

Previous ID SR-4580
Radar rdar://problem/31610342
Original Reporter @natecook1000
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 3.1 (swiftlang-802.0.51 clang-802.0.41)

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee @natecook1000
Priority Medium

md5: 4553d26f07e5447fcbb868620432a6b2

Issue Description:

If I enter the following code in the Swift REPL, line by line, I get a segfault:

var a = Array(1...5)
(a[1], a[3]) = (a[3], a[1])

import AppKit

var p = CGPoint(x: 1, y: 2)
(p.x, p.y) = (p.y, p.x)

If I don't use the first two lines, the remainder executes without issue. If I paste in the whole batch or compile them in a file, there's also no problem.

@natecook1000
Copy link
Member Author

@swift-ci Create

@jckarter
Copy link
Member

@swift-ci create

@swift-ci
Copy link

swift-ci commented May 3, 2017

Comment by Jim Ingham (JIRA)

There seems to be some initialization of the standard library that happens differently depending on whether Foundation is or is not present. So if you are going to use Foundation or anything that brings it in, you need to do that first in your REPL session.

@jckarter
Copy link
Member

jckarter commented May 3, 2017

Can lldb pre-load the Foundation overlay in that case to avoid that kind of issue?

@swift-ci
Copy link

swift-ci commented May 3, 2017

Comment by Jim Ingham (JIRA)

We could, provided it is a good assumption that everybody using the REPL wants Foundation?

@jckarter
Copy link
Member

jckarter commented May 3, 2017

The other approach would be to fix the standard library to pick up when Foundation is dynamically loaded and adjust itself accordingly. It isn't totally out of the realm of possibility that someone would dlopen Foundation at runtime even outside the REPL. Jim, did you happen to see where exactly in the library we were making different initialization choices?

@swift-ci
Copy link

swift-ci commented May 3, 2017

Comment by Jim Ingham (JIRA)

I think Arnold fixed this with:

apple/swift#8868

@jckarter
Copy link
Member

jckarter commented May 9, 2017

Nate, can you confirm this works for you now?

@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
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

3 participants