Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDebuginfo: Source lines for fail! invocations are incorrect #9232
Comments
This comment has been minimized.
This comment has been minimized.
|
Do you have an example of where this goes wrong as well? I may have broken usage through nested macros recently, but normal vanilla usage should be ok I thought. |
This comment has been minimized.
This comment has been minimized.
fn foo() {
fail!("whoops");
}
fn main() {
foo();
}
|
This comment has been minimized.
This comment has been minimized.
|
oh you mean with debug-info! I thought you meant what it actually printed to the console. Don't mind me... |
This comment has been minimized.
This comment has been minimized.
|
This is still incorrect... but in a different way; everything is now listed as being at the
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I suspect that the line 6 is coming from line 6 of the definition of fail here: https://github.com/mozilla/rust/blob/master/src/libstd/macros.rs#L48. Each macro is individually serialized which is why the line count shifted. I think the issue before and now is that the debug info infrastructure needs to do something special with spans that point to autogenerated "files" like "". |
This comment has been minimized.
This comment has been minimized.
|
Triage time! To reproduce today, source code:
compile:
use gdb:
notably: hello::foo () at :3 and hello::main () at hello.rs:6 Is this wrong? should it say |
This comment has been minimized.
This comment has been minimized.
|
Yes, the output in frame 3 is not as useful as it could be, since you really want to know what line the macro was invoke on, rather than which line of the macro called begin_unwind. |
This was referenced Nov 18, 2015
huonw
added
the
A-macros
label
Jan 5, 2016
This comment has been minimized.
This comment has been minimized.
|
Just ran into this with a custom macro - one function contains multiple expansion of the macro, which calls another function, which panics. The backtrace doesn't make it easy to tell which expansion was involved. Not sure how this would be fixed, since the only obvious alternative would be emitting line info for the expansion site instead, which would cause the opposite problem, not being able to tell where in the macro the call came from. (This is what you get in C, and it's awful for sufficiently long macros.) Maybe rustc could fake an inline function call somehow? |
aturon
changed the title
Source lines for fail! invocations are incorrect
Debuginfo: Source lines for fail! invocations are incorrect
Apr 15, 2017
Mark-Simulacrum
added
the
C-enhancement
label
Jul 19, 2017
Mark-Simulacrum
removed
the
I-papercut
label
Jul 28, 2017
This comment has been minimized.
This comment has been minimized.
|
Triage: you need to use |
This comment has been minimized.
This comment has been minimized.
|
Now I see:
Frames 3 and 4 look fine to me. I don't know whether there is a test for this or not; but if so, I think it could be closed. |
jdm commentedSep 16, 2013
When I set a breakpoint in rust_begin_unwind and hit a fail! somewhere, the stack frame containing the fail! call shows the right file but the wrong line. It shows me line 66, which I suspect comes from injecting the std_macros (including fail!) into every file, since the fail! definition occurs on line 60 of that block (see syntax/etx/expand.rs).