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-175] ErrorType with referenced strings crash on Linux #42797

Closed
colemancda opened this issue Dec 10, 2015 · 4 comments
Closed

[SR-175] ErrorType with referenced strings crash on Linux #42797

colemancda opened this issue Dec 10, 2015 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@colemancda
Copy link
Contributor

Previous ID SR-175
Radar None
Original Reporter @colemancda
Type Bug
Status Closed
Resolution Cannot Reproduce

Attachment: Download

Environment

Ubuntu 14.04, Swift 2.2

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

md5: 1b6da670b9f5a18e9fd9dee9c8e0af6a

Issue Description:

It seems that en Error enum that conforms to ErrorType will crash when that error is thrown. This only seems to happen on Linux, and not Darwin.

coleman@ubuntu:~/Swift/MySQLSwift$ .build/debug/UnitTests
Test Case 'MySQLTests.testNewDB' started.
UnitTests: /home/buildslave/jenkins/workspace/oss-swift-linux-packages-ubuntu_14_04-one-off-build/swift/include/swift/Runtime/../../../stdlib/public/SwiftShims/RefCount.h:207: bool StrongRefCount::doDecrementShouldDeallocate() [ClearPinnedFlag = false]: Assertion `newval + quantum >= RC_ONE && "releasing reference with a refcount of zero"' failed.
Aborted (core dumped)

@colemancda
Copy link
Contributor Author

My project compiles, but the unit test target crashes only on Linux. The same unit tests run fine on OS X.

With MySQLSwift.tar.gz :

coleman@ubuntu:~/Swift/MySQLSwift$ .build/debug/UnitTests
Test Case 'MySQLTests.testNewDB' started.
UnitTests: /home/buildslave/jenkins/workspace/oss-swift-linux-packages-ubuntu_14_04-one-off-build/swift/include/swift/Runtime/../../../stdlib/public/SwiftShims/RefCount.h:207: bool StrongRefCount::doDecrementShouldDeallocate() [ClearPinnedFlag = false]: Assertion `newval + quantum >= RC_ONE && "releasing reference with a refcount of zero"' failed.
Aborted (core dumped)

@colemancda
Copy link
Contributor Author

Was able to fix the crash. It seems that my Error enum with a associated string will crash on Linux. Here's the fix:

in Connection.swift

@swift-ci
Copy link
Collaborator

Comment by Dan Appel (JIRA)

I'm getting the same error, but in my case its a struct (which conforms to ErrorType). The error I'm getting is:

fatal error: _StringCore elementWidth doesn't match its buffer's: file /home/buildslave/jenkins/workspace/oss-swift-linux-packages-ubuntu_15_10-one-off-build/swift/stdlib/public/core/StringCore.swift, line 68

My workaround is to set the description to be empty as shown in this file.

@mxcl
Copy link

mxcl commented Jan 7, 2016

We are using the following work-around in SwiftPM:

func safeStringify(error: ErrorType) -> String {
    // work around for a miscompile when converting error type to string

    struct TempStream: OutputStreamType {
        var result: String = ""
        mutating func write(string: String) {
            result += string
        }
    }

    var stream = TempStream()
    print(error, toStream: &stream)
    return stream.result
}

Also, I've found that this crash happens on OS X intermittently too. Though I don't get a reliable backtrace it often seems to involve refcounting named functions.

@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

3 participants