-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
5.8.4 built with meson segfaults on some binaries #21491
Comments
I compiled r2 with meson (on macOS and Ubuntu) with the flags listed below taken from the fedora build logs). Downloaded the coreutils pkg and loaded the false binary without any crash.
So, before I jump into doing more tests here because i assume i need to setup a fedora VM to reproduce.. Also I would like to understand the use of some of these flags:
also, other comments and personal opinions:
|
that's my blind guess. but all this code sucks in many ways and i would like to rewrite it from scratch too.
|
|
Here is the backtrace with the debuginfo installed it should give the line numbers:
|
Quite possibly it is not just about the messon build. I have tried to compile/install radare 5.8.4 now using the sys/install.sh .
|
Asan stands for address sanitizer. You can use the sys/sanitize.sh script to build r2 with all the instrumentation in place (must clean the srcdir before) theres also a flag for meson to do the same. its weird that i cannot reproduce. Can you share the binary that is crashing for you? Zip it and attach it to the issue |
Please where you got the MESONFLAGS from, the build on copr (and official Fedora package are not using this variable and are usually enabled with the possibility to debug. This is the messon command used:
Debugger is disabled (-Ddebugger=false) only on the s390x platform (big-endian) - there were some issues with that. Long time I have not checked whether it got any better. Here the radare2.spec stanza:
This is generic strategic decision of the distributions (Fedora, Debian ...) to preferably use shared system libraries rather then local copies of code snippets embedded in various projects. It is not a dogma, but at least as a packager I need to track what libraries are embedded with versions and sufficient identification so it is possible for people tracking vulnerabilities to assess whether package is vulnerable or not, when some of the embedded/linked libraries is found vulnerable. For example the libr/magic ... it is not really clear what version is this exactly based on, what has been patched, whether vulnerabilities since 2010 (when the code was probably forked) have been patched. This would make it hard for people who track the vulnerabilities in Fedora to judge, is this still vulnerable or not. Especially as radare2 does not only embeds pristine libraries, but these are also heavily modified. And embedding 3rd party libraries brings also the licensing questions, which not-lawyers like to avoid to resolve. It is easier for packager to leave this to be handled by the standalone library packages and just link to those. For example the libr/magic is licensed with BSD 2 clause license, Radare2 is GPLv3+. |
seems sanitize works only with clang and not gcc
|
Asan works with gcc, clang and msvc. It was recently implemented in visual studio 2022. So maybe your gcc installation is incomplete or broken. That was implemented in gcc 4.8 but maybe the distro requires an extra package or ldflag like -lasan to make it work :? |
Managed to compile/install with sys/sanitize.sh (I was having libasan installed for i686, but obviously x86_64 is needed). |
its weird because asan builds are able to catch very weird bugs like integer overflows or off-by-one reads which doesnt cause any crash on normal executions.. i still cant reproduce. can you try with valgrind then? i also trtied with the same exact meson line you shared in the previous message and i it doesnt crash for me |
did you tried with the patch i shared some comments above? the multithreading thing with iaito was fixed a year ago. theres no need to pass this flag to make iaito happy nowadays |
asan is reporting a lot of stuff, but that is after I quit. The crash on opening is not manifesting:
|
Nope - sorry I failed to recognize it is patch fixing it. I thought it is general comment. |
I merged the proposed patch into master so you can git pull and try there :) Those asan messages are leaks (30KB of memory leaks) i plan to spend some time fixing those during before 5.8.6 but those are harmless. So cant say whats making it fail for you :/ |
I have tried with the patch. Now the segfault happens in hashRBinElfSymbol.lto_priv.1 and not the sdb_hash.
|
There is definitely some race condition to this. I have tried fresh account with no history of using radare2.
And then after a while playing with that the situation changed and getting the core dump all the time., Backtrace with the debug info
|
there are no threads in r2, so it can't be a race condition. if it fails randomly it should be spotted by valgrind or asan because it should be an uninitialized variable in use or UB. that thanks! |
I mean "race condition" not necessarily limited to threads interacting between themselves, but in broader sense that it depends also on something else within whole system, which I might or might not be able to influence.
Sure ... thanks.
Valgrind reports this:
But again like with asan - executing with valgrind it doesn't segfault.
I will try prepare build like that. |
omg the valgrind log is useful. i think i understand the bug now. but i have to run because im late because of real life stuff. i'll do another blind fix when i have some time to check the code properly because ideally i would like to rewrote this function that looks like crap and ive seen some sketchy things. thanks for your patience and testing. i wish i could repro too. i tried with static analyzers and no luck there. but i think theres a logic bug in this mess |
Can you git pull and try again with master? i think i fixed the calloc(0) issue |
sent you email.
I will try |
https://copr.fedorainfracloud.org/coprs/rebus/infosec/build/5707264/
Backtrace from gsb:
Running with Valgrind again prevents the segfault:
|
Can you try again? i think that i managed to repro after cleaning up some code in the parser.. still far from ideal, but I hope i hit the nail now :3 |
OK ... not able to reproduce and valgrind is clean. Solved, thank you. |
tested with 70a78f0 |
i found the reason why asan build didnt catched this and also found the
root cause for a couple of similar issues that are now fixed too :)
I guess you'll need another release to package it properly, right? i would
like to do some more work on before 5.8.6, but im aware this was an
important problem
thanks for reporting!
…On Tue, Mar 28, 2023 at 5:53 PM Michal Ambroz ***@***.***> wrote:
tested with 70a78f0
<70a78f0>
—
Reply to this email directly, view it on GitHub
<#21491 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABRCGG7LTEBC2G2V2SM2MDTW6MCOJANCNFSM6AAAAAAV5XZ6BI>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
That is so cool .. thank you.
Thank you, release would be preferable, but I understand you have also other things to fix. As packager I have got options to go with git snapshot or cherry-pick individual patches as well. I have already pushed the Fedora Rawhide branch and planned F38 with the mentioned git snapshot 70a78f0 For the supported Fedora branches I plan to wait for the 5.8.6 release, if it is not too far. |
There are a bunch of important fixes and i'll try to push for more fixes and improvements to make the new release in about a month. Usually releases depend on features or issues being fixed. Im doing good progress lately and that wont be the last release for this abi seasson. So depending on my spare time and contributors i hope to get this done in time for you 👍 |
Environment
2023-03-16T18:35:36 CET
radare2 5.8.4 0 @ linux-x86-64 git.5.8.4
commit: unknown build: 2023-03-16__00:00:00
Linux x86_64
Description
Issuing "radare2 /bin/false" immediately segfaults in sdb_hash.
It is not case with all binaries. For example opening /bin/bash is OK in Fedora37.
Test
radare2 5.8.4 compiled with meson - https://copr.fedorainfracloud.org/coprs/rebus/infosec/build/5651283/
/bin/false from coreutils-9.1-7.fc37.x86_64 - https://koji.fedoraproject.org/koji/buildinfo?buildID=2105770
The text was updated successfully, but these errors were encountered: