Skip to content
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

Edb hangs or crashes on multi threads binary. #674

Open
edpil02 opened this Issue Sep 11, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@edpil02
Copy link

edpil02 commented Sep 11, 2018

Since update to version 1.0 and git , got hangs or crashes on some threads:
-> stop_threads(): paused thread [22233] received an event besides SIGSTOP: status=0x3057.
or or got a PTRACE_GETSIGINFO failed.
No issues with 0.9.xx versions.
Thanks and sorry for english.

@eteran

This comment has been minimized.

Copy link
Owner

eteran commented Sep 11, 2018

I assume when you say "crash", you don't mean that it segfaulted or aborted, but that it is "stuck"?

@edpil02

This comment has been minimized.

Copy link
Author

edpil02 commented Sep 12, 2018

Most of the time it stucks after some syscalls return (often syscall 0x38 or futex syscall). the menu keeps working, i can restart or kill the program but not keep on debugging.
Sometimes dmesg shows segfaults from RIP or ptrace errors:
-- enable to detach from thread 1956: PTRACE_DETACH failed
-- stop_threads(): paused thread [2020] received an event besides SIGSTOP: status=0x3057
-- PTRACE_GETSIGINFO failed.
Buildind latest git yesterday and disabling all signal/exception doesnt help.
So revert to 0.9 version with no issue.

@eteran

This comment has been minimized.

Copy link
Owner

eteran commented Sep 12, 2018

Interesting that 0.9 has no issue as there hasn't (shouldn't) been any fundamental changes to how things worked with regard to threads. Is there a program I can use to replicate it locally easily?

Or is it basically any threaded program?

Unfortunately, dealing with threads is a bit of a difficult task to get just right.

@edpil02

This comment has been minimized.

Copy link
Author

edpil02 commented Sep 13, 2018

With edb 1.0 you can catch or pass exceptions to many sig signals, not with 0.9 version, and i'm wondering if there is a problem in this feature.
I noticed it because before, the debugger stucks currently on SIGCHLD signals.Passing this signal with the "signals/exceptions" menu solves my problem but give threads issue.
Unfortunately i'm studying a close binary... I'll try to test some other programs.
Thanks for your help.

@eteran

This comment has been minimized.

Copy link
Owner

eteran commented Sep 14, 2018

I think I see the source of the issue... and it's complicated :-P.

I've reworked how exception ignoring works because it frankly made more sense to handle it at a lower level then we were. And I was able to resolve the hang as well.

However, there is still an issue:

Suppose there are 3 threads, and a SIGUSR1 comes in, a few things happen:

  1. we see the SIGUSR1 on a random thread, and track that thread calling it the "active thread"
  2. we send a SIGSTOP to the other 2 threads so that the whole process stops (this is what the user expects)
  3. this causes more events, which alters the "active thread"! (this is the underlying thing I need to fix)
  4. user (or debugger) says "resume, just pass that exception back to the debuggee
  5. we end up telling the "active thread" to resume with no signal, but sending the SIGUSR1 to the original thread... which ends up killing the process even if we wanted to ignore the exception.

I'll have to think a bit on how to address this, but whatever I come up with, should be able to address this issue and similar ones to it completely.

@edpil02

This comment has been minimized.

Copy link
Author

edpil02 commented Sep 14, 2018

"My binary" is a port of a windows program to linux.
Perhaps the code is crappy so .....
Thanks again.

@eteran

This comment has been minimized.

Copy link
Owner

eteran commented Sep 14, 2018

@edpil02, nothing to do with your code!

Unfortunately handling threads just right is just complicated. The have some ideas to experiment with which may deal with it well.

I'll keep this issue updated as I experiment

eteran added a commit that referenced this issue Sep 14, 2018

working on issue #674
reworked where in the event stack events are ignored if needed to make more sense
make some efforts to ensure that the "active thread" represents the one which triggered the event that the user sees
@eteran

This comment has been minimized.

Copy link
Owner

eteran commented Sep 14, 2018

@edpil02 Let me know if the latest in master works any better for you. I've definitely addressed some "quirks" that I was able to identify, and things seem stable in my quick and dirty tests. But things like this are hard to know for sure.

@edpil02

This comment has been minimized.

Copy link
Author

edpil02 commented Sep 15, 2018

Just tried latest git with the same binary:

  • The debugger doesnt stuck on syscall 0x38 now, but stop on a RT_SIGPROCMASK (that's weird) and Futex syscalls.Running again is possible too, but it stucks later with stop_threads(): paused thread errors.
    Seems to run smoother too.

-However when ignoring all signals exceptions with the preference menu, the debugger kills the program as soon as i run it .
Got a PTRACE_GETREGS failed error and the restart menu keeps ineffective.
I will try to ignore the exceptions one by one when i got more time for testing.

Thanks for your job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.