(oh oh oh, just like, imagine if debug Rust could point to the line in source that the program broke, and explain how it broke, and why. Would be so much better than staring at a 50 line stack trace)
-
Show this thread
-
Replying to @yoshuawuyts
The problem is code ownership and responsibilities, what invariant went wrong is not something the compiler can figure out because it's a higher level concept not encoded in the type system. (If it could be, it wouldn't be a panic)
1 reply 0 retweets 1 like -
Replying to @ManishEarth @yoshuawuyts
It's often the first frame (or in the case of unwrap, the second frame), but not always. (There's an rfc for implicit caller location that makes this somewhat nicer for the semi-common case)
1 reply 0 retweets 0 likes -
Replying to @ManishEarth
Oh haha, yeah I don't disagree. Guess I should've been more specific. Currently we have a known TLS bug in a program. On invalid access instead of just panicking it'd be wild if we could track which thread failed, and show the line of code where the thread was spawned.
1 reply 0 retweets 1 like -
Replying to @yoshuawuyts @ManishEarth
I'm suspecting there might be more cases like these around stdlib. For example locks is another I'm curious about. But just in general if we could log the source lines corresponding to the failure I think we could really make some leaps.
1 reply 0 retweets 1 like -
Replying to @yoshuawuyts
Ah tracking threads is possible. When you spawn threads you can name them, fwiw, and that shows up in the backtrace.
2 replies 0 retweets 2 likes -
Replying to @ManishEarth
Ohh, didn't know that! -- that's very cool. Do you perhaps also know if it's possible to name the main thread? Would be cool to name it thread(main) instead of the regular thread(1) (or thread(0), I forget if it's zero-indexed haha)
1 reply 0 retweets 0 likes -
Replying to @yoshuawuyts
it is named main, that's why the panic says "thread `main` panicked on foobar" :)
1 reply 0 retweets 2 likes -
Replying to @ManishEarth @yoshuawuyts
OSX crash logs number the threads but we have zero control over that rust backtraces use thread names
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @yoshuawuyts
similarly i think OSX crash logs don't include fileline info but rust backtraces do
1 reply 0 retweets 0 likes
Ahh, cool! Guess I got confused with the std::thread::current().id() output.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.