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-1700] Runtime crash with NSJSONSerialization example #4144
Comments
@phausler any idea what is going on here? I don't know if this is a Foundation or compiler problem. |
Hmm you probably want to have `allowFragments` in the options |
Ah, of course. NSJSONWritingOptions doesn't have Should I close this as invalid? |
Yea, an unquoted string is questionably not a json object |
On Darwin running the same thing modulo the bridging 2016-06-07 15:30:29.209739 asdf[74319:18282990] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSJSONSerialization dataWithJSONObject:options:error:]: Invalid top-level type in JSON write'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff9367b74b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffa6ead80a objc_exception_throw + 48
2 CoreFoundation 0x00007fff936f3125 +[NSException raise:format:] + 197
3 Foundation 0x00007fff94ff603f +[NSJSONSerialization dataWithJSONObject:options:error:] + 249
4 asdf 0x000000010031b1a4 main + 228
5 libdyld.dylib 0x00007fffa7786285 start + 1
6 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException |
Yeah. It's unfortunate we don't get the same kind of information in the crash, to make it more obvious what is going on. |
I wonder if there is a way we can change our fatal errors to call backtrace_symbols to print nicer failures. (Even if they were mangled it would be an improvement) |
Maybe corelibs Foundation should consider internally using an alternative to fatalError() which print the information which would have been in the Obj-C exception? The default behavior of fatalError() for Swift is desired, IIUC, so that the codegen is minimal (in particular, it doesn't cause register pressure), but for Foundation where the APIs can't change but need to have sensible parity with Obj-C I'm not sure it is appropriate. |
Yep all of our fatal errors are not constrained; filed https://bugs.swift.org/browse/SR-1701 which it should be a pretty easy task to add and vastly improve the state of affairs of debugging issues like this. |
Additional Detail from JIRA
md5: 347009a98ceb158c19902eaff3526739
Issue Description:
This trivial sample code crashes at runtime with the latest snapshot, on Ubuntu 15.10
The text was updated successfully, but these errors were encountered: