mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #798] User defined signal 2 (core dumped) with --fork #415
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#415
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @frank-dittrich on GitHub (Oct 9, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/798
When I try to repeat the "insanely high number of forked processes" test from https://github.com/magnumripper/JohnTheRipper/issues/797 with bleeding-jumbo, commit
379881a01a, on the same 1 GB Memory, 2 GP swap 32bit linux system (legacy build), I get:It isn't really a surprize that jumbo is more than 10 times larger than core.
(make -s -j 4 -f Makefile.legacy linux-x86-sse2, but an autoconf build behaves in a similar way.
Now you know why I used "su - fd" here. Without it, the terminal would just have disappeared without a chance to see the "User defined signal 2 (core dumped)" output.
BTW, this is probably not related to issue #758, because I can reproduce it with sapb and other formats.
In a second try with sapb, the --fork=32 run crashed.
Another try with LM and --nolog:
I am sure I have seen that problem on 64bit linux as well (with less than 50 forked processes, but now I am not able to reproduce it even with --fork up to 500.
(EDIT: meanwhile I managed to reprocude it on 64bit, see next comment!)
OK, another 32bit linux test, this time after moving almost all plugin formats somewhere else:
The binary is still several times larger than core.
And finally, a stripped-down 32bit linux autoconf (non-OMP) build:
So that didn't really help.
@frank-dittrich commented on GitHub (Oct 9, 2014):
After disabling the 2 GB swap (swapoff -a), I repeated the test:
In another terminal, I verified (with top -d 0.4) that there were several hundred MB of free memory.
@frank-dittrich commented on GitHub (Oct 9, 2014):
Now I was able to reproduce tis with 64bit linux on a system with 8 GB memory, 6 GB swap, booted from a 64 GB USB 3.0 stick
@frank-dittrich commented on GitHub (Oct 10, 2014):
Finally, a clue:
With this change, the error disappears:
@magnumripper commented on GitHub (Oct 10, 2014):
OSX does up to some 12-13 forks (CPU has 4+HT), beyond that it crashes with no message. Disabling pot sync does not matter. My ulimits are this:
@frank-dittrich commented on GitHub (Oct 10, 2014):
On 10/11/2014 12:59 AM, magnum wrote:
That's why I used
first, and then ran john.
Otherwise, it would have killed the terminal without any message.
Now, only the su is killed, and I see the message.
@magnumripper commented on GitHub (Oct 11, 2014):
I did
su - magnumbut it really crashed with no message. But now I found an alternative way. Skip thesuand just doThe only difference with
ReloadAtCrack = Nis it dies at 12 instead of 13. SettingReloadAtSave = Ydoesn't make a difference in either case.So indeed it's signal 2 even under OSX. And I wonder what the
31means. That figure doesn't change.@magnumripper commented on GitHub (Oct 11, 2014):
Ah, I see the problem. There is some race condition. We use SIGUSR2 for certain signalling and it's not restored quick enough so it falls back to the default signal handler. So this bug is a real bug.
@magnumripper commented on GitHub (Oct 11, 2014):
I really thought
479a6eawould fix it, but it didn't. BTW this is a very un-natural race condition but I'd like to see a fix nonetheless.@magnumripper commented on GitHub (Oct 11, 2014):
I believe
3b4c29fmitigates it as much as at all possible. Theoretically we might still get a race condition but it's probably very far fetched. I tried it up to 350 forks before I grew tired of watching.@frank-dittrich commented on GitHub (Oct 11, 2014):
On 10/11/2014 02:22 AM, magnum wrote:
I also wonder why I always get $? = 140:
So far, I didn't find the 140 in some errno.h include.
@frank-dittrich commented on GitHub (Oct 11, 2014):
It appears you didn't wait long enough. I still get that error with latest commit:
Not that --fork=657 would be reasonable on a dual core system .
@magnumripper commented on GitHub (Oct 11, 2014):
Does
6b6e263make it better? I think that commit is pushing it to the limit: What more can I do other than block SIGUSR2 the first thing in main() and right after forking a child?@magnumripper commented on GitHub (Oct 11, 2014):
The below explains the 31 except for the fact I am not running an Alpha or Sparc (it should be 12 for intel)
http://unixhelp.ed.ac.uk/CGI/man-cgi?signal+7
@frank-dittrich commented on GitHub (Oct 11, 2014):
I'll test your latest comit.
Can you also ignore SUGUSR2 before forking?
Just an idea I got while googling for "sighup fork":
https://github.com/Supervisor/supervisor/issues/180
@frank-dittrich commented on GitHub (Oct 11, 2014):
Oh, I think you already do ignore SIGUSR2 it in main()...
@frank-dittrich commented on GitHub (Oct 11, 2014):
On 10/11/2014 02:49 PM, magnum wrote:
Unfortunately, not really:
$ (for i in
seq 600 999; do echo -n "$i "; rm john.pot; ./john--wordlist=../test/pw.dic ../test/LM_tst.in --format=lm --fork=${i}
--nolog > /dev/null 2> /dev/null; done); echo $?
600 rm: cannot remove ‘john.pot’: No such file or directory
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
673 674 675 676 677 678 679 680 681 User defined signal 2
140
@frank-dittrich commented on GitHub (Oct 11, 2014):
On 10/11/2014 12:59 AM, magnum wrote:
Now that we know that the SIGUSR2 race condition is the problem: Where
does that SIGTUSR2 come from if pot sync is disabled?
@magnumripper commented on GitHub (Oct 11, 2014):
USR2 is still raised whenever a child or MPI process is "done". It has to, that's the whole idea of it! I can't make it better without reverting to the old behavior where different processes kept trying to crack things already cracked. Note that this test of yours is extremely extreme: Not only are you over booking CPU with 32000%, all processes also find a crack for each candidate they try. And worst of all, you launch 600 processes with an extremely short life time. It's a wonder it works this good.
@frank-dittrich commented on GitHub (Oct 12, 2014):
With this john.local.conf
I don't have the "User defined signal 2 (core dumped) problem anymore.
I think I prefer it hat way.
I can still run
whenever I think it is appropriate.
Of course, the closer I get to the max --fork=1024, I still have the other problem of not all cracked hashes making it into the .pot file.
I guess it is just caused by the default ulimit of 1024 processes for a non-root user:
When I run the above as root, all these john runs create a pot file with 1500 unique lines.
@magnumripper commented on GitHub (Oct 12, 2014):
I need to revisit the machinery behind the "ReloadAtSave" parameter... it should work without any signalling, it should just check if size of pot file changed.
@magnumripper commented on GitHub (Oct 12, 2014):
I remembered correctly: The setting of ReloadAtSave should not affect sending or receiving of SIGUSR2 at all. I see nothing in the code, except the one case below, that would emit a SIGUSR2 with ReloadAtCrack = N.
The one place that will emit a SIGUSR2 with ReloadAtCrack = N is line 594-595 in john.c. But this is not affected by ReloadAtSave! Disregarding that, what if you comment that out and set ReloadAtSave = Y and ReloadAtCrack = N, is the problem still gone?
@frank-dittrich commented on GitHub (Oct 15, 2014):
You are right, ReloadAtSave = Y makes no difference here.
Not sure yet what changed since last time I could reproduce the problem.
(I tried with and without --nolog, and with redirecting stderr and stdout either to /dev/null or to regular files.)
@frank-dittrich commented on GitHub (Oct 15, 2014):
On 10/11/2014 07:46 PM, magnum wrote:
Why?
I consider this to be a bug.
When I want to disable pot syncs on cracked hashes, why would I want a
pot sync after 10 hours of run time when one of the processes might
finish several minutes earlier than the others, when I didn't care for
those first 10 hours of run time?
If I care, I could also use
$ killall -s USR1 john
either automatically every minute or manually whenever a significant
number of passwords has been found.
Not raising USR2 from the forked processes (unless ReloadAtCrack = Y)
would definitely eliminate this bug when a user sets ReloadAtCrack = N.
@magnumripper commented on GitHub (Oct 15, 2014):
Did you try to comment it out?
@frank-dittrich commented on GitHub (Oct 16, 2014):
OK, my stupid questions must have annoyed you.
I looked at the code and realized that you only raise SIGUSR2 when john is waiting for the remaining processes to finish and when there are no more passwords left to be cracked (so that other processes will know that there is no more work to do).
Before really looking at the code, I assumed you'd always raise SIGUSR2 when you wait for the other processes to finish, not just when there's nothing left to crack.
I agree that your approach makes sense. (I wouldn't want to keep several processes running when I was looking for just a single password which has already been found.)
There's really not much left what you could do to avoid the "User defined signal 2 (core dumped)" problem occurring under these extreme circumstances (huge number of forked processes, all the passwords are more or less immediately cracked).
I wouldn't want to wait an arbitrary number of seconds before raising SIGUSR.
But you could move that raise after the log_event() and fprintf(), and possibly even add an log_flush() and fflush(stderr) before raising SIGUSR2, i.e.
Otherwise, feel free to close this bug, as your other changes really helped to improve the situation.
@magnumripper commented on GitHub (Oct 16, 2014):
Hmm what difference does that make? OK, there could be less waiting for write lock if we do it first. And things might end up in better order in the log file. Sounds like a good idea. BTW stderr is not buffered so that flush should be redundant.
@magnumripper commented on GitHub (Oct 16, 2014):
Duh. "Closing #798" does not auto-close, "Closes #798" does.
@frank-dittrich commented on GitHub (Oct 16, 2014):
Now I think I found the real bug, and closing this issue was too early.
And I think it is a core bug, but it was just easier to trigger in jumbo.
Correct me if I'm wrong, but I think a forked process inherits signal handling from the parent process.
In john.c, in john_init(), we have the call to sig_init() before we call john_load().
john_load() calls john_fork(), and thus, the forked processes don't inherit the intended SIGUSR2 behavior.
I'll test with a changed john.c (just call sig_init() after john_load(), and report back.
I'll also try to find a way to trigger this bug in core.
@frank-dittrich commented on GitHub (Oct 16, 2014):
I think to allow users to safely use
and
on the command line, both SIGUSR1 and SIGUSR2 should be ignored first.
So, sig_preinit() should be changed to ignore SIGUSR1.
Only after john_load() is finished, both signals should be handled.
Or, alternatively, not after john_load(), but after john_fork().
@magnumripper commented on GitHub (Oct 17, 2014):
But there is a sig_init_child() called right after forking, no? I'm not so sure there is a core bug. In core, we are not supposed to send any USR2 to any process (the mother process may send it to its children, but with the meaning Jumbo has with USR1).
In core, we are also not supposed to send a USR1 to john. Only HUP. Core does not use USR1 for anything and will die if you send it that iirc.
BTWFYI, the reason Jumbo adds USR1 as an alternative to HUP, is that under MPI you can't send a HUP to mpirun - it will kill the job. Sending a USR1 will on the other hand be relayed to the nodes even if they are on remote hosts.
@magnumripper commented on GitHub (Oct 17, 2014):
After a fork(), all signals, the signal mask, the signal stack, and the restart/interrupt flags are inherited by the child. I think I have assumed otherwise but that doesn't hurt at all.
@frank-dittrich commented on GitHub (Oct 17, 2014):
OK, core is not affected.
And I noticed something interesting:
In my test with ReloadAtCrack = Y and ReloadAtSave = Y, even the --fork=682 session (which had the "User defined signal 2" problem) cracked all 1500 LM hashes.
And the log file has 682 "Session completed" lines
In another test, the "User defined signal 2" problem occurred for --fork=680.
Here, the pot file also had all the 1500 different hashes, and the expected 680 "Session completed" lines in the log file.
@magnumripper commented on GitHub (Nov 7, 2014):
In my humble opinion we should close this now ;-)
@frank-dittrich commented on GitHub (Nov 8, 2014):
Please give me at least 2 more days. I'm "working" on something, but I won't have enough time until Monday.
@frank-dittrich commented on GitHub (Nov 8, 2014):
Since I currently don't have access to the laptop where this problem occurs, I am reporting what I remenber from last time I tested this.
I noticed that the problem could be somewhat mitigated by either changing
Save = 60toSave = 62in john.conf or by changingif ((timer_save_value & 3) == 3) {toif ((timer_save_value & 7) == 7) {insig_handle_timer()insignals.c, because it increased the chance that john already finished cracking before all the SIGUSR2 signals occurred.Then I realized that the two comments
/* Some stuff only done every third second */insig_handle_timer()don't match what the code really does.For the !OS_TIMER case, the first signalling ocsurs after 3 seconds, then it occurs every 4 seconds.
For the OS_TIMER case, the first signalling depends on the value of
timer_save_interval(or theSave =setting in john.conf). Subsequent signals occur every 4 seconds, untiltimer_save_valuegets reset totimer_save_interval.This also means, with
Save = 2, there will never be a pot sync (except when the main process has no uncracked hashes remaining).So I'd suggest to adjust the comments and do the signalling every 4 seconds, but make sure that the first signalling only occurs after 4 seconds (not after 0 seconds).
And make sure that for the
OS_TIMERcase we signal every 4 seconds even if timer_save_interval is not a multiple of 4 (or even less than 4).Also, we should probably have as little code as possible depend on OS_TIMER and reuse more code for both the
OS_TIMERand!OS_TIMERcases.Unfortunately, I'll have no time to implement and test these changes right now.
@magnumripper commented on GitHub (Nov 9, 2014):
How about this
@frank-dittrich commented on GitHub (Nov 10, 2014):
So, for
timer_save_interval < 4, signalling happens every second.And if timer_save_interval is not a multiple of 4, you'll have an irregular pot sync interval once per timer_save_interval seconds.
Why do you think timer_save_value needs to depend on timer_save_interval at all?
@magnumripper commented on GitHub (Nov 10, 2014):
A time save interval less than four would probably be some kind of test run anyway.
I just wanted to keep it simple, and some irregularity is absolutely not an issue. I theory, each extra counter we add harms performance. In reality though, a counter updated once per second should not be distinguishable in profiling...
@magnumripper commented on GitHub (Mar 19, 2015):
Since the above, there is a new john.conf option
ReloadAtDone = Y. Now, if you set all three of those options toN, you will supposedly never send any USR2 signal and never sync the pot file. Normally, that is a bad idea but it might be good for debugging.I'm closing this. If some similar problem can still be triggered, please open a brand new issue.