-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
SIGSEGV running Rust tests under kcov #212
Comments
Don't be so humble! You've even found the faulty commit! That said, it's a bit surprising that this particular commit causes a crash: it shouldn't change breakpoint setting very much. Do you use the #180 feature? I.e., via LCOV_EXCL_START? Is this consistent across every run, or does it sometimes work? |
Thanks for the speedy reply! It doesn't matter whether I'm using |
OK, great! If you run kcov with --debug=15, you should be able to see how/if the breakpoint setting changes between the two versions. I think there must be something wrong related to breakpoint setting, so that a breakpoint gets misplaced (i.e. what --verify works around) and therefore causes the crash. The output will be quite long, but should be possible to pass to diff. |
Hmm - if I set debug=15 then both cases fail! The previously working case gives me:
And the end of the debug output for this case is:
The previously broken case has 7000 lines of debug output, the previously working case 220000 - I assume you don't want to see 200k lines of diff! The 7000 lines in the "broken" case are the same as the first 7000 in the "working" case, but for the "broken" one the output just stops mid-line. No obvious errors in the "broken" version. |
OK, strange. That almost sounds like kcov itself is crashing (as in #207) if it stops mid-line. Do you get a core file for kcov in that case? I'm busy with real-life things right now (repainting a room), but I'll take a deeper look at the commit after that to see if I can figure out why it breaks things. |
No problem about the delay - enjoy your redecorating! You're right - running it with debug causes kcov itself to crash, and I do get a core. Output from loading in gdb (running kcov at e620da4, Linux x86_64):
Looks like a null pointer dereference to me - seems that |
Yes, that sounds like it! Is the /checkout/src/libcore/lib.rs present in your system? Anyway, with that finding, it should be pretty easy to fix the problem. Good catching! |
Hmm... match takes a reference for line, so it really shouldn't be null. Could you mail me the source code of lib.rs? simon.kagstrom@gmail.com is the address. I'll see if I can reproduce this in a unit test, although I'll have to warn you that it might be a few days until I look at this again. |
Well, |
Well, something is strange if the source code isn't present on your system: Then it should not be able to read the file to start with. I've read the code of source-file-cache.cc again, but I can't see that it should be possible to end up in this situation. Could you mail me the core file? |
Thanks Simon - I've sent you a mail. |
Unfortunately, I guess I would need your kcov binary as well (matching the core file), I don't get any symbols in the backtrace. One other thing though: Could you build kcov in debug-mode, i.e., configure it with
? Perhaps the backtrace would be easier to follow in this case. At least the "optimized out" stuff should be gone then. |
The debug build is a good call - I may have got somewhere with that:
I wonder if the fact that Looks like if that is the case, then the call to |
Well, it should return an empty vector, but then the number of lines should
be zero, and not 1 as in this case. I think that's probably the root of the
problem.
Not at the computer now, but I think the m_empty member in
source-file-cache.cc maybe isn't set up correctly.
|
OK, so this issue with the null reference is a bit of a red herring. :( The test I see at that commit is:
And BUT you've fixed this in master, by switching to a for loop:
And running from the master, kcov itself doesn't segfault, the instrumented binary does. However I switched back to running with --debug=15 and that fails even back obn v33! So I suspect that this second bug isn't a regression, it's always been a problem, but somehow before the introduction of the line filters it only manifests with debug tracing on. The end of the debug trace shows:
And 0x7ffff71050db is inside |
OK, too bad - I had forgot that change myself. Sounds like some kind of race then, but difficult to say where it might be. Things to test:
Is the crash the same with |
Yes, I get the same problem on master and v33. Using One other thought - it's possible that this is actually a Rust bug of course, and rustc is generating bad debugging information in the binary... |
Well, normally you'd want to only cover your own code anyway, but it should still work I think. Does |
Sorry for delayed replay - |
OK, good. At least that's working as it should then. It almost sounds like a timing issue I'd say. kcov (as you've no doubt seen!) tends to slow down execution quite a bit, and maybe that triggers some race somewhere? |
Hi, just dropping by to say that I'm too affected by this. Looks like rustc bump (1.19.0 → 1.20.0) broke things completely: Last working build: https://travis-ci.org/zetok/tox/jobs/270343484#L2215 |
Does the workaround @mthebridge uses ( |
Looks like rustc bump (1.19.0 → 1.20.0) broke things. Use modified script from https://github.com/gimli-rs/gimli/blob/master/coverage @ de7eeff87fa21264e41f2b2e0b82f45f88851b2d and a workaround from SimonKagstrom/kcov#212 (comment) to make it work again. New script isn't really needed, but it also makes kcov cover tests that previously weren't checked by it.
@SimonKagstrom That works, thanks! |
FWIW, I dealt with a similar situation with Rust code in Firefox, and even contributed a patch to rustc to make things better. Generics in Rust do not get actually compiled until you instantiate them with a concrete type, and the Rust standard library has a lot of generics. This means that when you use like It's possible to encounter this in C code, but less likely due to the fact that many C libraries are dynamically linked. If you were to link an external static library that contained debug info I'm pretty sure you'd hit the same issue, though. |
Thanks for the insight into rust! Still, I don't think the missing source code as such is really the problem - that's quite common for C/C++ as well, and present no problem by itself. But the volume of instrumented code might certainly increase the chances of triggering a case of bad debug info. This problem would have been so much simpler if x86 - with variable instruction lengths - weren't so prevalent. |
I hitted by this issue today. The steps to reproduce are simple:
version of software that I use:
|
@Dushistov try running kcov with |
Sorryk forgot to mention, I've tried both variants,
|
So it works with I agree it should work without any extra options, but since this appears to be quite common (not only with Rust), the only alternative would be to make |
Perhaps a warning noting that if it's not needed |
The segfault occurs when you don't have addons:
apt:
update: true
- libiberity-dev For some reason, kcov can build without libiberity, but the segfaults at runtime. |
@fschutt kcov detects if It gives a warning though if you run with @Arzte running without |
I'm hitting an issue where running a Rust test binary under kcov segfaults, but running the binary natively is fine:
Obviously due to the way kcov works I can't run it in a debugger, but if I dump a core and load that in gdb I can see the segfault is somewhere in jemalloc in thread initialization.
Unfortunately I can't seem to generate a simple example for repro, and I can't share the underlying code, but running under kcov v33 works as expected, indicating this is a regression - and indeed
git bisect
found that the commit at fault is e620da4, which fixed #180. Annoyingly, the reason I want to run off master and not from the v33 release is because I want to be able to exclude lines within my project!I appreciate there's not a lot to go on here - let me know if there's any useful diagnsotics I can send!
The text was updated successfully, but these errors were encountered: