Stream: general

Topic: dbg!() causing crashes and hangs


Luca Barbato (May 26 2019 at 10:33, on Zulip):

Today I'm getting reports from the rav1e team that using dbg!() causes hangs an/or worse.

As in adding !dbg(some.field) getting the code infiniloop or even segfault.

Is that a known issue or should I make them dig deeper? So far the workaround had been "use println!()"

RalfJ (May 26 2019 at 11:52, on Zulip):

that sounds odd, does that macro even use unsafe code?

oli (May 26 2019 at 12:31, on Zulip):

do you have a small (or even minimal) example of a dbg crash?

centril (May 26 2019 at 12:33, on Zulip):

that sounds odd, does that macro even use unsafe code?

No, it's pretty basic eprintln!(..) all the way -- which makes this all more worrying

Luca Barbato (May 27 2019 at 09:52, on Zulip):

it is in normal safe code, I couldn't get it to reproduce with a minimal rayon loop

Luca Barbato (May 27 2019 at 11:32, on Zulip):

I should get a branch with the condition

Luca Barbato (May 27 2019 at 11:33, on Zulip):

(if you have suggestions on how to improve that code in general that would be also welcome ^^)

Luca Barbato (May 27 2019 at 12:08, on Zulip):

https://github.com/shreevari/rav1e/blob/biasing_rdo/src/tiling/tile_state.rs#L138 here is an example

Luca Barbato (May 27 2019 at 12:24, on Zulip):

It is getting even weirder

Luca Barbato (May 27 2019 at 12:24, on Zulip):

I tried w/out the match around and it shows the same behaviour

Luca Barbato (May 27 2019 at 12:27, on Zulip):

eprintln! isn't just a write! to stderr?

oli (May 27 2019 at 12:30, on Zulip):

if you are getting a segfault that means you have undefined behavior. It may not be at all related to the dbg!

Luca Barbato (May 27 2019 at 12:30, on Zulip):

I'm not getting a segfault

oli (May 27 2019 at 12:30, on Zulip):

in the second comment in this thread you said " or even segfault."

Luca Barbato (May 27 2019 at 12:31, on Zulip):

that's what people told me

oli (May 27 2019 at 12:31, on Zulip):

ok, what's actually happening?

Luca Barbato (May 27 2019 at 12:31, on Zulip):

now I have something in my system so I can see what's going on :)

oli (May 27 2019 at 12:31, on Zulip):

what is the output?

Luca Barbato (May 27 2019 at 12:31, on Zulip):

it apparently hangs

oli (May 27 2019 at 12:31, on Zulip):

and println! doesn't?

Luca Barbato (May 27 2019 at 12:31, on Zulip):

yes

oli (May 27 2019 at 12:32, on Zulip):

can you use a debugger and dump a backtrace of the hang?

Luca Barbato (May 27 2019 at 12:32, on Zulip):

working on it right now :)

Luca Barbato (May 27 2019 at 12:33, on Zulip):

do we have cargo debug somewhere? :P

Luca Barbato (May 27 2019 at 12:39, on Zulip):

https://gist.github.com/lu-zero/f12325142b1124b086f7c820ac844c71

Luca Barbato (May 27 2019 at 12:39, on Zulip):

this is _really_ strange

Luca Barbato (May 27 2019 at 12:40, on Zulip):

what's the best way to find who's locking that mutex?

oli (May 27 2019 at 13:00, on Zulip):

not sure... but you can keep moving dbg! calls earlier until you find it I guess

Luca Barbato (May 27 2019 at 13:01, on Zulip):

so

Luca Barbato (May 27 2019 at 13:02, on Zulip):

I'm trying to set a breakpoint at #4 lock () at src/libstd/io/stdio.rs:666

Luca Barbato (May 27 2019 at 13:02, on Zulip):

(also rust-gdb should add the rust sources to the directories :P)

Luca Barbato (May 27 2019 at 13:07, on Zulip):

/me facepalms

Luca Barbato (May 27 2019 at 13:07, on Zulip):

Ok

Luca Barbato (May 27 2019 at 13:08, on Zulip):

if found the problem

Luca Barbato (May 27 2019 at 13:08, on Zulip):

and it is not related to dbg or rustc =E

oli (May 27 2019 at 13:09, on Zulip):

did you lock the error output manually?

Luca Barbato (May 27 2019 at 13:12, on Zulip):

somebody had this great idea...

Luca Barbato (May 27 2019 at 13:12, on Zulip):

and obviously I didn't think of checking that first

Luca Barbato (May 27 2019 at 13:15, on Zulip):

where are the sources of rust-gdb ?

RalfJ (May 27 2019 at 13:21, on Zulip):

@Luca Barbato might be src/etc/rust-gdb in the rustc repo

Luca Barbato (May 27 2019 at 13:29, on Zulip):

it is a binary

RalfJ (May 27 2019 at 13:30, on Zulip):

are you sure that's not just the rustup wrapper?

Luca Barbato (May 27 2019 at 13:31, on Zulip):

I am not :)

RalfJ (May 27 2019 at 13:31, on Zulip):

I think it is

RalfJ (May 27 2019 at 13:31, on Zulip):
-rwxr-xr-x 11 r r  11M Mai 23 15:54 rustc
-rwxr-xr-x 11 r r  11M Mai 23 15:54 rustdoc
-rwxr-xr-x 11 r r  11M Mai 23 15:54 rustfmt
-rwxr-xr-x 11 r r  11M Mai 23 15:54 rust-gdb
-rwxr-xr-x 11 r r  11M Mai 23 15:54 rust-lldb
-rwxr-xr-x 11 r r  11M Mai 23 15:54 rustup

notice the identical size

Luca Barbato (May 27 2019 at 13:31, on Zulip):

good, then it is easy to change :)

RalfJ (May 27 2019 at 13:32, on Zulip):

these are all the same binary (hardlinks), and all they do is determine the current toolchain and the exec the real thing

Last update: Nov 20 2019 at 11:35UTC