[GH-ISSUE #2068] Crash recovery file is locked #1386

Closed
opened 2026-10-14 03:46:54 +07:00 by bsakaguchi · 30 comments
Owner

Originally created by @blackboxbandit-zz on GitHub (Feb 26, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2068

I've compiled john on cygwin (x64). When i run john with the --fork option, the process doesnt seem to cleanly exit if

  1. i have killed the session using Ctrl-C or
  2. John completes the iteration

and as a result the crash files arent removed. This is a bit annoying when you have john running from a bash script

Im running
john.exe hashes.txt --format=lm --mask=?u?u?u?u?d?d?d --session=SSSF ; stty sane

its running fine without the fork option

John version:
$ ./john.exe
John the Ripper 1.8.0.6-jumbo-1-2087-g35996d5+ OMP [cygwin 64-bit AVX2-ac]

Originally created by @blackboxbandit-zz on GitHub (Feb 26, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2068 I've compiled john on cygwin (x64). When i run john with the --fork option, the process doesnt seem to cleanly exit if 1) i have killed the session using Ctrl-C or 2) John completes the iteration and as a result the crash files arent removed. This is a bit annoying when you have john running from a bash script Im running john.exe hashes.txt --format=lm --mask=?u?u?u?u?d?d?d --session=SSSF ; stty sane its running fine without the fork option John version: $ ./john.exe John the Ripper 1.8.0.6-jumbo-1-2087-g35996d5+ OMP [cygwin 64-bit AVX2-ac]
bsakaguchi 2026-10-14 03:46:54 +07:00
Author
Owner

@jfoug commented on GitHub (Feb 26, 2016):

There has been some work on cygwin and record locking.

Btw, I just pushed a commit that gets rid of the need for fixing stty after a -fork run.

github.com/magnumripper/JohnTheRipper@81e0cce630

<!-- gh-comment-id:189361957 --> @jfoug commented on GitHub (Feb 26, 2016): There has been some work on cygwin and record locking. Btw, I just pushed a commit that gets rid of the need for fixing stty after a -fork run. https://github.com/magnumripper/JohnTheRipper/commit/81e0cce6303cbea87420ccd70151f0779857b564
Author
Owner

@magnumripper commented on GitHub (Mar 2, 2016):

I'm not sure all signaling is in place in Cygwin. If you press a key for status while running forked, are you getting a status print from each process? Or, if you press 'q' for quitting a forked run - does that work differently from using ctrl-c?

<!-- gh-comment-id:191399748 --> @magnumripper commented on GitHub (Mar 2, 2016): I'm not sure all signaling is in place in Cygwin. If you press a key for status while running forked, are you getting a status print from each process? Or, if you press 'q' for quitting a forked run - does that work differently from using ctrl-c?
Author
Owner

@jfoug commented on GitHub (Mar 2, 2016):

if you press a key for status while running forked, are you getting a status print from each process?

yes

Or, if you press 'q' for quitting a forked run - does that work differently from using ctrl-c?

Nope. Both methods work properly and same result. Clean exit.

<!-- gh-comment-id:191463027 --> @jfoug commented on GitHub (Mar 2, 2016): > if you press a key for status while running forked, are you getting a status print from each process? yes > Or, if you press 'q' for quitting a forked run - does that work differently from using ctrl-c? Nope. Both methods work properly and same result. Clean exit.
Author
Owner

@blackboxbandit-zz commented on GitHub (Mar 3, 2016):

I've noticed that i do not need to stty, in the new version. Thanks for fixing that!

/john.exe --format=NT-old NT.out --wordlist=../../../wordlists/eNtr0pY_ALL_sort_uniq.dic --rules --fork=8;

5 0g 0:00:01:09 DONE (2016-03-03 08:54) 0g/s 2621Kp/s 2621Kc/s 18055MC/s Zzzrzzzing..Zzzzzzzzzzzzzzzzing 6 0g 0:00:01:10 DONE (2016-03-03 08:54) 0g/s 2607Kp/s 2607Kc/s 17805MC/s Zzzzzzzzzxing..Zzzzzzzzzzzzzzzzzzing 2 1g 0:00:01:10 DONE (2016-03-03 08:54) 0.01417g/s 2594Kp/s 2594Kc/s 17800MC/s Zzzzzzlling..Zzzzzzzzzzzzzzzzzzzzzzzing 1 2g 0:00:01:10 DONE (2016-03-03 08:54) 0.02829g/s 2589Kp/s 2589Kc/s 17797MC/s Zzzzzxzing..Zzzzzzzzzzzzzzzzzzzzzzing Waiting for 7 children to terminate 4 3g 0:00:01:11 DONE (2016-03-03 08:54) 0.04184g/s 2552Kp/s 2552Kc/s 17543MC/s Zzziling..Zzzzzzzzzzzzzzing 3 2g 0:00:01:12 DONE (2016-03-03 08:54) 0.02774g/s 2538Kp/s 2538Kc/s 17301MC/s Zzzuuing..Zzzzzzzzzzzzzzzzzzzzzzzzzzi 7 0g 0:00:01:12 DONE (2016-03-03 08:54) 0g/s 2531Kp/s 2531Kc/s 17314MC/s Zzzjktxrfing..Zzzzzzzzzzzzzzzzzzzzing 8 0g 0:00:01:12 DONE (2016-03-03 08:54) 0g/s 2521Kp/s 2521Kc/s 17305MC/s Zzzzing..Zzzzzzzzzzzzzzzzzzzzing Warning: passwords printed above might not be all those cracked Use the "--show" option to display all of the cracked passwords reliably Session completed

user@HAXTOP /Tools/Password Crackers/JohnTheRipper/run
$ ./john.exe --format=NT-old NT.out --wordlist=../../../wordlists/eNtr0pY_ALL_sort_uniq.dic --rules:Jumbo --fork=8
Using default input encoding: UTF-8
Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16])
Warning: invalid UTF-8 seen reading $JOHN/john.pot
Remaining 6801 password hashes with no different salts
Node numbers 1-8 of 8 (fork)
Each node loaded 1/8 of wordfile to memory (about 108 MB/node)
Crash recovery file is locked: ./john.2.rec
Crash recovery file is locked: ./john.3.rec
Crash recovery file is locked: ./john.5.rec
Crash recovery file is locked: ./john.6.rec
Crash recovery file is locked: ./john.7.rec
Crash recovery file is locked: ./john.8.rec
Crash recovery file is locked: ./john.rec

Process listing still has john running.

Killing all the john process manually and restarting the job.. i get (Notice forks, 1 and 7 are only going)

$ ./john.exe --format=NT-old NT.out --wordlist=../../../wordlists/eNtr0pY_ALL_sort_uniq.dic --rules:Jumbo --fork=8
Using default input encoding: UTF-8
Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16])
Warning: invalid UTF-8 seen reading $JOHN/john.pot
Remaining 6795 password hashes with no different salts
Node numbers 1-8 of 8 (fork)
Each node loaded 1/8 of wordfile to memory (about 108 MB/node)
Crash recovery file is locked: ./john.2.rec
Crash recovery file is locked: ./john.5.rec
Crash recovery file is locked: ./john.4.rec
Crash recovery file is locked: ./john.6.rec
Crash recovery file is locked: ./john.3.rec
Crash recovery file is locked: ./john.8.rec
Press 'q' or Ctrl-C to abort, almost any other key for status
1 0g 0:00:00:15 0.07% (ETA: 15:11:36) 0g/s 3684Kp/s 3684Kc/s 26600MC/s wendyannemoffat9..wendyashbyarroyo9
7 0g 0:00:00:15 0.07% (ETA: 15:05:55) 0g/s 3702Kp/s 3702Kc/s 26766MC/s doosjeejsood5..dopasefa5

Using version:
$ ./john.exe
John the Ripper 1.8.0.6-jumbo-1-2129-gf9f31ef+ OMP [cygwin 64-bit AVX2-ac]

<!-- gh-comment-id:191661846 --> @blackboxbandit-zz commented on GitHub (Mar 3, 2016): I've noticed that i do not need to stty, in the new version. Thanks for fixing that! /john.exe --format=NT-old NT.out --wordlist=../../../wordlists/eNtr0pY_ALL_sort_uniq.dic --rules --fork=8; <SNIP> 5 0g 0:00:01:09 DONE (2016-03-03 08:54) 0g/s 2621Kp/s 2621Kc/s 18055MC/s Zzzrzzzing..Zzzzzzzzzzzzzzzzing 6 0g 0:00:01:10 DONE (2016-03-03 08:54) 0g/s 2607Kp/s 2607Kc/s 17805MC/s Zzzzzzzzzxing..Zzzzzzzzzzzzzzzzzzing 2 1g 0:00:01:10 DONE (2016-03-03 08:54) 0.01417g/s 2594Kp/s 2594Kc/s 17800MC/s Zzzzzzlling..Zzzzzzzzzzzzzzzzzzzzzzzing 1 2g 0:00:01:10 DONE (2016-03-03 08:54) 0.02829g/s 2589Kp/s 2589Kc/s 17797MC/s Zzzzzxzing..Zzzzzzzzzzzzzzzzzzzzzzing Waiting for 7 children to terminate 4 3g 0:00:01:11 DONE (2016-03-03 08:54) 0.04184g/s 2552Kp/s 2552Kc/s 17543MC/s Zzziling..Zzzzzzzzzzzzzzing 3 2g 0:00:01:12 DONE (2016-03-03 08:54) 0.02774g/s 2538Kp/s 2538Kc/s 17301MC/s Zzzuuing..Zzzzzzzzzzzzzzzzzzzzzzzzzzi 7 0g 0:00:01:12 DONE (2016-03-03 08:54) 0g/s 2531Kp/s 2531Kc/s 17314MC/s Zzzjktxrfing..Zzzzzzzzzzzzzzzzzzzzing 8 0g 0:00:01:12 DONE (2016-03-03 08:54) 0g/s 2521Kp/s 2521Kc/s 17305MC/s Zzzzing..Zzzzzzzzzzzzzzzzzzzzing Warning: passwords printed above might not be all those cracked Use the "--show" option to display all of the cracked passwords reliably Session completed user@HAXTOP /Tools/Password Crackers/JohnTheRipper/run $ ./john.exe --format=NT-old NT.out --wordlist=../../../wordlists/eNtr0pY_ALL_sort_uniq.dic --rules:Jumbo --fork=8 Using default input encoding: UTF-8 Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16]) Warning: invalid UTF-8 seen reading $JOHN/john.pot Remaining 6801 password hashes with no different salts Node numbers 1-8 of 8 (fork) Each node loaded 1/8 of wordfile to memory (about 108 MB/node) Crash recovery file is locked: ./john.2.rec Crash recovery file is locked: ./john.3.rec Crash recovery file is locked: ./john.5.rec Crash recovery file is locked: ./john.6.rec Crash recovery file is locked: ./john.7.rec Crash recovery file is locked: ./john.8.rec Crash recovery file is locked: ./john.rec Process listing still has john running. Killing all the john process manually and restarting the job.. i get (Notice forks, 1 and 7 are only going) $ ./john.exe --format=NT-old NT.out --wordlist=../../../wordlists/eNtr0pY_ALL_sort_uniq.dic --rules:Jumbo --fork=8 Using default input encoding: UTF-8 Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16]) Warning: invalid UTF-8 seen reading $JOHN/john.pot Remaining 6795 password hashes with no different salts Node numbers 1-8 of 8 (fork) Each node loaded 1/8 of wordfile to memory (about 108 MB/node) Crash recovery file is locked: ./john.2.rec Crash recovery file is locked: ./john.5.rec Crash recovery file is locked: ./john.4.rec Crash recovery file is locked: ./john.6.rec Crash recovery file is locked: ./john.3.rec Crash recovery file is locked: ./john.8.rec Press 'q' or Ctrl-C to abort, almost any other key for status 1 0g 0:00:00:15 0.07% (ETA: 15:11:36) 0g/s 3684Kp/s 3684Kc/s 26600MC/s wendyannemoffat9..wendyashbyarroyo9 7 0g 0:00:00:15 0.07% (ETA: 15:05:55) 0g/s 3702Kp/s 3702Kc/s 26766MC/s doosjeejsood5..dopasefa5 Using version: $ ./john.exe John the Ripper 1.8.0.6-jumbo-1-2129-gf9f31ef+ OMP [cygwin 64-bit AVX2-ac]
Author
Owner

@jfoug commented on GitHub (Mar 3, 2016):

Just a couple questions as I try to track this down.

  1. What version of windows are you running cygwin under?
  2. I assume you are running under cygwin shell, due to the command syntax, but I will ask just to make sure. Running under cygwin bash shell ?
  3. Is your cygwin64 environment updated semi-recently?
<!-- gh-comment-id:191761111 --> @jfoug commented on GitHub (Mar 3, 2016): Just a couple questions as I try to track this down. 1. What version of windows are you running cygwin under? 2. I assume you are running under cygwin shell, due to the command syntax, but I will ask just to make sure. Running under cygwin bash shell ? 3. Is your cygwin64 environment updated semi-recently?
Author
Owner

@blackboxbandit-zz commented on GitHub (Mar 3, 2016):

Thanks for the swift response.

My answers :)

  1. Windows 8.1 64 bit
  2. Cygwin running bash under the standard mintty.exe
    3 Updated cygwin this morning.
<!-- gh-comment-id:191825566 --> @blackboxbandit-zz commented on GitHub (Mar 3, 2016): Thanks for the swift response. My answers :) 1. Windows 8.1 64 bit 2. Cygwin running bash under the standard mintty.exe 3 Updated cygwin this morning.
Author
Owner

@jfoug commented on GitHub (Mar 3, 2016):

I do not have an 8.1 any more. I have Win7 at work, and Win10 at home (win10 home and pro). If I can not get this to replicate (NOTE, I HAVE NOT yet tried), then I can probably install an 8.1 on a VM and see if it is OS dependant.

But yes, there are problems with -fork and or with .rec files, with cygwin, and I would LOVE to get to the bottom of it. I have had a few instances of .rec files being full of 'null' bytes. They were about right size, but the contents were smashed. I would really think this is related in some way. I have not had a repeatable way to produce the bug before. Possibly, I can from our instructions.

If I can easily repeat, I can pretty much find about any bug, even if it is just a 'hack' work around. But a hack, if it works, is better than the bug, lol.

<!-- gh-comment-id:191868345 --> @jfoug commented on GitHub (Mar 3, 2016): I do not have an 8.1 any more. I have Win7 at work, and Win10 at home (win10 home and pro). If I can not get this to replicate (NOTE, I HAVE NOT yet tried), then I can probably install an 8.1 on a VM and see if it is OS dependant. But yes, there are problems with -fork and or with .rec files, with cygwin, and I would LOVE to get to the bottom of it. I have had a few instances of .rec files being full of 'null' bytes. They were about right size, but the contents were smashed. I would really think this is related in some way. I have not had a repeatable way to produce the bug before. Possibly, I can from our instructions. If I can easily repeat, I can pretty much find about any bug, even if it is just a 'hack' work around. But a hack, if it works, is better than the bug, lol.
Author
Owner

@jfoug commented on GitHub (Mar 3, 2016):

$ ../run/john -form=NT-old NT_inc_all_tst.in -w=/c/projects/phpbb/dictionaries/RockYou_UserAccount-passwords.txt  --rules -fork=4 -ses=tst- -pot=tst-.pot
Loaded 1500 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16])
Node numbers 1-4 of 4 (fork)
Each node loaded 1/4 of wordfile to memory (about 16 MB/node)
Boi92            (u240-NT)
meanors          (u1207-NT)
sistecs          (u39-NT)
dumarc1          (u67-NT)
>>>clip<<<
krygrn           (u82-NT)
2ialb            (u1225-NT)
2 0g 0:00:00:11 DONE (2016-03-03 11:26) 0g/s 2781Kp/s 2781Kc/s 4310MC/s Wallyteaming..Ddiinnkkoing
1 3g 0:00:00:11 DONE (2016-03-03 11:26) 0.2659g/s 2804Kp/s 2804Kc/s 4305MC/s Emonaaking..Jadelening
Waiting for 3 children to terminate
3 4g 0:00:00:11 DONE (2016-03-03 11:26) 0.3512g/s 2773Kp/s 2773Kc/s 4298MC/s Imporioarmaning..Eninoeling
4 3g 0:00:00:11 DONE (2016-03-03 11:26) 0.2622g/s 2764Kp/s 2764Kc/s 4308MC/s Kybakloioning..Jucariusing
Session completed

$ ../run/john -form=NT-old NT_inc_all_tst.in -w=/c/projects/phpbb/dictionaries/RockYou_UserAccount-passwords.txt  --rules=jumbo -fork=4 -ses=tst- -pot=tst-.pot
Loaded 1500 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16])
Remaining 1491 password hashes with no different salts
Node numbers 1-4 of 4 (fork)
Each node loaded 1/4 of wordfile to memory (about 16 MB/node)
shaprie          (u43-NT)
Bozze            (u193-NT)
randic1          (u122-NT)
>>>clip<<<
gaclan2          (u1180-NT)
447b             (u125-NT)
3 11g 0:00:00:31 0.67% (ETA: 12:44:20) 0.3520g/s 3252Kp/s 3252Kc/s 4878MC/s 1lynn..syfat
4 6g 0:00:00:31 0.67% (ETA: 12:44:41) 0.1930g/s 3245Kp/s 3245Kc/s 4845MC/s ry-ey..loale
2 6g 0:00:00:31 0.67% (ETA: 12:45:17) 0.1911g/s 3159Kp/s 3159Kc/s 4761MC/s l0ze...k06
1 7g 0:00:00:31 0.67% (ETA: 12:44:46) 0.2251g/s 3237Kp/s 3237Kc/s 4835MC/s w1107..ernet
Waiting for 3 children to terminate
Session aborted

One instance ran to completion (like you did), and the 2nd I used the 'q' to exit.

A few questions.

  1. could you be running low or out of memory ?
  2. how much memory is being used by each of the 8 john processes running ?
  3. how large is wordlists/eNtr0pY_ALL_sort_uniq.dic ?

you might want to install TaskInfo or some other tool to have a better look at how much memory each john process is using. NOTE, when using -fork, each instance uses memory, vs OMP, where there 1 1 instance using slightly more memory than a single -fork instance.

<!-- gh-comment-id:191876073 --> @jfoug commented on GitHub (Mar 3, 2016): ``` $ ../run/john -form=NT-old NT_inc_all_tst.in -w=/c/projects/phpbb/dictionaries/RockYou_UserAccount-passwords.txt --rules -fork=4 -ses=tst- -pot=tst-.pot Loaded 1500 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16]) Node numbers 1-4 of 4 (fork) Each node loaded 1/4 of wordfile to memory (about 16 MB/node) Boi92 (u240-NT) meanors (u1207-NT) sistecs (u39-NT) dumarc1 (u67-NT) >>>clip<<< krygrn (u82-NT) 2ialb (u1225-NT) 2 0g 0:00:00:11 DONE (2016-03-03 11:26) 0g/s 2781Kp/s 2781Kc/s 4310MC/s Wallyteaming..Ddiinnkkoing 1 3g 0:00:00:11 DONE (2016-03-03 11:26) 0.2659g/s 2804Kp/s 2804Kc/s 4305MC/s Emonaaking..Jadelening Waiting for 3 children to terminate 3 4g 0:00:00:11 DONE (2016-03-03 11:26) 0.3512g/s 2773Kp/s 2773Kc/s 4298MC/s Imporioarmaning..Eninoeling 4 3g 0:00:00:11 DONE (2016-03-03 11:26) 0.2622g/s 2764Kp/s 2764Kc/s 4308MC/s Kybakloioning..Jucariusing Session completed $ ../run/john -form=NT-old NT_inc_all_tst.in -w=/c/projects/phpbb/dictionaries/RockYou_UserAccount-passwords.txt --rules=jumbo -fork=4 -ses=tst- -pot=tst-.pot Loaded 1500 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16]) Remaining 1491 password hashes with no different salts Node numbers 1-4 of 4 (fork) Each node loaded 1/4 of wordfile to memory (about 16 MB/node) shaprie (u43-NT) Bozze (u193-NT) randic1 (u122-NT) >>>clip<<< gaclan2 (u1180-NT) 447b (u125-NT) 3 11g 0:00:00:31 0.67% (ETA: 12:44:20) 0.3520g/s 3252Kp/s 3252Kc/s 4878MC/s 1lynn..syfat 4 6g 0:00:00:31 0.67% (ETA: 12:44:41) 0.1930g/s 3245Kp/s 3245Kc/s 4845MC/s ry-ey..loale 2 6g 0:00:00:31 0.67% (ETA: 12:45:17) 0.1911g/s 3159Kp/s 3159Kc/s 4761MC/s l0ze...k06 1 7g 0:00:00:31 0.67% (ETA: 12:44:46) 0.2251g/s 3237Kp/s 3237Kc/s 4835MC/s w1107..ernet Waiting for 3 children to terminate Session aborted ``` One instance ran to completion (like you did), and the 2nd I used the 'q' to exit. A few questions. 1. could you be running low or out of memory ? 2. how much memory is being used by each of the 8 john processes running ? 3. how large is wordlists/eNtr0pY_ALL_sort_uniq.dic ? you might want to install TaskInfo or some other tool to have a better look at how much memory each john process is using. NOTE, when using -fork, each instance uses memory, vs OMP, where there 1 1 instance using slightly more memory than a single -fork instance.
Author
Owner

@magnumripper commented on GitHub (Mar 3, 2016):

Another datapoint could be the log file. Almost any bailout-ending of JtR should leave some traces in the log file via error() complete with (iirc) function and source line number.

<!-- gh-comment-id:191927462 --> @magnumripper commented on GitHub (Mar 3, 2016): Another datapoint could be the log file. Almost any bailout-ending of JtR should leave some traces in the log file via `error()` complete with (iirc) function and source line number.
Author
Owner

@jfoug commented on GitHub (Mar 3, 2016):

very good point. Other things to look at are:

size of .pot file ?
size of .log file (not sure this matters)

But yes contents of the .log file around the problem time would help.

Also running in -verbose=4 (or 5) may also turn up additional things , or at least better allow tracing where in the process a problem happens.

<!-- gh-comment-id:191931390 --> @jfoug commented on GitHub (Mar 3, 2016): very good point. Other things to look at are: size of .pot file ? size of .log file (not sure this matters) But yes contents of the .log file around the problem time would help. Also running in -verbose=4 (or 5) may also turn up additional things , or at least better allow tracing where in the process a problem happens.
Author
Owner

@blackboxbandit-zz commented on GitHub (Mar 3, 2016):

Entr0py wordlist is from m3g9tr0n one IIRC

$ ls -l /Tools/wordlists/eNtr0pY_ALL_sort_uniq.dic
-rwxrwx---+ 1 User None 872M Aug 29 2012 /Tools/wordlists/eNtr0pY_ALL_sort_uniq.dic*

$ls -l john.pot
-rwxrwx---+ 1 User None 34M Mar 3 19:21 john.pot

I am going to try to run it with traceinfo & -verbose=5. I will also look at the contents of the log / rec file.

Got 16Gigs of memory, so i dont think i am running out of memory

<!-- gh-comment-id:191969184 --> @blackboxbandit-zz commented on GitHub (Mar 3, 2016): Entr0py wordlist is from m3g9tr0n one IIRC $ ls -l /Tools/wordlists/eNtr0pY_ALL_sort_uniq.dic -rwxrwx---+ 1 User None 872M Aug 29 2012 /Tools/wordlists/eNtr0pY_ALL_sort_uniq.dic* $ls -l john.pot -rwxrwx---+ 1 User None 34M Mar 3 19:21 john.pot I am going to try to run it with traceinfo & -verbose=5. I will also look at the contents of the log / rec file. Got 16Gigs of memory, so i dont think i am running out of memory
Author
Owner

@jfoug commented on GitHub (Mar 4, 2016):

Got 16Gigs of memory, so i dont think i am running out of memory

You easily could be running out of memory. Be sure to check. How large is your input file? NOTE, the dict will likely be stored in memory (FOR EACH of the 8 instances!). Also hash lists, hashes, source buffers, etc.

Things add up. 2GB per (or close to that), is not hard at all to hit. I am running john against 6.5m candidates, and am seeing 1.3+gb images, and when running in some modes, I have seen that up in the 2.5gb per node.

<!-- gh-comment-id:192038393 --> @jfoug commented on GitHub (Mar 4, 2016): > Got 16Gigs of memory, so i dont think i am running out of memory You easily could be running out of memory. Be sure to check. How large is your input file? NOTE, the dict will likely be stored in memory (FOR EACH of the 8 instances!). Also hash lists, hashes, source buffers, etc. Things add up. 2GB per (or close to that), is not hard at all to hit. I am running john against 6.5m candidates, and am seeing 1.3+gb images, and when running in some modes, I have seen that up in the 2.5gb per node.
Author
Owner

@jfoug commented on GitHub (Mar 4, 2016):

I see that the builtin windows task manager also shows memory being used per process also, so that is one way for you to find out, without having to install any additional software

<!-- gh-comment-id:192038850 --> @jfoug commented on GitHub (Mar 4, 2016): I see that the builtin windows task manager also shows memory being used per process also, so that is one way for you to find out, without having to install any additional software
Author
Owner

@blackboxbandit-zz commented on GitHub (Mar 4, 2016):

john.log contains the following error messages

1 0:00:00:00 Terminating on error, recovery.c:160
2 0:00:00:02 Terminating on error, recovery.c:160
3 0:00:00:02 Terminating on error, recovery.c:160
6 0:00:00:02 Terminating on error, recovery.c:160
5 0:00:00:02 Terminating on error, recovery.c:160
8 0:00:00:02 Terminating on error, recovery.c:160
7 0:00:00:02 Terminating on error, recovery.c:160

Contents of rec files

$ cat john.*.rec
REC4
9
--format=nt-old
NT.out
--wordlist=password.lst
--rules=All
--fork=8
--verbosity=5
--input-encoding=UTF-8
--internal-codepage=UTF-8
181
0
9fca19a0
c9a
0
7a7fef60
0
7a7fef60
0
0
0
68
0
4902817
0
1288

$ ls -l *.rec |
-rw-------+ 1 User None 205 Mar 4 10:43 john.2.rec
-rw-------+ 1 User None 0 Mar 4 10:40 john.3.rec
-rw-------+ 1 User None 0 Mar 4 10:40 john.4.rec
-rw-------+ 1 User None 0 Mar 4 10:40 john.5.rec
-rw-------+ 1 User None 0 Mar 4 10:40 john.6.rec
-rw-------+ 1 User None 0 Mar 4 10:40 john.7.rec
-rw-------+ 1 User None 0 Mar 4 10:40 john.8.rec
-rw-------+ 1 User None 0 Mar 4 10:40 john.rec

Recreate issue:

$ ./john.exe --format=nt-old NT.out -w=password.lst --rules --fork=8 -v=5
initUnicode(UNICODE, UTF-8/ISO-8859-1)
UTF-8 -> UTF-8 -> UTF-8
Using default input encoding: UTF-8
Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16])
Remaining 6743 password hashes with no different salts
Node numbers 1-8 of 8 (fork)
Loaded 43 hashes with 1 different salts to test db from test vectors
2 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 2551Kp/s 2551Kc/s 17201MC/s 8whose
Loaded 43 hashes with 1 different salts to test db from test vectors
3 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 2417Kp/s 2417Kc/s 16303MC/s Whoses
Loaded 43 hashes with 1 different salts to test db from test vectors
4 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 3085Kp/s 3085Kc/s 20804MC/s lissaboned..whosed
Loaded 43 hashes with 1 different salts to test db from test vectors
5 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 2553Kp/s 2553Kc/s 17219MC/s qwerting..whosing
Loaded 43 hashes with 1 different salts to test db from test vectors
6 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 3085Kp/s 3085Kc/s 20806MC/s Kerryaed..Whosed
Loaded 43 hashes with 1 different salts to test db from test vectors
7 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 4342Kp/s 4342Kc/s 29279MC/s Paagaling..Whosing
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Each node loaded the whole wordfile to memory
Press 'q' or Ctrl-C to abort, almost any other key for status
8 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 3513Kp/s 3513Kc/s 23688MC/s 5mart..5whose
1 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 4753Kp/s 4753Kc/s 32052MC/s 6spring..6whose
Waiting for 7 children to terminate
Session completed

$ ./john.exe --format=nt-old NT.out -w=password.lst --rules:All --fork=8 -v=5
initUnicode(UNICODE, UTF-8/ISO-8859-1)
UTF-8 -> UTF-8 -> UTF-8
Using default input encoding: UTF-8
Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16])
Remaining 6743 password hashes with no different salts
Node numbers 1-8 of 8 (fork)
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Loaded 43 hashes with 1 different salts to test db from test vectors
Each node loaded the whole wordfile to memory
Crash recovery file is locked: ./john.3.rec
Crash recovery file is locked: ./john.4.rec
Crash recovery file is locked: ./john.6.rec
Crash recovery file is locked: ./john.5.rec
Crash recovery file is locked: ./john.rec
Crash recovery file is locked: ./john.7.rec
Crash recovery file is locked: ./john.8.rec

Memory utilization is about 210Meg per instance;

Anything else that you guys might find userful ?

<!-- gh-comment-id:192228693 --> @blackboxbandit-zz commented on GitHub (Mar 4, 2016): john.log contains the following error messages 1 0:00:00:00 Terminating on error, recovery.c:160 2 0:00:00:02 Terminating on error, recovery.c:160 3 0:00:00:02 Terminating on error, recovery.c:160 6 0:00:00:02 Terminating on error, recovery.c:160 5 0:00:00:02 Terminating on error, recovery.c:160 8 0:00:00:02 Terminating on error, recovery.c:160 7 0:00:00:02 Terminating on error, recovery.c:160 # Contents of rec files $ cat john.*.rec REC4 9 --format=nt-old NT.out --wordlist=password.lst --rules=All --fork=8 --verbosity=5 --input-encoding=UTF-8 --internal-codepage=UTF-8 181 0 9fca19a0 c9a 0 7a7fef60 0 7a7fef60 0 0 0 68 0 4902817 0 1288 $ ls -l *.rec | -rw-------+ 1 User None 205 Mar 4 10:43 john.2.rec -rw-------+ 1 User None 0 Mar 4 10:40 john.3.rec -rw-------+ 1 User None 0 Mar 4 10:40 john.4.rec -rw-------+ 1 User None 0 Mar 4 10:40 john.5.rec -rw-------+ 1 User None 0 Mar 4 10:40 john.6.rec -rw-------+ 1 User None 0 Mar 4 10:40 john.7.rec -rw-------+ 1 User None 0 Mar 4 10:40 john.8.rec -rw-------+ 1 User None 0 Mar 4 10:40 john.rec Recreate issue: $ ./john.exe --format=nt-old NT.out -w=password.lst --rules --fork=8 -v=5 initUnicode(UNICODE, UTF-8/ISO-8859-1) UTF-8 -> UTF-8 -> UTF-8 Using default input encoding: UTF-8 Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16]) Remaining 6743 password hashes with no different salts Node numbers 1-8 of 8 (fork) Loaded 43 hashes with 1 different salts to test db from test vectors 2 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 2551Kp/s 2551Kc/s 17201MC/s 8whose Loaded 43 hashes with 1 different salts to test db from test vectors 3 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 2417Kp/s 2417Kc/s 16303MC/s Whoses Loaded 43 hashes with 1 different salts to test db from test vectors 4 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 3085Kp/s 3085Kc/s 20804MC/s lissaboned..whosed Loaded 43 hashes with 1 different salts to test db from test vectors 5 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 2553Kp/s 2553Kc/s 17219MC/s qwerting..whosing Loaded 43 hashes with 1 different salts to test db from test vectors 6 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 3085Kp/s 3085Kc/s 20806MC/s Kerryaed..Whosed Loaded 43 hashes with 1 different salts to test db from test vectors 7 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 4342Kp/s 4342Kc/s 29279MC/s Paagaling..Whosing Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Each node loaded the whole wordfile to memory Press 'q' or Ctrl-C to abort, almost any other key for status 8 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 3513Kp/s 3513Kc/s 23688MC/s 5mart..5whose 1 0g 0:00:00:00 DONE (2016-03-04 10:40) 0g/s 4753Kp/s 4753Kc/s 32052MC/s 6spring..6whose Waiting for 7 children to terminate Session completed $ ./john.exe --format=nt-old NT.out -w=password.lst --rules:All --fork=8 -v=5 initUnicode(UNICODE, UTF-8/ISO-8859-1) UTF-8 -> UTF-8 -> UTF-8 Using default input encoding: UTF-8 Loaded 15709 password hashes with no different salts (NT-old [MD4 128/128 X2 SSE2-16]) Remaining 6743 password hashes with no different salts Node numbers 1-8 of 8 (fork) Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Loaded 43 hashes with 1 different salts to test db from test vectors Each node loaded the whole wordfile to memory Crash recovery file is locked: ./john.3.rec Crash recovery file is locked: ./john.4.rec Crash recovery file is locked: ./john.6.rec Crash recovery file is locked: ./john.5.rec Crash recovery file is locked: ./john.rec Crash recovery file is locked: ./john.7.rec Crash recovery file is locked: ./john.8.rec Memory utilization is about 210Meg per instance; Anything else that you guys might find userful ?
Author
Owner

@jfoug commented on GitHub (Mar 4, 2016):

Ok, here is the locking function as cygwin when built without MPI sees things (all crap defines removed)

static void rec_lock(int shared) {
    int lockmode, blockmode;
    struct flock lock;
    if (shared == 1) {
        lockmode = F_WRLCK;
        blockmode = F_SETLKW;
            blockmode = F_SETLK;
    } else
    {
        lockmode = F_RDLCK;
        blockmode = F_SETLK;
    }
    memset(&lock, 0, sizeof(lock));
    lock.l_type = lockmode;
    if (fcntl(rec_fd, blockmode, &lock)) {
        if (errno == EAGAIN || errno == EACCES) {
            fprintf(stderr, "Crash recovery file is locked: %s\n",
                path_expand(rec_name));
            error();
        } else
            pexit("fcntl()");
    }
}

line-7 is the line I question. We initially setup blockmode to be F_SETLKW (blocking) but then immediately change that to F_SETLK (nonblocking)

@magnumripper you did most work on this. Can you explain, or is this simply a problem, OR was there a problem with F_SETLKW ?

The 'full' code for the F_SETLK override is this:

        lockmode = F_WRLCK;
        blockmode = F_SETLKW;
#ifdef HAVE_MPI
        if (!rec_restored || mpi_id || mpi_p == 1)
#endif
            blockmode = F_SETLK;

I am wondering if that hidden if statement should also be addressed with -fork mode work ?

<!-- gh-comment-id:192442008 --> @jfoug commented on GitHub (Mar 4, 2016): Ok, here is the locking function as cygwin when built without MPI sees things (all crap defines removed) ``` C static void rec_lock(int shared) { int lockmode, blockmode; struct flock lock; if (shared == 1) { lockmode = F_WRLCK; blockmode = F_SETLKW; blockmode = F_SETLK; } else { lockmode = F_RDLCK; blockmode = F_SETLK; } memset(&lock, 0, sizeof(lock)); lock.l_type = lockmode; if (fcntl(rec_fd, blockmode, &lock)) { if (errno == EAGAIN || errno == EACCES) { fprintf(stderr, "Crash recovery file is locked: %s\n", path_expand(rec_name)); error(); } else pexit("fcntl()"); } } ``` line-7 is the line I question. We initially setup blockmode to be F_SETLKW (blocking) but then immediately change that to F_SETLK (nonblocking) @magnumripper you did most work on this. Can you explain, or is this simply a problem, OR was there a problem with F_SETLKW ? The 'full' code for the F_SETLK override is this: ``` C lockmode = F_WRLCK; blockmode = F_SETLKW; #ifdef HAVE_MPI if (!rec_restored || mpi_id || mpi_p == 1) #endif blockmode = F_SETLK; ``` I am wondering if that hidden if statement should also be addressed with -fork mode work ?
Author
Owner

@jfoug commented on GitHub (Mar 4, 2016):

@blackboxbandit can you apply this patch, rebuild and do a -fork test again, checking to see if the problem is there, OR if jtr hangs (or only a thread or 2 actually run).

diff --git a/src/recovery.c b/src/recovery.c
index aa89f44..c674c4f 100644
--- a/src/recovery.c
+++ b/src/recovery.c
@@ -118,6 +118,7 @@ static void rec_lock(int shared)
 #else
                lockmode = LOCK_EX;
 #endif
+#ifndef __CYGWIN__
 #ifdef HAVE_MPI
                if (!rec_restored || mpi_id || mpi_p == 1)
 #endif
@@ -126,6 +127,7 @@ static void rec_lock(int shared)
 #else
                        lockmode |= LOCK_NB;
 #endif
+#endif
        } else
 #if FCNTL_LOCKS
        {

Note, the change will make the file locking go from non-blocking to blocking, so jtr MAY hang, but I imagine you can kill it properly if that is the case.

<!-- gh-comment-id:192445839 --> @jfoug commented on GitHub (Mar 4, 2016): @blackboxbandit can you apply this patch, rebuild and do a -fork test again, checking to see if the problem is there, OR if jtr hangs (or only a thread or 2 actually run). ``` diff diff --git a/src/recovery.c b/src/recovery.c index aa89f44..c674c4f 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -118,6 +118,7 @@ static void rec_lock(int shared) #else lockmode = LOCK_EX; #endif +#ifndef __CYGWIN__ #ifdef HAVE_MPI if (!rec_restored || mpi_id || mpi_p == 1) #endif @@ -126,6 +127,7 @@ static void rec_lock(int shared) #else lockmode |= LOCK_NB; #endif +#endif } else #if FCNTL_LOCKS { ``` Note, the change will make the file locking go from non-blocking to blocking, so jtr MAY hang, but I imagine you can kill it properly if that is the case.
Author
Owner

@jfoug commented on GitHub (Mar 5, 2016):

@magnumripper I found another comment which seems very important to this discussion:

void rec_restore_mode(int (*restore_mode)(FILE *file))
{
    rec_name_complete();
    if (!rec_file) return;
    if (restore_mode)
    if (restore_mode(rec_file)) rec_format_error("fscanf");
    if (options.flags & FLG_MASK_STACKED)
    if (mask_restore_state(rec_file)) rec_format_error("fscanf");
/*
 * Unlocking the file explicitly is normally not necessary since we're about to
 * close it anyway (which would normally release the lock).  However, when
 * we're the main process running with --fork, our newborn children may hold a
 * copy of the fd for a moment (until they close the fd themselves).  Thus, if
 * we don't explicitly remove the lock, there may be a race condition between
 * our children closing the fd and us proceeding to re-open and re-lock it.
 */
    rec_unlock();
    if (fclose(rec_file)) pexit("fclose");
    rec_file = NULL;
    rec_restoring_now = 0;
}
<!-- gh-comment-id:192620517 --> @jfoug commented on GitHub (Mar 5, 2016): @magnumripper I found another comment which seems very important to this discussion: ``` C void rec_restore_mode(int (*restore_mode)(FILE *file)) { rec_name_complete(); if (!rec_file) return; if (restore_mode) if (restore_mode(rec_file)) rec_format_error("fscanf"); if (options.flags & FLG_MASK_STACKED) if (mask_restore_state(rec_file)) rec_format_error("fscanf"); /* * Unlocking the file explicitly is normally not necessary since we're about to * close it anyway (which would normally release the lock). However, when * we're the main process running with --fork, our newborn children may hold a * copy of the fd for a moment (until they close the fd themselves). Thus, if * we don't explicitly remove the lock, there may be a race condition between * our children closing the fd and us proceeding to re-open and re-lock it. */ rec_unlock(); if (fclose(rec_file)) pexit("fclose"); rec_file = NULL; rec_restoring_now = 0; } ```
Author
Owner

@jfoug commented on GitHub (Mar 5, 2016):

Testing the new hybrid-external mode, I have been able to replicate this problem!!! I can not have it do it every time, but it does do it, and now that I can do it frequently, I can test 'fixes' myself, looking for what is needed.

 -fork=4 dynamic_0_tst.in -ext:hybrid_example-w=tst-.dic -ses=tst- -pot=tst-.pot
Warning: detected hash type "dynamic_0", but the string is also recognized as "Raw-MD5"
Use the "--format=Raw-MD5" option to force loading these as that type instead
Warning: detected hash type "dynamic_0", but the string is also recognized as "Raw-MD5-opencl"
Use the "--format=Raw-MD5-opencl" option to force loading these as that type instead
Loaded 1500 password hashes with no different salts (dynamic_0 [md5($p) (raw-md5) 128/128 XOP 4x2])
Remaining 1499 password hashes with no different salts
Node numbers 1-4 of 4 (fork)
Crash recovery file is locked: tst-.3.rec
Crash recovery file is locked: tst-.rec
$ Crash recovery file is locked: tst-.4.rec
2 0g 0:00:00:00 DONE (2016-03-05 13:56) 0g/s 250.6p/s 250.6c/s 375689C/s a00..a99
^C

here files 1, 3, 4 were locked, 2 was 'working'.

<!-- gh-comment-id:192720566 --> @jfoug commented on GitHub (Mar 5, 2016): Testing the new hybrid-external mode, I have been able to replicate this problem!!! I can not have it do it every time, but it does do it, and now that I can do it frequently, I can test 'fixes' myself, looking for what is needed. ``` -fork=4 dynamic_0_tst.in -ext:hybrid_example-w=tst-.dic -ses=tst- -pot=tst-.pot Warning: detected hash type "dynamic_0", but the string is also recognized as "Raw-MD5" Use the "--format=Raw-MD5" option to force loading these as that type instead Warning: detected hash type "dynamic_0", but the string is also recognized as "Raw-MD5-opencl" Use the "--format=Raw-MD5-opencl" option to force loading these as that type instead Loaded 1500 password hashes with no different salts (dynamic_0 [md5($p) (raw-md5) 128/128 XOP 4x2]) Remaining 1499 password hashes with no different salts Node numbers 1-4 of 4 (fork) Crash recovery file is locked: tst-.3.rec Crash recovery file is locked: tst-.rec $ Crash recovery file is locked: tst-.4.rec 2 0g 0:00:00:00 DONE (2016-03-05 13:56) 0g/s 250.6p/s 250.6c/s 375689C/s a00..a99 ^C ``` here files 1, 3, 4 were locked, 2 was 'working'.
Author
Owner

@jfoug commented on GitHub (Mar 5, 2016):

It only seems to happen if the .rec file is CREATED by the file handle that we try to lock. If the file handle was from opening (create) a file that already existed on disk, I see no locking problems.

I will check in a hack. We can talk about how this helps, and what others think about it.

<!-- gh-comment-id:192725730 --> @jfoug commented on GitHub (Mar 5, 2016): It only seems to happen if the .rec file is CREATED by the file handle that we try to lock. If the file handle was from opening (create) a file that already existed on disk, I see no locking problems. I will check in a hack. We can talk about how this helps, and what others think about it.
Author
Owner

@jfoug commented on GitHub (Mar 6, 2016):

@blackboxbandit please try jtr on cygwin for your setup after applying 9ba87c8 I believe it should work without issues under cygwin forking.

<!-- gh-comment-id:192766086 --> @jfoug commented on GitHub (Mar 6, 2016): @blackboxbandit please try jtr on cygwin for your setup after applying 9ba87c8 I believe it should work without issues under cygwin forking.
Author
Owner

@blackboxbandit-zz commented on GitHub (Mar 7, 2016):

Downloading the patch now and will let you know how it goes.

On 6 Mar 2016, at 00:23, jfoug notifications@github.com wrote:

@blackboxbandit please try jtr on cygwin for your setup after applying 9ba87c8 I believe it should work without issues under cygwin forking.

—
Reply to this email directly or view it on GitHub.

<!-- gh-comment-id:193157380 --> @blackboxbandit-zz commented on GitHub (Mar 7, 2016): Downloading the patch now and will let you know how it goes. > On 6 Mar 2016, at 00:23, jfoug notifications@github.com wrote: > > @blackboxbandit please try jtr on cygwin for your setup after applying 9ba87c8 I believe it should work without issues under cygwin forking. > > — > Reply to this email directly or view it on GitHub.
Author
Owner

@blackboxbandit-zz commented on GitHub (Mar 7, 2016):

Seems to be working fine with the patch; Have had no problems since morning..

Thanks guys for your efforts! Appreciate the quick fix!

<!-- gh-comment-id:193185773 --> @blackboxbandit-zz commented on GitHub (Mar 7, 2016): Seems to be working fine with the patch; Have had no problems since morning.. Thanks guys for your efforts! Appreciate the quick fix!
Author
Owner

@jfoug commented on GitHub (Mar 7, 2016):

@magnumripper didn't we have some other issue a couple years back, where we had to create a file, close it, and then re-open for some issue to go away (cygwin again I think)?? Wasn't it memory mapped files or some crap like that? I do remember something like this. How did we end up handling that issue? was it done in #ifdef __CYGWIN__ manner, or did we just put it into code for all systems to behave that way? (note my memory could be F'n with me also, I kind of partied it up a bit last nite, lol)

<!-- gh-comment-id:193270791 --> @jfoug commented on GitHub (Mar 7, 2016): @magnumripper didn't we have some other issue a couple years back, where we had to create a file, close it, and then re-open for some issue to go away (cygwin again I think)?? Wasn't it memory mapped files or some crap like that? I do remember something like this. How did we end up handling that issue? was it done in `#ifdef __CYGWIN__` manner, or did we just put it into code for all systems to behave that way? (note my memory could be F'n with me also, I kind of partied it up a bit last nite, lol)
Author
Owner

@magnumripper commented on GitHub (Mar 8, 2016):

I can't remember. Have you searched closed issues here for it?

<!-- gh-comment-id:193627376 --> @magnumripper commented on GitHub (Mar 8, 2016): I can't remember. Have you searched closed issues here for it?
Author
Owner

@jfoug commented on GitHub (Mar 8, 2016):

I think it was at the bottom of recovery.c

/* See the comment in recovery.h on how the "save" parameter is used */
void rec_done(int save)
{
    if (!rec_file)
        return;

/*
 * If we're the main process for a --fork'ed group of children, leave our .rec
 * file around until the children terminate (at which time we may be called
 * again with save < 0, meaning forced non-saving).
 */
#ifndef HAVE_MPI
    if (!save && options.fork && john_main_process) {
#else
    if (!save && (options.fork || mpi_p > 1) && john_main_process) {
#endif
        rec_save();
        return;
    }

    if (save > 0)
        rec_save();
    else
        log_flush();

/*
 * In Jumbo we close [releasing the lock] *after* unlinking, avoiding
 * race conditions. Except we can't do this on b0rken systems.
 */
#if __DJGPP__ || _MSC_VER || __MINGW32__ || __MINGW64__ || __CYGWIN__ || HAVE_WINDOWS_H
    if (fclose(rec_file))
        pexit("fclose");
    rec_file = NULL;
#endif

    if ((!save || save == -1) && unlink(path_expand(rec_name)))
        pexit("unlink: %s", path_expand(rec_name));

    if (rec_file) {
        if (fclose(rec_file))
            pexit("fclose");
        rec_file = NULL;
    }
}
<!-- gh-comment-id:193629775 --> @jfoug commented on GitHub (Mar 8, 2016): I think it was at the bottom of recovery.c ``` C /* See the comment in recovery.h on how the "save" parameter is used */ void rec_done(int save) { if (!rec_file) return; /* * If we're the main process for a --fork'ed group of children, leave our .rec * file around until the children terminate (at which time we may be called * again with save < 0, meaning forced non-saving). */ #ifndef HAVE_MPI if (!save && options.fork && john_main_process) { #else if (!save && (options.fork || mpi_p > 1) && john_main_process) { #endif rec_save(); return; } if (save > 0) rec_save(); else log_flush(); /* * In Jumbo we close [releasing the lock] *after* unlinking, avoiding * race conditions. Except we can't do this on b0rken systems. */ #if __DJGPP__ || _MSC_VER || __MINGW32__ || __MINGW64__ || __CYGWIN__ || HAVE_WINDOWS_H if (fclose(rec_file)) pexit("fclose"); rec_file = NULL; #endif if ((!save || save == -1) && unlink(path_expand(rec_name))) pexit("unlink: %s", path_expand(rec_name)); if (rec_file) { if (fclose(rec_file)) pexit("fclose"); rec_file = NULL; } } ```
Author
Owner

@magnumripper commented on GitHub (Mar 8, 2016):

If you mean the close-after-unlink, I added this just some month ago for #1954, which would be a real race condition trigger if implemented.

<!-- gh-comment-id:193631565 --> @magnumripper commented on GitHub (Mar 8, 2016): If you mean the close-after-unlink, I added this just some month ago for #1954, which would be a real race condition trigger if implemented.
Author
Owner

@jfoug commented on GitHub (Mar 8, 2016):

I still remember something else, but I am not able to find it. There was something about if a file had to be created, that the handle was not usable for something. But simply create file, close it, reopen the already existing file, and things were fine. I am pretty sure this was something in cygwin. We fought to find something for a while, and in the end, a hack like that worked around the problem. For the life of me, I simply can not remember exactly what/where it was.

<!-- gh-comment-id:193633212 --> @jfoug commented on GitHub (Mar 8, 2016): I still remember something else, but I am not able to find it. There was something about if a file had to be created, that the handle was not usable for something. But simply create file, close it, reopen the already existing file, and things were fine. I am pretty sure this was something in cygwin. We fought to find something for a while, and in the end, a hack like that worked around the problem. For the life of me, I simply can not remember exactly what/where it was.
Author
Owner

@jfoug commented on GitHub (Mar 8, 2016):

This may have been an issue I addressed at work. But I remember this.

  1. a file handle from a create may not have the actual file show up on disk immediately, and thus not be usable for certain tasks (such as locking).
  2. a file handle from an existing file always worked
  3. so the simple step of open/close/open then use (lock) worked every time.

I do not remember if this was a cygwin only issue. If this was from work, it was likely solaris. Now thinking back, I do think this was our pm process (process manager, that spawns all of our stuff), OR possibly it was that 'runnable' C project where i built so that C code could be executable from the command line. I certainly do not see this in john, but I do remember this problem.

The only question I have, is should we leave the if defs in, or simply make that the default behavior? The actual time used is not all that great, and it is a one time operation. It just makes sure that the .rec file IS on disk.

<!-- gh-comment-id:193809061 --> @jfoug commented on GitHub (Mar 8, 2016): This may have been an issue I addressed at work. But I remember this. 1. a file handle from a create may not have the actual file show up on disk immediately, and thus not be usable for certain tasks (such as locking). 2. a file handle from an existing file always worked 3. so the simple step of open/close/open then use (lock) worked every time. I do not remember if this was a cygwin only issue. If this was from work, it was likely solaris. Now thinking back, I do think this was our pm process (process manager, that spawns all of our stuff), OR possibly it was that 'runnable' C project where i built so that C code could be executable from the command line. I certainly do not see this in john, but I do remember this problem. The only question I have, is should we leave the if defs in, or simply make that the default behavior? The actual time used is not all that great, and it is a one time operation. It just makes sure that the .rec file IS on disk.
Author
Owner

@magnumripper commented on GitHub (Mar 8, 2016):

No, I wouldn't want workarounds for borken systems in the code for non-borken ones. Besides, the ifdef's serve as a documentation of sorts.

<!-- gh-comment-id:193912796 --> @magnumripper commented on GitHub (Mar 8, 2016): No, I wouldn't want workarounds for borken systems in the code for non-borken ones. Besides, the ifdef's serve as a documentation of sorts.
Author
Owner

@jfoug commented on GitHub (Mar 8, 2016):

Then lets close this bug, and leave the defines.

This change appears to be needed for cygwin. My question was are there other systems which would need this? That I can not answer, but like you said, the defines list that there are systems which require this type of 'fix'.

<!-- gh-comment-id:193942630 --> @jfoug commented on GitHub (Mar 8, 2016): Then lets close this bug, and leave the defines. This change appears to be needed for cygwin. My question was are there other systems which would need this? That I can not answer, but like you said, the defines list that there are systems which require this type of 'fix'.
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#1386
No description provided.