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-392] Creating a String from an object of type ErrorType segfaults #43009
Comments
Comment by Austin Zheng (JIRA) A bit of context: I'm rewriting _dump() to not use _Reflectable, which means I can't rely upon _MirrorType's 'summary' property. A natural alternative is to ask the instance to describe itself, via debugDescription, description, etc, which is where the String(reflecting: ) constructor comes in. |
Comment by Austin Zheng (JIRA) After doing some more testing, it appears that the crash happens as early as "let b : ErrorType = a". Also, I occasionally get the following error: Assertion failed: (newval + quantum >= RC_ONE && "releasing reference with a refcount of zero"), function doDecrementShouldDeallocate, file /Users/austinzheng/Developer/Swift/swift/include/swift/Runtime/../../../stdlib/public/SwiftShims/RefCount.h, line 207. |
Comment by Jesse Rusak (JIRA) I ran a git bisect on this last night and it identified the following commit as causing this regression: Reverting that commit on top of master seems to fix the issue. I'm guessing the issue has to do with the |
Comment by Austin Zheng (JIRA) Thanks for looking into this, I really appreciate it. Is this something you'd like to pursue further, or would you prefer to hand it off to someone else? |
Comment by Jesse Rusak (JIRA) Yes, I'll try to put something together for this; just wanted to finish up a couple other things before taking it on. |
Comment by Jesse Rusak (JIRA) I've put up a PR for this here: #861 |
Comment by Jesse Rusak (JIRA) PR was merged here: 35448a1 |
Environment
OS X 10.11.2, running development version built from source (SHA: 3d0b77c). I made sure all dependencies were updated and ran the build script with the --clean flag.
Additional Detail from JIRA
md5: 665c561a48400ef5cc296a7e706545e5
blocks:
relates to:
Issue Description:
A variable of type 'ErrorType' causes a segfault if a program attempts to construct a String from it, either using the "String(a)" or "String(reflecting: a)" initializers.
As an example, the following code, whether run in the REPL or compiled into a Swift program, causes a segmentation fault when executed:
class MyErrorClass : ErrorType { }
let a = MyErrorClass()
// These are fine
print("(String(reflecting: a))")
print("(String(a))")
let b : ErrorType = a
// Either of these cause a segfault
print("(String(reflecting: b))")
print("(String(b))")
Note that this does NOT happen when using the version of swiftc bundled with Xcode 7.2. It seems like a regression.
The text was updated successfully, but these errors were encountered: