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-10519] Segfault with simple Dictionary insert #52919

Closed
swift-ci opened this issue Apr 19, 2019 · 2 comments
Closed

[SR-10519] Segfault with simple Dictionary insert #52919

swift-ci opened this issue Apr 19, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10519
Radar None
Original Reporter Neon12345 (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Environment

Ubuntu 16.04 with Swift 5 release version: https://swift.org/builds/swift-5.0-release/ubuntu1604/swift-5.0-RELEASE/swift-5.0-RELEASE-ubuntu16.04.tar.gz

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 589472f6aae0bfa1890906ea6b5e5084

Issue Description:

The following example segfaults when compiled to an executable with swiftc and exec:

struct TestData {
}

struct Test {
    let v : Int
    var value : Int {
         return v
    }
}

extension Test: Hashable {
    public static func == (lhs: Test, rhs: Test) -> Bool {
        return lhs.value == rhs.value
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(self)
    }
}

var _data : [Test: TestData] = [:]

func main() -> Void {
    _data[Test(v:10)] = TestData()
    //_data.updateValue(TestData(), forKey:Test(v:10))
}

main()
 
@belkadan
Copy link
Contributor

Your hash(into:) implementation says hasher.combine(self), which is going to lead to an infinite loop.

@swift-ci
Copy link
Collaborator Author

Comment by Neon (JIRA)

Ok, this happens when you think Swift is so smart that you don't need to look into details. 😉

Sorry for the noise and thanks.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants