[GH-ISSUE #798] User defined signal 2 (core dumped) with --fork #415

Closed
opened 2026-10-14 03:06:02 +07:00 by bsakaguchi · 39 comments
Owner

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:

[fd@f20x32 run]$ ls -l john
-rwxrwxr-x. 1 fd fd 3159620 Oct  9 21:32 john

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.

[fd@f20x32 ~]$ su - fd
Password: 
Last login: Thu Oct  9 19:14:11 CEST 2014 on pts/1
[fd@f20x32 ~]$ cd git/JtR/run/
[fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot john.log ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i > /dev/null 2> /dev/null ; done
2 /bin/rm: cannot remove ‘john.pot’: No such file or directory
/bin/rm: cannot remove ‘john.log’: No such file or directory
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 User defined signal 2 (core dumped)
[fd@f20x32 ~]$ 
[fd@f20x32 ~]$ echo $?
140

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.

[fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot john.log ; sleep 1; ./john --format=sapb ../test/sapb_tst.in --wordlist=../test/pw.dic --fork=$i > /dev/null 2> /dev/null ; done
2 /bin/rm: cannot remove ‘john.pot’: No such file or directory
/bin/rm: cannot remove ‘john.log’: No such file or directory
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 User defined signal 2 (core dumped)

In a second try with sapb, the --fork=32 run crashed.

Another try with LM and --nolog:

[fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot  ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done
2 /bin/rm: cannot remove ‘john.pot’: No such file or directory
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 User defined signal 2 (core dumped)
[fd@f20x32 ~]$ 

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.

[fd@f20x32 run]$ ls -l john
-rwxrwxr-x. 1 fd fd 1791460 Oct  9 22:12 john
[fd@f20x32 run]$ ./john --list=formats
descrypt, bsdicrypt, md5crypt, bcrypt, scrypt, LM, AFS, tripcode, dummy, 
dynamic_n, nt2, crypt
[fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done 
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 User defined signal 2 (core dumped)

And finally, a stripped-down 32bit linux autoconf (non-OMP) build:

[fd@f20x32 run]$ ls -l john
-rwxrwxr-x. 1 fd fd 5824083 Oct  9 22:25 john
[fd@f20x32 run]$ ./john --list=formats
descrypt, bsdicrypt, md5crypt, bcrypt, scrypt, LM, AFS, tripcode, dummy, 
dynamic_n, NT, nt2, crypt
[fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done 
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 User defined signal 2 (core dumped)

So that didn't really help.

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 379881a01ae7ca04d77221efb025afdc8edb273e, on the same 1 GB Memory, 2 GP swap 32bit linux system (legacy build), I get: ``` [fd@f20x32 run]$ ls -l john -rwxrwxr-x. 1 fd fd 3159620 Oct 9 21:32 john ``` 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. ``` [fd@f20x32 ~]$ su - fd Password: Last login: Thu Oct 9 19:14:11 CEST 2014 on pts/1 [fd@f20x32 ~]$ cd git/JtR/run/ [fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot john.log ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i > /dev/null 2> /dev/null ; done 2 /bin/rm: cannot remove ‘john.pot’: No such file or directory /bin/rm: cannot remove ‘john.log’: No such file or directory 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 User defined signal 2 (core dumped) [fd@f20x32 ~]$ [fd@f20x32 ~]$ echo $? 140 ``` 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. ``` [fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot john.log ; sleep 1; ./john --format=sapb ../test/sapb_tst.in --wordlist=../test/pw.dic --fork=$i > /dev/null 2> /dev/null ; done 2 /bin/rm: cannot remove ‘john.pot’: No such file or directory /bin/rm: cannot remove ‘john.log’: No such file or directory 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 User defined signal 2 (core dumped) ``` In a second try with sapb, the --fork=32 run crashed. Another try with LM and --nolog: ``` [fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done 2 /bin/rm: cannot remove ‘john.pot’: No such file or directory 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 User defined signal 2 (core dumped) [fd@f20x32 ~]$ ``` 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. ``` [fd@f20x32 run]$ ls -l john -rwxrwxr-x. 1 fd fd 1791460 Oct 9 22:12 john [fd@f20x32 run]$ ./john --list=formats descrypt, bsdicrypt, md5crypt, bcrypt, scrypt, LM, AFS, tripcode, dummy, dynamic_n, nt2, crypt [fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 User defined signal 2 (core dumped) ``` And finally, a stripped-down 32bit linux autoconf (non-OMP) build: ``` [fd@f20x32 run]$ ls -l john -rwxrwxr-x. 1 fd fd 5824083 Oct 9 22:25 john [fd@f20x32 run]$ ./john --list=formats descrypt, bsdicrypt, md5crypt, bcrypt, scrypt, LM, AFS, tripcode, dummy, dynamic_n, NT, nt2, crypt [fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 User defined signal 2 (core dumped) ``` So that didn't really help.
bsakaguchi 2026-10-14 03:06:02 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@frank-dittrich commented on GitHub (Oct 9, 2014):

After disabling the 2 GB swap (swapoff -a), I repeated the test:

[fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done 
2 /bin/rm: cannot remove ‘john.pot’: No such file or directory
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 User defined signal 2 (core dumped)

In another terminal, I verified (with top -d 0.4) that there were several hundred MB of free memory.

<!-- gh-comment-id:58580797 --> @frank-dittrich commented on GitHub (Oct 9, 2014): After disabling the 2 GB swap (swapoff -a), I repeated the test: ``` [fd@f20x32 run]$ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm john.pot ; sleep 1; ./john --format=LM ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i --nolog > /dev/null 2> /dev/null ; done 2 /bin/rm: cannot remove ‘john.pot’: No such file or directory 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 User defined signal 2 (core dumped) ``` In another terminal, I verified (with top -d 0.4) that there were several hundred MB of free memory.
Author
Owner

@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

(bleeding-jumbo)run $ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm j1.pot; ./john --pot=j1.pot --session=j1 --nolog --format=lm ../test/LM_tst.in --wordlist=../test/pw.dic  --fork=$i > /dev/null 2> /dev/null; done
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 User defined signal 2 (core dumped)
(bleeding-jumbo)run $ 
$ ./john --list=build-info 
Version: 1.8.0.2-bleeding-jumbo
Build: linux-gnu 64-bit AVX-autoconf
Arch: 64-bit LE
$JOHN is ./
Format interface version: 12
Max. number of reported tunable costs: 3
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
Max. Markov mode level: 400
Max. Markov mode password length: 30
Compiler version: 4.8.3 20140911 (Red Hat 4.8.3-7)
gcc version: 4.8.3
OpenSSL library version: 01000105f
OpenSSL 1.0.1e-fips 11 Feb 2013
GMP library version: 5.1.2
NSS library version: 3.17.1 Basic ECC   (loaded: 3.17.1 Extended ECC)
NSPR library version: 4.10.7
Kerberos version 5 support enabled
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): System's
$ ls -l john
-rwxrwxr-x. 1 fd fd 15836608 Oct  9 23:22 john
<!-- gh-comment-id:58584484 --> @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 ``` (bleeding-jumbo)run $ for i in `seq 2 1500`; do echo -n "$i "; /bin/rm j1.pot; ./john --pot=j1.pot --session=j1 --nolog --format=lm ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i > /dev/null 2> /dev/null; done 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 User defined signal 2 (core dumped) (bleeding-jumbo)run $ ``` ``` $ ./john --list=build-info Version: 1.8.0.2-bleeding-jumbo Build: linux-gnu 64-bit AVX-autoconf Arch: 64-bit LE $JOHN is ./ Format interface version: 12 Max. number of reported tunable costs: 3 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 Max. Markov mode level: 400 Max. Markov mode password length: 30 Compiler version: 4.8.3 20140911 (Red Hat 4.8.3-7) gcc version: 4.8.3 OpenSSL library version: 01000105f OpenSSL 1.0.1e-fips 11 Feb 2013 GMP library version: 5.1.2 NSS library version: 3.17.1 Basic ECC (loaded: 3.17.1 Extended ECC) NSPR library version: 4.10.7 Kerberos version 5 support enabled fseek(): fseek ftell(): ftell fopen(): fopen memmem(): System's $ ls -l john -rwxrwxr-x. 1 fd fd 15836608 Oct 9 23:22 john ```
Author
Owner

@frank-dittrich commented on GitHub (Oct 10, 2014):

Finally, a clue:
With this change, the error disappears:

$ git diff
diff --git a/run/john.conf b/run/john.conf
index fc8e3f7..4b4799c 100644
--- a/run/john.conf
+++ b/run/john.conf
@@ -156,7 +156,7 @@ SecureMode = N
 # If set to Y, a session using --fork or MPI will signal to other nodes when
 # it has written cracks to the pot file (note that this writing is delayed
 # by buffers and the "Save" timer above), so they will re-sync.
-ReloadAtCrack = Y
+ReloadAtCrack = N

 # If set to Y, resync pot file when saving session.
 ReloadAtSave = Y
<!-- gh-comment-id:58722426 --> @frank-dittrich commented on GitHub (Oct 10, 2014): Finally, a clue: With this change, the error disappears: ``` $ git diff diff --git a/run/john.conf b/run/john.conf index fc8e3f7..4b4799c 100644 --- a/run/john.conf +++ b/run/john.conf @@ -156,7 +156,7 @@ SecureMode = N # If set to Y, a session using --fork or MPI will signal to other nodes when # it has written cracks to the pot file (note that this writing is delayed # by buffers and the "Save" timer above), so they will re-sync. -ReloadAtCrack = Y +ReloadAtCrack = N # If set to Y, resync pot file when saving session. ReloadAtSave = Y ```
Author
Owner

@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:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited
<!-- gh-comment-id:58726480 --> @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: ``` $ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 256 pipe size (512 bytes, -p) 1 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 709 virtual memory (kbytes, -v) unlimited ```
Author
Owner

@frank-dittrich commented on GitHub (Oct 10, 2014):

On 10/11/2014 12:59 AM, magnum wrote:

OSX does up to some 12-13 forks, beyond that it crashes with no message.

That's why I used

su - fd

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.

<!-- gh-comment-id:58727692 --> @frank-dittrich commented on GitHub (Oct 10, 2014): On 10/11/2014 12:59 AM, magnum wrote: > OSX does up to some 12-13 forks, beyond that it crashes with no message. That's why I used ``` su - fd ``` 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.
Author
Owner

@magnumripper commented on GitHub (Oct 11, 2014):

OSX does up to some 12-13 forks, beyond that it crashes with no message.

That's why I used

su - fd

I did su - magnum but it really crashed with no message. But now I found an alternative way. Skip the su and just do

$ (for i in `seq 2 1500`; do echo -n "$i "; rm -f j1.pot; ../run/john --pot=j1.pot --session=j1 --nolog --format=lm ../test/LM_tst.in --wordlist=../test/pw.dic  --fork=$i > /dev/null 2> /dev/null; done)
2 3 4 5 6 7 8 9 10 11 12 13 User defined signal 2: 31

The only difference with ReloadAtCrack = N is it dies at 12 instead of 13. Setting ReloadAtSave = Y doesn't make a difference in either case.

So indeed it's signal 2 even under OSX. And I wonder what the 31 means. That figure doesn't change.

<!-- gh-comment-id:58731322 --> @magnumripper commented on GitHub (Oct 11, 2014): > > OSX does up to some 12-13 forks, beyond that it crashes with no message. > > That's why I used > > ``` > su - fd > ``` I did `su - magnum` but it really crashed with no message. But now I found an alternative way. Skip the `su` and just do ``` $ (for i in `seq 2 1500`; do echo -n "$i "; rm -f j1.pot; ../run/john --pot=j1.pot --session=j1 --nolog --format=lm ../test/LM_tst.in --wordlist=../test/pw.dic --fork=$i > /dev/null 2> /dev/null; done) 2 3 4 5 6 7 8 9 10 11 12 13 User defined signal 2: 31 ``` The only difference with `ReloadAtCrack = N` is it dies at 12 instead of 13. Setting `ReloadAtSave = Y` doesn't make a difference in either case. So indeed it's signal 2 even under OSX. And I wonder what the `31` means. That figure doesn't change.
Author
Owner

@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.

<!-- gh-comment-id:58731582 --> @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.
Author
Owner

@magnumripper commented on GitHub (Oct 11, 2014):

I really thought 479a6ea would fix it, but it didn't. BTW this is a very un-natural race condition but I'd like to see a fix nonetheless.

<!-- gh-comment-id:58732748 --> @magnumripper commented on GitHub (Oct 11, 2014): I really thought 479a6ea would fix it, but it didn't. BTW this is a very un-natural race condition but I'd like to see a fix nonetheless.
Author
Owner

@magnumripper commented on GitHub (Oct 11, 2014):

I believe 3b4c29f mitigates 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.

<!-- gh-comment-id:58733585 --> @magnumripper commented on GitHub (Oct 11, 2014): I believe 3b4c29f mitigates 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.
Author
Owner

@frank-dittrich commented on GitHub (Oct 11, 2014):

On 10/11/2014 02:22 AM, magnum wrote:

And I wonder what the 31 means. That figure doesn't change.

I also wonder why I always get $? = 140:

$ (for i in `seq 3 50`; do echo -n "$i "; rm john.pot john.log; ./john
--wordlist=../test/pw.dic ../test/LM_tst.in --format=lm --fork=$i >
/dev/null 2> /dev/null; done); echo $?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
User defined signal 2
140

So far, I didn't find the 140 in some errno.h include.

<!-- gh-comment-id:58742764 --> @frank-dittrich commented on GitHub (Oct 11, 2014): On 10/11/2014 02:22 AM, magnum wrote: > And I wonder what the `31` means. That figure doesn't change. I also wonder why I always get $? = 140: ``` $ (for i in `seq 3 50`; do echo -n "$i "; rm john.pot john.log; ./john --wordlist=../test/pw.dic ../test/LM_tst.in --format=lm --fork=$i > /dev/null 2> /dev/null; done); echo $? 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 User defined signal 2 140 ``` So far, I didn't find the 140 in some errno.h include.
Author
Owner

@frank-dittrich commented on GitHub (Oct 11, 2014):

It appears you didn't wait long enough. I still get that error with latest commit:

$ (for i in `seq 650 999`; do echo -n "$i "; rm john.pot john.log; ./john --wordlist=../test/pw.dic ../test/LM_tst.in --format=lm --fork=${i} > /dev/null 2> /dev/null; done); echo $?
650 rm: cannot remove ‘john.pot’: No such file or directory
rm: cannot remove ‘john.log’: No such file or directory
651 652 653 654 655 656 657 User defined signal 2
140

Not that --fork=657 would be reasonable on a dual core system .

<!-- gh-comment-id:58744353 --> @frank-dittrich commented on GitHub (Oct 11, 2014): It appears you didn't wait long enough. I still get that error with latest commit: ``` $ (for i in `seq 650 999`; do echo -n "$i "; rm john.pot john.log; ./john --wordlist=../test/pw.dic ../test/LM_tst.in --format=lm --fork=${i} > /dev/null 2> /dev/null; done); echo $? 650 rm: cannot remove ‘john.pot’: No such file or directory rm: cannot remove ‘john.log’: No such file or directory 651 652 653 654 655 656 657 User defined signal 2 140 ``` Not that --fork=657 would be reasonable on a dual core system .
Author
Owner

@magnumripper commented on GitHub (Oct 11, 2014):

Does 6b6e263 make 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?

<!-- gh-comment-id:58748436 --> @magnumripper commented on GitHub (Oct 11, 2014): Does 6b6e263 make 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?
Author
Owner

@magnumripper commented on GitHub (Oct 11, 2014):

And I wonder what the 31 means. That figure doesn't change.

I also wonder why I always get $? = 140:

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

  Standard Signals
       Linux supports the standard signals listed below. Several  signal  num-
       bers  are  architecture  dependent, as indicated in the "Value" column.
       (Where three values are given, the first one is usually valid for alpha
       and  sparc,  the  middle one for i386, ppc and sh, and the last one for
       mips.  A - denotes that a signal is absent on the corresponding  archi-
       tecture.)

       First the signals described in the original POSIX.1-1990 standard.

       Signal     Value     Action   Comment
       -------------------------------------------------------------------------
       SIGHUP        1       Term    Hangup detected on controlling terminal
                     or death of controlling process
       SIGINT        2       Term    Interrupt from keyboard
       SIGQUIT       3       Core    Quit from keyboard
       SIGILL        4       Core    Illegal Instruction
       SIGABRT       6       Core    Abort signal from abort(3)
       SIGFPE        8       Core    Floating point exception
       SIGKILL       9       Term    Kill signal
       SIGSEGV      11       Core    Invalid memory reference
       SIGPIPE      13       Term    Broken pipe: write to pipe with no readers
       SIGALRM      14       Term    Timer signal from alarm(2)
       SIGTERM      15       Term    Termination signal
       SIGUSR1   30,10,16    Term    User-defined signal 1
       SIGUSR2   31,12,17    Term    User-defined signal 2
       SIGCHLD   20,17,18    Ign     Child stopped or terminated
       SIGCONT   19,18,25    Cont    Continue if stopped
       SIGSTOP   17,19,23    Stop    Stop process
       SIGTSTP   18,20,24    Stop    Stop typed at tty
       SIGTTIN   21,21,26    Stop    tty input for background process
       SIGTTOU   22,22,27    Stop    tty output for background process

       The  signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.
<!-- gh-comment-id:58748666 --> @magnumripper commented on GitHub (Oct 11, 2014): > > And I wonder what the `31` means. That figure doesn't change. > > I also wonder why I always get $? = 140: 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 ``` Standard Signals Linux supports the standard signals listed below. Several signal num- bers are architecture dependent, as indicated in the "Value" column. (Where three values are given, the first one is usually valid for alpha and sparc, the middle one for i386, ppc and sh, and the last one for mips. A - denotes that a signal is absent on the corresponding archi- tecture.) First the signals described in the original POSIX.1-1990 standard. Signal Value Action Comment ------------------------------------------------------------------------- SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 Term Interrupt from keyboard SIGQUIT 3 Core Quit from keyboard SIGILL 4 Core Illegal Instruction SIGABRT 6 Core Abort signal from abort(3) SIGFPE 8 Core Floating point exception SIGKILL 9 Term Kill signal SIGSEGV 11 Core Invalid memory reference SIGPIPE 13 Term Broken pipe: write to pipe with no readers SIGALRM 14 Term Timer signal from alarm(2) SIGTERM 15 Term Termination signal SIGUSR1 30,10,16 Term User-defined signal 1 SIGUSR2 31,12,17 Term User-defined signal 2 SIGCHLD 20,17,18 Ign Child stopped or terminated SIGCONT 19,18,25 Cont Continue if stopped SIGSTOP 17,19,23 Stop Stop process SIGTSTP 18,20,24 Stop Stop typed at tty SIGTTIN 21,21,26 Stop tty input for background process SIGTTOU 22,22,27 Stop tty output for background process The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored. ```
Author
Owner

@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

<!-- gh-comment-id:58749088 --> @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
Author
Owner

@frank-dittrich commented on GitHub (Oct 11, 2014):

Oh, I think you already do ignore SIGUSR2 it in main()...

<!-- gh-comment-id:58749117 --> @frank-dittrich commented on GitHub (Oct 11, 2014): Oh, I think you already do ignore SIGUSR2 it in main()...
Author
Owner

@frank-dittrich commented on GitHub (Oct 11, 2014):

On 10/11/2014 02:49 PM, magnum wrote:

Does 6b6e263 make it better?

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

<!-- gh-comment-id:58749713 --> @frank-dittrich commented on GitHub (Oct 11, 2014): On 10/11/2014 02:49 PM, magnum wrote: > Does 6b6e263 make it better? 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
Author
Owner

@frank-dittrich commented on GitHub (Oct 11, 2014):

On 10/11/2014 12:59 AM, magnum wrote:

OSX does up to some 12-13 forks, beyond that it crashes with no
message. Disabling pot sync does not matter.

Now that we know that the SIGUSR2 race condition is the problem: Where
does that SIGTUSR2 come from if pot sync is disabled?

<!-- gh-comment-id:58750995 --> @frank-dittrich commented on GitHub (Oct 11, 2014): On 10/11/2014 12:59 AM, magnum wrote: > OSX does up to some 12-13 forks, beyond that it crashes with no > message. Disabling pot sync does not matter. Now that we know that the SIGUSR2 race condition is the problem: Where does that SIGTUSR2 come from if pot sync is disabled?
Author
Owner

@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.

<!-- gh-comment-id:58758021 --> @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.
Author
Owner

@frank-dittrich commented on GitHub (Oct 12, 2014):

With this john.local.conf

[Local:Options]
ReloadAtCrack = N
ReloadAtSave = N

I don't have the "User defined signal 2 (core dumped) problem anymore.
I think I prefer it hat way.

I can still run

$ killall -s USR2 john

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.

 $ (for i in `seq 1020 1024`; do echo -n -e "$i\t"; echo $i > i.txt; /bin/rm john.pot; ./john --wordlist=../test/pw.dic ../test/LM_tst.in --format=lm --fork=${i} --session=t-$i > stdout-$i.txt 2> stderr-$i.txt; LC_ALL=C sort -u john.pot | wc -l; done |LC_ALL=C grep -v 1500 ); echo $?
/bin/rm: cannot remove ‘john.pot’: No such file or directory
bash: fork: retry: Resource temporarily unavailable
1020    174
bash: fork: retry: Resource temporarily unavailable
1021    32
1022    53
1023    15
1024    16

I guess it is just caused by the default ulimit of 1024 processes for a non-root user:

$ grep error t-102*.log
t-1020.log:1 0:00:00:00 Terminating on error, john.c:496
t-1020.log:1 0:00:00:00 Terminating on error, john.c:496
t-1021.log:1 0:00:00:00 Terminating on error, john.c:496
t-1021.log:1 0:00:00:00 Terminating on error, john.c:496
t-1022.log:1 0:00:00:00 Terminating on error, john.c:496
t-1022.log:1 0:00:00:00 Terminating on error, john.c:496
t-1023.log:1 0:00:00:00 Terminating on error, john.c:496
t-1023.log:1 0:00:00:00 Terminating on error, john.c:496
t-1024.log:1 0:00:00:00 Terminating on error, john.c:496
t-1024.log:1 0:00:00:00 Terminating on error, john.c:496

When I run the above as root, all these john runs create a pot file with 1500 unique lines.

<!-- gh-comment-id:58810805 --> @frank-dittrich commented on GitHub (Oct 12, 2014): With this john.local.conf ``` [Local:Options] ReloadAtCrack = N ReloadAtSave = N ``` I don't have the "User defined signal 2 (core dumped) problem anymore. I think I prefer it hat way. I can still run ``` $ killall -s USR2 john ``` 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. ``` $ (for i in `seq 1020 1024`; do echo -n -e "$i\t"; echo $i > i.txt; /bin/rm john.pot; ./john --wordlist=../test/pw.dic ../test/LM_tst.in --format=lm --fork=${i} --session=t-$i > stdout-$i.txt 2> stderr-$i.txt; LC_ALL=C sort -u john.pot | wc -l; done |LC_ALL=C grep -v 1500 ); echo $? /bin/rm: cannot remove ‘john.pot’: No such file or directory bash: fork: retry: Resource temporarily unavailable 1020 174 bash: fork: retry: Resource temporarily unavailable 1021 32 1022 53 1023 15 1024 16 ``` I guess it is just caused by the default ulimit of 1024 processes for a non-root user: ``` $ grep error t-102*.log t-1020.log:1 0:00:00:00 Terminating on error, john.c:496 t-1020.log:1 0:00:00:00 Terminating on error, john.c:496 t-1021.log:1 0:00:00:00 Terminating on error, john.c:496 t-1021.log:1 0:00:00:00 Terminating on error, john.c:496 t-1022.log:1 0:00:00:00 Terminating on error, john.c:496 t-1022.log:1 0:00:00:00 Terminating on error, john.c:496 t-1023.log:1 0:00:00:00 Terminating on error, john.c:496 t-1023.log:1 0:00:00:00 Terminating on error, john.c:496 t-1024.log:1 0:00:00:00 Terminating on error, john.c:496 t-1024.log:1 0:00:00:00 Terminating on error, john.c:496 ``` When I run the above as root, all these john runs create a pot file with 1500 unique lines.
Author
Owner

@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.

<!-- gh-comment-id:58822059 --> @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.
Author
Owner

@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?

<!-- gh-comment-id:58823190 --> @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?
Author
Owner

@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.)

<!-- gh-comment-id:59182736 --> @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.)
Author
Owner

@frank-dittrich commented on GitHub (Oct 15, 2014):

On 10/11/2014 07:46 PM, magnum wrote:

USR2 is still raised whenever a child or MPI process is "done". It has to, that's the whole idea of it!

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.

<!-- gh-comment-id:59184434 --> @frank-dittrich commented on GitHub (Oct 15, 2014): On 10/11/2014 07:46 PM, magnum wrote: > USR2 is still raised whenever a child or MPI process is "done". It has to, that's the whole idea of it! 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.
Author
Owner

@magnumripper commented on GitHub (Oct 15, 2014):

what if you comment that out and set ReloadAtSave = Y and ReloadAtCrack = N, is the problem still gone?

Not raising USR2 from the forked processes (unless ReloadAtCrack = Y) would definitely eliminate this bug when a user sets ReloadAtCrack = N.

Did you try to comment it out?

<!-- gh-comment-id:59263768 --> @magnumripper commented on GitHub (Oct 15, 2014): > > what if you comment that out and set ReloadAtSave = Y and ReloadAtCrack = N, is the problem still gone? > > Not raising USR2 from the forked processes (unless ReloadAtCrack = Y) would definitely eliminate this bug when a user sets ReloadAtCrack = N. Did you try to comment it out?
Author
Owner

@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.

diff --git a/src/john.c b/src/john.c
index 20316b5..adaa6b4 100644
--- a/src/john.c
+++ b/src/john.c
@@ -591,14 +591,17 @@ static void john_wait(void)
 {
    int waiting_for = john_child_count;

-   if (!database.password_count && !options.reload_at_crack)
-       raise(SIGUSR2);
-
    log_event("Waiting for %d child%s to terminate",
        waiting_for, waiting_for == 1 ? "" : "ren");
    fprintf(stderr, "Waiting for %d child%s to terminate\n",
        waiting_for, waiting_for == 1 ? "" : "ren");

+   log_flush();
+   fflush(stderr);
+
+   if (!database.password_count && !options.reload_at_crack)
+       raise(SIGUSR2);
+
 /*
  * Although we may block on wait(2), we still have signal handlers and a timer
  * in place, so we're relaying keypresses to child processes via signals.

Otherwise, feel free to close this bug, as your other changes really helped to improve the situation.

<!-- gh-comment-id:59346593 --> @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. ``` diff --git a/src/john.c b/src/john.c index 20316b5..adaa6b4 100644 --- a/src/john.c +++ b/src/john.c @@ -591,14 +591,17 @@ static void john_wait(void) { int waiting_for = john_child_count; - if (!database.password_count && !options.reload_at_crack) - raise(SIGUSR2); - log_event("Waiting for %d child%s to terminate", waiting_for, waiting_for == 1 ? "" : "ren"); fprintf(stderr, "Waiting for %d child%s to terminate\n", waiting_for, waiting_for == 1 ? "" : "ren"); + log_flush(); + fflush(stderr); + + if (!database.password_count && !options.reload_at_crack) + raise(SIGUSR2); + /* * Although we may block on wait(2), we still have signal handlers and a timer * in place, so we're relaying keypresses to child processes via signals. ``` Otherwise, feel free to close this bug, as your other changes really helped to improve the situation.
Author
Owner

@magnumripper commented on GitHub (Oct 16, 2014):

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.

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.

<!-- gh-comment-id:59404598 --> @magnumripper commented on GitHub (Oct 16, 2014): > 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. 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.
Author
Owner

@magnumripper commented on GitHub (Oct 16, 2014):

Duh. "Closing #798" does not auto-close, "Closes #798" does.

<!-- gh-comment-id:59406037 --> @magnumripper commented on GitHub (Oct 16, 2014): Duh. "Closing #798" does not auto-close, "Closes #798" does.
Author
Owner

@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.

<!-- gh-comment-id:59435804 --> @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.
Author
Owner

@frank-dittrich commented on GitHub (Oct 16, 2014):

I think to allow users to safely use

killall -s USR1 john

and

killall -s USR2 john

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().

<!-- gh-comment-id:59438354 --> @frank-dittrich commented on GitHub (Oct 16, 2014): I think to allow users to safely use ``` killall -s USR1 john ``` and ``` killall -s USR2 john ``` 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().
Author
Owner

@magnumripper commented on GitHub (Oct 17, 2014):

john_load() calls john_fork(), and thus, the forked processes don't inherit the intended SIGUSR2 behavior.

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).

I think to allow users to safely use
killall -s USR1 john

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.

<!-- gh-comment-id:59469519 --> @magnumripper commented on GitHub (Oct 17, 2014): > john_load() calls john_fork(), and thus, the forked processes don't inherit the intended SIGUSR2 behavior. 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). > I think to allow users to safely use > `killall -s USR1 john` 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.
Author
Owner

@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.

<!-- gh-comment-id:59470207 --> @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.
Author
Owner

@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.

<!-- gh-comment-id:59502235 --> @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.
Author
Owner

@magnumripper commented on GitHub (Nov 7, 2014):

In my humble opinion we should close this now ;-)

<!-- gh-comment-id:62232250 --> @magnumripper commented on GitHub (Nov 7, 2014): In my humble opinion we should close this now ;-)
Author
Owner

@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.

<!-- gh-comment-id:62253252 --> @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.
Author
Owner

@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 = 60 to Save = 62 in john.conf or by changing if ((timer_save_value & 3) == 3) { to if ((timer_save_value & 7) == 7) { in sig_handle_timer() in signals.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 */ in sig_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 the Save = setting in john.conf). Subsequent signals occur every 4 seconds, until timer_save_value gets reset to timer_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_TIMER case 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_TIMER and !OS_TIMER cases.

Unfortunately, I'll have no time to implement and test these changes right now.

<!-- gh-comment-id:62255190 --> @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 = 60` to `Save = 62` in john.conf or by changing `if ((timer_save_value & 3) == 3) {` to `if ((timer_save_value & 7) == 7) {` in `sig_handle_timer()` in `signals.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 */` in `sig_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 the `Save =` setting in john.conf). Subsequent signals occur every 4 seconds, until `timer_save_value` gets reset to `timer_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_TIMER` case 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_TIMER` and `!OS_TIMER` cases. Unfortunately, I'll have no time to implement and test these changes right now.
Author
Owner

@magnumripper commented on GitHub (Nov 9, 2014):

How about this

diff --git a/src/signals.c b/src/signals.c
index 2e6a482..44a6a30 100644
--- a/src/signals.c
+++ b/src/signals.c
@@ -269,8 +269,9 @@ static void sig_handle_timer(int signum)
 #endif
 #ifndef BENCH_BUILD
 #if OS_TIMER
-       /* Some stuff only done every third second */
-       if ((timer_save_value & 3) == 3) {
+       /* Some stuff only done every few seconds */
+       if (timer_save_interval < 4 ||
+           ((timer_save_interval - timer_save_value) & 3) == 3) {
 #ifdef HAVE_MPI
                if (!event_reload && mpi_p > 1) {
                        event_pending = event_mpiprobe = 1;
@@ -298,7 +299,7 @@ static void sig_handle_timer(int signum)
 #else /* no OS_TIMER */
        time = status_get_time();

-       /* Some stuff only done every third second */
+       /* Some stuff only done every few seconds */
        if ((time & 3) == 3) {
 #ifdef HAVE_MPI
                if (!event_reload && mpi_p > 1) {
<!-- gh-comment-id:62325144 --> @magnumripper commented on GitHub (Nov 9, 2014): How about this ``` diff --git a/src/signals.c b/src/signals.c index 2e6a482..44a6a30 100644 --- a/src/signals.c +++ b/src/signals.c @@ -269,8 +269,9 @@ static void sig_handle_timer(int signum) #endif #ifndef BENCH_BUILD #if OS_TIMER - /* Some stuff only done every third second */ - if ((timer_save_value & 3) == 3) { + /* Some stuff only done every few seconds */ + if (timer_save_interval < 4 || + ((timer_save_interval - timer_save_value) & 3) == 3) { #ifdef HAVE_MPI if (!event_reload && mpi_p > 1) { event_pending = event_mpiprobe = 1; @@ -298,7 +299,7 @@ static void sig_handle_timer(int signum) #else /* no OS_TIMER */ time = status_get_time(); - /* Some stuff only done every third second */ + /* Some stuff only done every few seconds */ if ((time & 3) == 3) { #ifdef HAVE_MPI if (!event_reload && mpi_p > 1) { ```
Author
Owner

@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?

<!-- gh-comment-id:62463024 --> @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?
Author
Owner

@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...

<!-- gh-comment-id:62474053 --> @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...
Author
Owner

@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 to N, 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.

<!-- gh-comment-id:83763650 --> @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 to `N`, 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#415
No description provided.