[GH-ISSUE #1043] -fork may be borking .pot file (and other FILE io) on jumbo. #645

Closed
opened 2026-10-14 03:17:03 +07:00 by bsakaguchi · 101 comments
Owner

Originally created by @jfoug on GitHub (Feb 5, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1043

Issue found with TS. Started as a stdout only problem, but appears to be .pot file being truncated when -fork is being used.

a fflush() was needed for the stdout problem. That may be the issue needed on all FILE io when in fork mode. Time will tell.

This is an example showing the symptom:

$ ./jtrts.pl -b=/JtR/bleed/run -passthru=-fork=2
-------------------------------------------------------------------------------
- JtR-TestSuite (jtrts). Version 1.13, Dec 21, 2014.  By, Jim Fougeron & others
- Testing:  John the Ripper password cracker, version 1.8.0.2-jumbo-1-bleeding_omp_memdbg_asan [linux-gnu 64-bit SSE4.1-autoconf]
--------------------------------------------------------------------------------

John Jumbo build detected.

form=dynamic_0                    guesses: 1502 0:00:00:00 DONE  [PASSED]
.pot CHK:dynamic_0                guesses: 1500 0:00:00:00 DONE  [PASSED] (1500 val-pwd)

.....
form=dynamic_15                   guesses: 1500 -show= 752 0:00:00:03 DONE : Expected count(s) (1500)  [!!!FAILED!!!]
.pot CHK:dynamic_15               guesses:  752 -show= 752 0:00:00:00 DONE : Expected count(s) (1500)  [!!!FAILED!!!]  (752 val-pwd)

In this case, the -show only gave us 752, which was what was in the .pot file. Upon the .pot check, it also shows us that only 752 lines were in the .pot, and on re-run john worked with them, so this does not appear to be any 'bug' in the test suite. This only appears to happen in -fork mode.

Originally created by @jfoug on GitHub (Feb 5, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1043 Issue found with TS. Started as a stdout only problem, but appears to be .pot file being truncated when -fork is being used. a fflush() was needed for the stdout problem. That may be the issue needed on all FILE io when in fork mode. Time will tell. This is an example showing the symptom: ``` $ ./jtrts.pl -b=/JtR/bleed/run -passthru=-fork=2 ------------------------------------------------------------------------------- - JtR-TestSuite (jtrts). Version 1.13, Dec 21, 2014. By, Jim Fougeron & others - Testing: John the Ripper password cracker, version 1.8.0.2-jumbo-1-bleeding_omp_memdbg_asan [linux-gnu 64-bit SSE4.1-autoconf] -------------------------------------------------------------------------------- John Jumbo build detected. form=dynamic_0 guesses: 1502 0:00:00:00 DONE [PASSED] .pot CHK:dynamic_0 guesses: 1500 0:00:00:00 DONE [PASSED] (1500 val-pwd) ..... form=dynamic_15 guesses: 1500 -show= 752 0:00:00:03 DONE : Expected count(s) (1500) [!!!FAILED!!!] .pot CHK:dynamic_15 guesses: 752 -show= 752 0:00:00:00 DONE : Expected count(s) (1500) [!!!FAILED!!!] (752 val-pwd) ``` In this case, the -show only gave us 752, which was what was in the .pot file. Upon the .pot check, it also shows us that only 752 lines were in the .pot, and on re-run john worked with them, so this does not appear to be any 'bug' in the test suite. This only appears to happen in -fork mode.
bsakaguchi 2026-10-14 03:17:03 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Ok, I ran again, with -stop on the command line. The .pot was truncated to 1049 entries, a wc on the .pot file shows 1050 lines, and I found this in the .pot file (showing why only 1049)

$dynamic_9$6f09fa563ac911fdea73cda5318c7b79$zIOqOeIk:}Ry4ppppppppppYP; 
$dynamic_9$b1ccabc84972f4295be16a978fef0f21$xshNSrtz:*eX8ppppppppppk|E@
$dynamic_9$c37fdaf2cd8c82f9bd208a28f0dd186c$8ut3rtKa:(_Fxpppppppppp@CQK
$dynamic_9$6b4822f6e523545b2becb4fe11c8f72d$cWtOo79x:#ww2mlkn
Hrgnu:I(e|ppppppppppppppppppppppppppppppppppppppppppppppv$@.
$dynamic_9$26a4c805473dd391c68ec905430e61f4$ClCS6YXL:1_@=pppppppppppppppppppppppA60R
$dynamic_9$38fc889fb3fc56d00890ea62d3974dcb$NTGdWyLr:jZX&pppppppppppppppppppppIs.8

That is the same 'classic' corrupted file sign we were seeing on the stdout problem fixed by a fflush() call after printing the found guess.

<!-- gh-comment-id:72996750 --> @jfoug commented on GitHub (Feb 5, 2015): Ok, I ran again, with -stop on the command line. The .pot was truncated to 1049 entries, a wc on the .pot file shows 1050 lines, and I found this in the .pot file (showing why only 1049) ``` $dynamic_9$6f09fa563ac911fdea73cda5318c7b79$zIOqOeIk:}Ry4ppppppppppYP; $dynamic_9$b1ccabc84972f4295be16a978fef0f21$xshNSrtz:*eX8ppppppppppk|E@ $dynamic_9$c37fdaf2cd8c82f9bd208a28f0dd186c$8ut3rtKa:(_Fxpppppppppp@CQK $dynamic_9$6b4822f6e523545b2becb4fe11c8f72d$cWtOo79x:#ww2mlkn Hrgnu:I(e|ppppppppppppppppppppppppppppppppppppppppppppppv$@. $dynamic_9$26a4c805473dd391c68ec905430e61f4$ClCS6YXL:1_@=pppppppppppppppppppppppA60R $dynamic_9$38fc889fb3fc56d00890ea62d3974dcb$NTGdWyLr:jZX&pppppppppppppppppppppIs.8 ``` That is the same 'classic' corrupted file sign we were seeing on the stdout problem fixed by a fflush() call after printing the found guess.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

A process may only hold one type of lock (shared     or  exclusive)  on  a
file.   Subsequent flock() calls on an already locked file will convert
an existing lock to the new lock mode.

We do have flock(pot_fd, LOCK_SH) within cracker??? But that is ONLY during reload pot.

COULD that be the problem???? In the TS, things happen fast. It could be that one process has already written into the .pot file, the other starts up, and blows the lock type by trying to load the .pot file??? Just a theory, since flock is a new function to me. The function make sense, since it is simply a mutex like function @magnumripper, is there any reason why we are using LOCK_SH in the flock within the .pot file reload? I would think exclusive would be just fine there. It would mean john blocks allowing only one process to access the .pot file at once during startup, BUT that is really the way it should be, on a multi-processing system, especially by reading the man page, listing that a call of a shared lock will pretty much zonk all of the exclusives being waited upon.

<!-- gh-comment-id:72998569 --> @jfoug commented on GitHub (Feb 5, 2015): ``` A process may only hold one type of lock (shared or exclusive) on a file. Subsequent flock() calls on an already locked file will convert an existing lock to the new lock mode. ``` We do have flock(pot_fd, LOCK_SH) within cracker??? But that is ONLY during reload pot. COULD that be the problem???? In the TS, things happen fast. It could be that one process has already written into the .pot file, the other starts up, and blows the lock type by trying to load the .pot file??? Just a theory, since flock is a new function to me. The function make sense, since it is simply a mutex like function @magnumripper, is there any reason why we are using LOCK_SH in the flock within the .pot file reload? I would think exclusive would be just fine there. It would mean john blocks allowing only one process to access the .pot file at once during startup, BUT that is really the way it should be, on a multi-processing system, especially by reading the man page, listing that a call of a shared lock will pretty much zonk all of the exclusives being waited upon.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Changing the flock in cracker to LOCK_EX did not change the problem. I have kept it for now at LOCK_SH

<!-- gh-comment-id:72998851 --> @jfoug commented on GitHub (Feb 5, 2015): Changing the flock in cracker to LOCK_EX did not change the problem. I have kept it for now at LOCK_SH
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Ok, here is a decent looking example:

Execute john: /JtR/bleed/run/john -ses=./tst  -fork=2 -pot=./tst.pot dynamic_15_new_tst.in --wordlist=pw-new.dic 2>&1 >/dev/null

Cmd_data = 
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
1 754g 0:00:00:02 DONE (2015-02-05 00:22) 375.1g/s 966.6p/s 1450Kc/s 1450KC/s aab2b..DSr]pppppppppO(C\
Waiting for 1 child to terminate
2 746g 0:00:00:02 DONE (2015-02-05 00:22) 365.6g/s 952.4p/s 1428Kc/s 1428KC/s ;C>5ppt^q^..ko}GpppVeLj
At Program Exit
MemDbg_Validate level 0 checking Passed
Use the "--show" option to display all of the cracked passwords reliably
Session completed
At Program Exit
MemDbg_Validate level 0 checking Passed

Execute john: /JtR/bleed/run/john -show    -pot=./tst.pot dynamic_15_new_tst.in -form=dynamic_15

d_show_line = 
747 password hashes cracked, 753 left

form=dynamic_15                   guesses: 1500 -show= 747 0:00:00:02 DONE : Expected count(s) (1500)  [!!!FAILED!!!]
Exiting on error. The .pot file ./tst.pot contains the found data
The command used to run this test was:

/JtR/bleed/run/john -ses=./tst  -fork=2 -pot=./tst.pot dynamic_15_new_tst.in --wordlist=pw-new.dic
$ wc tst.pot
  748   806 97257 tst.pot

Then at very bottom of tst.pot file:

$dynamic_15$c2f97f7d9423b3eb8938caad5e044519$HEX$4a3438494752306f2424555477656c76655f6368617273:!\zMppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp#Af0
$dynamic_15$af99574f198b6b4a5374d7ec932912f1$HEX$325278467a6176672424557531:es>YpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppgI`X
$dynamic_15$69dd3eb59597ffa1996b9bd4a314cf9e$HEX$454f6c50786b455324245575736572:d(`fpppppY.zm
pcZH<E7>
$dynamic_15$fced19c087c1b8b27ffd192da415d77c$HEX$4438643544336a3124245548616e6b:Y7LCpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp&<wg
(END)

So what appears to have happened here, is that the first 754 line crack wrote data. Then the 746 line fork wrote data right over the top, starting at tope of file. There was a bit more data (1 full line, and a partial) that was longer in the file so it still shows up.

I am also surprised about 754/746 counts. Usually it is 750/750 for fork.

<!-- gh-comment-id:73001139 --> @jfoug commented on GitHub (Feb 5, 2015): Ok, here is a decent looking example: ``` Execute john: /JtR/bleed/run/john -ses=./tst -fork=2 -pot=./tst.pot dynamic_15_new_tst.in --wordlist=pw-new.dic 2>&1 >/dev/null Cmd_data = Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status 1 754g 0:00:00:02 DONE (2015-02-05 00:22) 375.1g/s 966.6p/s 1450Kc/s 1450KC/s aab2b..DSr]pppppppppO(C\ Waiting for 1 child to terminate 2 746g 0:00:00:02 DONE (2015-02-05 00:22) 365.6g/s 952.4p/s 1428Kc/s 1428KC/s ;C>5ppt^q^..ko}GpppVeLj At Program Exit MemDbg_Validate level 0 checking Passed Use the "--show" option to display all of the cracked passwords reliably Session completed At Program Exit MemDbg_Validate level 0 checking Passed Execute john: /JtR/bleed/run/john -show -pot=./tst.pot dynamic_15_new_tst.in -form=dynamic_15 d_show_line = 747 password hashes cracked, 753 left form=dynamic_15 guesses: 1500 -show= 747 0:00:00:02 DONE : Expected count(s) (1500) [!!!FAILED!!!] Exiting on error. The .pot file ./tst.pot contains the found data The command used to run this test was: /JtR/bleed/run/john -ses=./tst -fork=2 -pot=./tst.pot dynamic_15_new_tst.in --wordlist=pw-new.dic ``` ``` $ wc tst.pot 748 806 97257 tst.pot ``` Then at very bottom of tst.pot file: ``` $dynamic_15$c2f97f7d9423b3eb8938caad5e044519$HEX$4a3438494752306f2424555477656c76655f6368617273:!\zMppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp#Af0 $dynamic_15$af99574f198b6b4a5374d7ec932912f1$HEX$325278467a6176672424557531:es>YpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppgI`X $dynamic_15$69dd3eb59597ffa1996b9bd4a314cf9e$HEX$454f6c50786b455324245575736572:d(`fpppppY.zm pcZH<E7> $dynamic_15$fced19c087c1b8b27ffd192da415d77c$HEX$4438643544336a3124245548616e6b:Y7LCpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp&<wg (END) ``` So what appears to have happened here, is that the first 754 line crack wrote data. Then the 746 line fork wrote data right over the top, starting at tope of file. There was a bit more data (1 full line, and a partial) that was longer in the file so it still shows up. I am also surprised about 754/746 counts. Usually it is 750/750 for fork.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

This one is not so easy to determine reason why (it is 100 lines 'short' in the .pot file)

Execute john: /JtR/bleed/run/john -ses=./tst  -fork=2 -pot=./tst.pot dynamic_1_new_tst.in --wordlist=pw-new.dic 2>&1 >/dev/null

Cmd_data = 
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
2 460g 0:00:00:01 DONE (2015-02-05 00:38) 310.8g/s 1312p/s 1969Kc/s 1969KC/s ;C>5ppt^q^..ko}GpppVeLj
At Program Exit
MemDbg_Validate level 0 checking Passed
1 463g 0:00:00:01 DONE (2015-02-05 00:38) 300.6g/s 1261p/s 1892Kc/s 1892KC/s aab2b..DSr]pppppppppO(C\
Waiting for 1 child to terminate
Use the "--show" option to display all of the cracked passwords reliably
Session completed
At Program Exit
MemDbg_Validate level 0 checking Passed

Execute john: /JtR/bleed/run/john -show    -pot=./tst.pot dynamic_1_new_tst.in -form=dynamic_1

d_show_line = 
823 password hashes cracked, 677 left

form=dynamic_1                    guesses:  923 -show= 823 0:00:00:01 DONE : Expected count(s) (1500)(923)  [!!!FAILED!!!]
Exiting on error. The .pot file ./tst.pot contains the found data
The command used to run this test was:

/JtR/bleed/run/john -ses=./tst  -fork=2 -pot=./tst.pot dynamic_1_new_tst.in --wordlist=pw-new.dic


$ wc tst.pot
  824   874 74861 tst.pot
<!-- gh-comment-id:73001663 --> @jfoug commented on GitHub (Feb 5, 2015): This one is not so easy to determine reason why (it is 100 lines 'short' in the .pot file) ``` Execute john: /JtR/bleed/run/john -ses=./tst -fork=2 -pot=./tst.pot dynamic_1_new_tst.in --wordlist=pw-new.dic 2>&1 >/dev/null Cmd_data = Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status 2 460g 0:00:00:01 DONE (2015-02-05 00:38) 310.8g/s 1312p/s 1969Kc/s 1969KC/s ;C>5ppt^q^..ko}GpppVeLj At Program Exit MemDbg_Validate level 0 checking Passed 1 463g 0:00:00:01 DONE (2015-02-05 00:38) 300.6g/s 1261p/s 1892Kc/s 1892KC/s aab2b..DSr]pppppppppO(C\ Waiting for 1 child to terminate Use the "--show" option to display all of the cracked passwords reliably Session completed At Program Exit MemDbg_Validate level 0 checking Passed Execute john: /JtR/bleed/run/john -show -pot=./tst.pot dynamic_1_new_tst.in -form=dynamic_1 d_show_line = 823 password hashes cracked, 677 left form=dynamic_1 guesses: 923 -show= 823 0:00:00:01 DONE : Expected count(s) (1500)(923) [!!!FAILED!!!] Exiting on error. The .pot file ./tst.pot contains the found data The command used to run this test was: /JtR/bleed/run/john -ses=./tst -fork=2 -pot=./tst.pot dynamic_1_new_tst.in --wordlist=pw-new.dic $ wc tst.pot 824 874 74861 tst.pot ```
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

I set LOCK_SH for reading, LOCK_EX for writing.

What good would a LOCK_EX do in pot sync? Pot sync only reads so it uses LOCK_SH. Other processes can set a LOCK_SH simultaneously and sync too, without waiting. That's the idea of a shared lock.

Any process wanting LOCK_EX for writing new pot entries will obviously wait for those LOCK_SH before it gets its lock.

<!-- gh-comment-id:73003728 --> @magnumripper commented on GitHub (Feb 5, 2015): I set LOCK_SH for reading, LOCK_EX for writing. What good would a LOCK_EX do in pot sync? Pot sync only _reads_ so it uses LOCK_SH. Other processes can set a LOCK_SH simultaneously and sync too, without waiting. That's the idea of a shared lock. Any process wanting LOCK_EX for _writing_ new pot entries will obviously wait for those LOCK_SH before it gets its lock.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

A process may only hold one type of lock (shared     or  exclusive)  on  a
file.   Subsequent flock() calls on an already locked file will convert
an existing lock to the new lock mode.

Only process A (or perhaps a subthread of process A but we don't have threads doing file IO) can blow its own lock the way you describe. Otherwise we could give up locking completely.

It could be that one process has already written into the .pot file, the other starts up, and blows the lock type by trying to load the .pot file?

If process A has a lock, process B can not blow it.

<!-- gh-comment-id:73004026 --> @magnumripper commented on GitHub (Feb 5, 2015): > ``` > A process may only hold one type of lock (shared or exclusive) on a > file. Subsequent flock() calls on an already locked file will convert > an existing lock to the new lock mode. > ``` Only process A (or perhaps a subthread of process A but we don't have threads doing file IO) can blow its own lock the way you describe. Otherwise we could give up locking completely. > It could be that one process has already written into the .pot file, the other starts up, and blows the lock type by trying to load the .pot file? If process A has a lock, process B can not blow it.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Yes, but a LOCK_SH will blow away (change) any lock waiting in LOCK_EX. (edit, so that is only threads in the process?? If so, then i would 'assume' this would be ok. It is outside of the OMP loop, correct)

I have a printf in the reload_pot, and it is not being called anyway.

Here is some new information. I added some logging to the flush pot stuff. It looks like all data in the flush made it out, and to the 'proper' location. Could this bug be something totally different, in that the last process sometimes does not write out it's final data???

Warning: detected hash type "dynamic_4", but the string is also recognized as "osc"
Use the "--format=osc" option to force loading these as that type instead
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
 ***In log_file_flush, writing to offset 0, count=28536 total after write=28536
 ***In log_file_flush, reset crk_pot_pos to 0
 ***In log_file_flush, writing to offset 28536, count=28559 total after write=57095
2 458g 0:00:00:00 DONE (2015-02-05 01:06) 1832g/s 1832p/s 1483Kc/s 1678KC/s )|jMp�Gge..s7g9y)
1 458g 0:00:00:00 DONE (2015-02-05 01:06) 1761g/s 1761p/s 1426Kc/s 1613KC/s \y^>pppppppppppppp~!OV..w&K4pppp{A#b
Waiting for 1 child to terminate
At Program Exit
MemDbg_Validate level 0 checking Passed
Use the "--show" option to display all of the cracked passwords reliably
Session completed
At Program Exit
MemDbg_Validate level 0 checking Passed


FAILED line = guesses: 458  0:00:00:00 DONE (2015-02-05 01:06) 1832g/s 1832p/s 1483Kc/s 1678KC/s )|jMp�Gge..s7g9y)
Execute john: /JtR/bleed/run/john -show    -pot=./tst.pot dynamic_4_new_tst.in -form=dynamic_4 2>&1

d_show_line2 = 
916 password hashes cracked, 584 left
1 invalid passwords
916 valid passwords

.pot CHK:dynamic_4                guesses:  916 -show= 916 0:00:00:00 DONE : Expected count(s) (1500)  [!!!FAILED!!!]  (916 val-pwd)
Exiting on error. The .pot file ./tst.pot contains the found data
The command used to run this test was:

/JtR/bleed/run/john -ses=./tst  -fork=2 -pot=./tst.pot dynamic_4_new_tst.in --wordlist=pw-new.dic

$ ls -l tst.pot
-rwxrwx--- 1 root vboxsf 57095 Feb  5 01:06 tst.pot
<!-- gh-comment-id:73004037 --> @jfoug commented on GitHub (Feb 5, 2015): Yes, but a LOCK_SH will blow away (change) any lock waiting in LOCK_EX. (edit, so that is only threads in the process?? If so, then i would 'assume' this would be ok. It is outside of the OMP loop, correct) I have a printf in the reload_pot, and it is not being called anyway. Here is some new information. I added some logging to the flush pot stuff. It looks like all data in the flush made it out, and to the 'proper' location. Could this bug be something totally different, in that the last process sometimes does not write out it's final data??? ``` Warning: detected hash type "dynamic_4", but the string is also recognized as "osc" Use the "--format=osc" option to force loading these as that type instead Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status ***In log_file_flush, writing to offset 0, count=28536 total after write=28536 ***In log_file_flush, reset crk_pot_pos to 0 ***In log_file_flush, writing to offset 28536, count=28559 total after write=57095 2 458g 0:00:00:00 DONE (2015-02-05 01:06) 1832g/s 1832p/s 1483Kc/s 1678KC/s )|jMp�Gge..s7g9y) 1 458g 0:00:00:00 DONE (2015-02-05 01:06) 1761g/s 1761p/s 1426Kc/s 1613KC/s \y^>pppppppppppppp~!OV..w&K4pppp{A#b Waiting for 1 child to terminate At Program Exit MemDbg_Validate level 0 checking Passed Use the "--show" option to display all of the cracked passwords reliably Session completed At Program Exit MemDbg_Validate level 0 checking Passed FAILED line = guesses: 458 0:00:00:00 DONE (2015-02-05 01:06) 1832g/s 1832p/s 1483Kc/s 1678KC/s )|jMp�Gge..s7g9y) Execute john: /JtR/bleed/run/john -show -pot=./tst.pot dynamic_4_new_tst.in -form=dynamic_4 2>&1 d_show_line2 = 916 password hashes cracked, 584 left 1 invalid passwords 916 valid passwords .pot CHK:dynamic_4 guesses: 916 -show= 916 0:00:00:00 DONE : Expected count(s) (1500) [!!!FAILED!!!] (916 val-pwd) Exiting on error. The .pot file ./tst.pot contains the found data The command used to run this test was: /JtR/bleed/run/john -ses=./tst -fork=2 -pot=./tst.pot dynamic_4_new_tst.in --wordlist=pw-new.dic $ ls -l tst.pot -rwxrwx--- 1 root vboxsf 57095 Feb 5 01:06 tst.pot ```
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

This was what I was hoping to see (at some time). This shows that for whatever reason, the locking is not always working:

Execute john: /JtR/bleed/run/john -ses=./tst  -fork=2 -pot=./tst.pot dynamic_13_tst.in --wordlist=pw.dic 2>&1 >/dev/null


Cmd_data = 
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
 ***In log_file_flush, writing to offset 0, count=32834 total after write=32834
 ***In log_file_flush, reset crk_pot_pos to 0
 ***In log_file_flush, writing to offset 0, count=32803 total after write=32803
 ***In log_file_flush, reset crk_pot_pos to 0
 ***In log_file_flush, writing to offset 32834, count=16950 total after write=49784
 ***In log_file_flush, reset crk_pot_pos to 32834
1 752g 0:00:00:04 DONE (2015-02-05 01:17) 170.9g/s 667.0p/s 1000Kc/s 1000KC/s Skippin� an�*..0A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Waiting for 1 child to terminate
 ***In log_file_flush, writing to offset 32803, count=16843 total after write=49646
 ***In log_file_flush, reset crk_pot_pos to 32803
2 748g 0:00:00:04 DONE (2015-02-05 01:17) 163.6g/s 642.0p/s 963019c/s 963019C/s Skipping and*..Z1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
At Program Exit
MemDbg_Validate level 0 checking Passed
Use the "--show" option to display all of the cracked passwords reliably
Session completed
At Program Exit
MemDbg_Validate level 0 checking Passed



Execute john: /JtR/bleed/run/john -show    -pot=./tst.pot dynamic_13_tst.in -form=dynamic_13

d_show_line = 
750 password hashes cracked, 750 left

form=dynamic_13                   guesses: 1500 -show= 750 0:00:00:04 DONE : Expected count(s) (1500)  [!!!FAILED!!!]
Exiting on error. The .pot file ./tst.pot contains the found data
The command used to run this test was:

/JtR/bleed/run/john -ses=./tst  -fork=2 -pot=./tst.pot dynamic_13_tst.in --wordlist=pw.dic
<!-- gh-comment-id:73004419 --> @jfoug commented on GitHub (Feb 5, 2015): This was what I was hoping to see (at some time). This shows that for whatever reason, the locking is not always working: ``` Execute john: /JtR/bleed/run/john -ses=./tst -fork=2 -pot=./tst.pot dynamic_13_tst.in --wordlist=pw.dic 2>&1 >/dev/null Cmd_data = Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status ***In log_file_flush, writing to offset 0, count=32834 total after write=32834 ***In log_file_flush, reset crk_pot_pos to 0 ***In log_file_flush, writing to offset 0, count=32803 total after write=32803 ***In log_file_flush, reset crk_pot_pos to 0 ***In log_file_flush, writing to offset 32834, count=16950 total after write=49784 ***In log_file_flush, reset crk_pot_pos to 32834 1 752g 0:00:00:04 DONE (2015-02-05 01:17) 170.9g/s 667.0p/s 1000Kc/s 1000KC/s Skippin� an�*..0A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 Waiting for 1 child to terminate ***In log_file_flush, writing to offset 32803, count=16843 total after write=49646 ***In log_file_flush, reset crk_pot_pos to 32803 2 748g 0:00:00:04 DONE (2015-02-05 01:17) 163.6g/s 642.0p/s 963019c/s 963019C/s Skipping and*..Z1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 At Program Exit MemDbg_Validate level 0 checking Passed Use the "--show" option to display all of the cracked passwords reliably Session completed At Program Exit MemDbg_Validate level 0 checking Passed Execute john: /JtR/bleed/run/john -show -pot=./tst.pot dynamic_13_tst.in -form=dynamic_13 d_show_line = 750 password hashes cracked, 750 left form=dynamic_13 guesses: 1500 -show= 750 0:00:00:04 DONE : Expected count(s) (1500) [!!!FAILED!!!] Exiting on error. The .pot file ./tst.pot contains the found data The command used to run this test was: /JtR/bleed/run/john -ses=./tst -fork=2 -pot=./tst.pot dynamic_13_tst.in --wordlist=pw.dic ```
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

Could this bug be something totally different, in that the last process sometimes does not write out it's final data???

That sounds more plausible to me. So why would that happen? Are all processes really completing? I recently changed a bunch of exit() into error() because that's a very much better way to abort a job.

<!-- gh-comment-id:73004492 --> @magnumripper commented on GitHub (Feb 5, 2015): > Could this bug be something totally different, in that the last process sometimes does not write out it's final data??? That sounds more plausible to me. So why would that happen? Are all processes really completing? I recently changed a bunch of `exit()` into `error()` because that's a very much better way to abort a job.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

The above looks ALMOST like 2 totally separate file descriptors, but acting on the same file.

<!-- gh-comment-id:73004541 --> @jfoug commented on GitHub (Feb 5, 2015): The above looks ALMOST like 2 totally separate file descriptors, but acting on the same file.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

This is the code I am using

#if OS_FLOCK
    while (flock(f->fd, LOCK_EX)) {
        if (errno != EINTR)
            pexit("flock(LOCK_EX)");
    }
#endif
    if (f == &pot) {
        pos_b4 = (long int)lseek(f->fd, 0, SEEK_END);
+       if (options.fork) {
+           fprintf (stderr, " ***In log_file_flush, writing to offset %ld, count=%d total after write=%ld\n", pos_b4, count, pos_b4+count);
+       }
    }
    if (write_loop(f->fd, f->buffer, count) < 0) pexit("write");
    f->ptr = f->buffer;

    if (f == &pot && pos_b4 == crk_pot_pos) {
        crk_pot_pos = (long int)lseek(f->fd, 0, SEEK_CUR);
+       fprintf (stderr, " ***In log_file_flush, reset crk_pot_pos to %ld\n", pos_b4, count);
    }
#if OS_FLOCK
    if (flock(f->fd, LOCK_UN))
        pexit("flock(LOCK_UN)");
#endif
<!-- gh-comment-id:73004647 --> @jfoug commented on GitHub (Feb 5, 2015): This is the code I am using ``` C #if OS_FLOCK while (flock(f->fd, LOCK_EX)) { if (errno != EINTR) pexit("flock(LOCK_EX)"); } #endif if (f == &pot) { pos_b4 = (long int)lseek(f->fd, 0, SEEK_END); + if (options.fork) { + fprintf (stderr, " ***In log_file_flush, writing to offset %ld, count=%d total after write=%ld\n", pos_b4, count, pos_b4+count); + } } if (write_loop(f->fd, f->buffer, count) < 0) pexit("write"); f->ptr = f->buffer; if (f == &pot && pos_b4 == crk_pot_pos) { crk_pot_pos = (long int)lseek(f->fd, 0, SEEK_CUR); + fprintf (stderr, " ***In log_file_flush, reset crk_pot_pos to %ld\n", pos_b4, count); } #if OS_FLOCK if (flock(f->fd, LOCK_UN)) pexit("flock(LOCK_UN)"); #endif ```
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

After a fork() any file descriptors are like duplicated. In order for locking to work we need to (re)open the pot and log files after forking. But that I'm pretty sure we do.

<!-- gh-comment-id:73004816 --> @magnumripper commented on GitHub (Feb 5, 2015): After a fork() any file descriptors are like duplicated. In order for locking to work we need to (re)open the pot and log files _after_ forking. But that I'm pretty sure we do.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

Add a debug print showing you indeed execute code within that #if OS_FLOCK block. That goes for pot sync too.

 #if OS_FLOCK
     while (flock(f->fd, LOCK_EX)) {
         if (errno != EINTR)
             pexit("flock(LOCK_EX)");
     }
+    fprintf(stderr, "successful LOCK_EX\n");
 #endif
<!-- gh-comment-id:73005074 --> @magnumripper commented on GitHub (Feb 5, 2015): Add a debug print showing you indeed execute code within that `#if OS_FLOCK` block. That goes for pot sync too. ``` C #if OS_FLOCK while (flock(f->fd, LOCK_EX)) { if (errno != EINTR) pexit("flock(LOCK_EX)"); } + fprintf(stderr, "successful LOCK_EX\n"); #endif ```
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

I agree. looking at the "***In log_file_flush..." messages, it looks like almost always this is hte case.

But it is HARD to explain away the output I show a few messages up. There are 2 distinct instances, as shown by the lseek(end) and the counts printed. BUT they are writing to the same file.

I am going to make a simple script that gets the TS out of the way, that will simply hammer away on a known fast input item until the .pot file comes up short. All data will be logged to a file, and the temp stuff cleaned up between each run (if things are good). Should be pretty easy to do, and once done, will be a real quick way to get all the 'testing' we need.

<!-- gh-comment-id:73005099 --> @jfoug commented on GitHub (Feb 5, 2015): I agree. looking at the "***In log_file_flush..." messages, it looks like almost always this is hte case. But it is HARD to explain away the output I show a few messages up. There are 2 distinct instances, as shown by the lseek(end) and the counts printed. BUT they are writing to the same file. I am going to make a simple script that gets the TS out of the way, that will simply hammer away on a known fast input item until the .pot file comes up short. All data will be logged to a file, and the temp stuff cleaned up between each run (if things are good). Should be pretty easy to do, and once done, will be a real quick way to get all the 'testing' we need.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Add a debug print showing

Will do.

NOTE, I have debug output for pot reload, and that code is never executed. Is that the -reload-pot stuff (where you use the .pot as the input file?) If so, it is nowhere near the exe path we are using anyway.

<!-- gh-comment-id:73005798 --> @jfoug commented on GitHub (Feb 5, 2015): > Add a debug print showing Will do. NOTE, I have debug output for pot reload, and that code is never executed. Is that the -reload-pot stuff (where you use the .pot as the input file?) If so, it is nowhere near the exe path we are using anyway.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

That pot reload is executed on signals and on timers. For short jobs, it's often called very late if at all.

<!-- gh-comment-id:73006113 --> @magnumripper commented on GitHub (Feb 5, 2015): That pot reload is executed on signals and on timers. For short jobs, it's often called very late if at all.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

I have not seen it called 'yet'. I certainly have not seen it called on the ones that have been failing, so for now, it is not on my radar.

<!-- gh-comment-id:73006258 --> @jfoug commented on GitHub (Feb 5, 2015): I have not seen it called 'yet'. I certainly have not seen it called on the ones that have been failing, so for now, it is not on my radar.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

It only reads so it shouldn't be able to do much harm. Actually it could probably do fine without locking at all.

<!-- gh-comment-id:73006354 --> @magnumripper commented on GitHub (Feb 5, 2015): It only reads so it shouldn't be able to do much harm. Actually it could probably do fine without locking at all.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Ok, new script:

cat flock-tst 

#!/bin/sh
rm bug.*
/JtR/bleed/run/john -fork=2 dynamic_1_tst.in -w=pw.dic -pot=./bug.pot -ses=./bug -form=dynamic_1 >./bug.stdout 2>./bug.stderr
CNT=$(wc bug.pot | awk '{print $1;}')
if [ x$CNT != x1500 ] ; 
then
    echo failed
fi

Ran this a couple times, til I got a failed.

Here are the relevant lines:

$ wc bug.pot
  1131   1202 100803 bug.pot
$ wc bug.stdout
 1195  2461 41377 bug.stdout
$ cat bug.stderr
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
successful LOCK_EX
successful LOCK_EX
successful LOCK_EX
successful LOCK_EX
Press 'q' or Ctrl-C to abort, almost any other key for status
successful LOCK_EX
 ***In log_file_flush, writing to offset 0, count=32844 total after write=32844
 ***In log_file_flush, reset crk_pot_pos to 0
successful LOCK_EX
successful LOCK_EX
 ***In log_file_flush, writing to offset 0, count=32800 total after write=32800
 ***In log_file_flush, reset crk_pot_pos to 0
successful LOCK_EX
successful LOCK_EX
 ***In log_file_flush, writing to offset 32800, count=32830 total after write=65630
 ***In log_file_flush, reset crk_pot_pos to 32800
successful LOCK_EX
successful LOCK_EX
successful LOCK_EX
 ***In log_file_flush, writing to offset 65630, count=1607 total after write=67237
 ***In log_file_flush, reset crk_pot_pos to 65630
1 755g 0:00:00:02 DONE (2015-02-05 01:46) 280.6g/s 1091p/s 1636Kc/s 1636KC/s Skippin� an�*..0A234567890123456789012
Waiting for 1 child to terminate
successful LOCK_EX
successful LOCK_EX
 ***In log_file_flush, writing to offset 32844, count=32774 total after write=65618
 ***In log_file_flush, reset crk_pot_pos to 32844
successful LOCK_EX
successful LOCK_EX
successful LOCK_EX
 ***In log_file_flush, writing to offset 65618, count=792 total after write=66410
 ***In log_file_flush, reset crk_pot_pos to 65618
2 745g 0:00:00:02 DONE (2015-02-05 01:46) 272.8g/s 1074p/s 1612Kc/s 1612KC/s Skipping and*..Z1234567890123456789012
successful LOCK_EX
At Program Exit
MemDbg_Validate level 0 checking Passed
Use the "--show" option to display all of the cracked passwords reliably
Session completed
successful LOCK_EX
At Program Exit
MemDbg_Validate level 0 checking Passed

I am done for the night. I have to sleep sometime.

<!-- gh-comment-id:73007327 --> @jfoug commented on GitHub (Feb 5, 2015): Ok, new script: ``` SH cat flock-tst #!/bin/sh rm bug.* /JtR/bleed/run/john -fork=2 dynamic_1_tst.in -w=pw.dic -pot=./bug.pot -ses=./bug -form=dynamic_1 >./bug.stdout 2>./bug.stderr CNT=$(wc bug.pot | awk '{print $1;}') if [ x$CNT != x1500 ] ; then echo failed fi ``` Ran this a couple times, til I got a failed. Here are the relevant lines: ``` $ wc bug.pot 1131 1202 100803 bug.pot $ wc bug.stdout 1195 2461 41377 bug.stdout $ cat bug.stderr Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) successful LOCK_EX successful LOCK_EX successful LOCK_EX successful LOCK_EX Press 'q' or Ctrl-C to abort, almost any other key for status successful LOCK_EX ***In log_file_flush, writing to offset 0, count=32844 total after write=32844 ***In log_file_flush, reset crk_pot_pos to 0 successful LOCK_EX successful LOCK_EX ***In log_file_flush, writing to offset 0, count=32800 total after write=32800 ***In log_file_flush, reset crk_pot_pos to 0 successful LOCK_EX successful LOCK_EX ***In log_file_flush, writing to offset 32800, count=32830 total after write=65630 ***In log_file_flush, reset crk_pot_pos to 32800 successful LOCK_EX successful LOCK_EX successful LOCK_EX ***In log_file_flush, writing to offset 65630, count=1607 total after write=67237 ***In log_file_flush, reset crk_pot_pos to 65630 1 755g 0:00:00:02 DONE (2015-02-05 01:46) 280.6g/s 1091p/s 1636Kc/s 1636KC/s Skippin� an�*..0A234567890123456789012 Waiting for 1 child to terminate successful LOCK_EX successful LOCK_EX ***In log_file_flush, writing to offset 32844, count=32774 total after write=65618 ***In log_file_flush, reset crk_pot_pos to 32844 successful LOCK_EX successful LOCK_EX successful LOCK_EX ***In log_file_flush, writing to offset 65618, count=792 total after write=66410 ***In log_file_flush, reset crk_pot_pos to 65618 2 745g 0:00:00:02 DONE (2015-02-05 01:46) 272.8g/s 1074p/s 1612Kc/s 1612KC/s Skipping and*..Z1234567890123456789012 successful LOCK_EX At Program Exit MemDbg_Validate level 0 checking Passed Use the "--show" option to display all of the cracked passwords reliably Session completed successful LOCK_EX At Program Exit MemDbg_Validate level 0 checking Passed ``` I am done for the night. I have to sleep sometime.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Btw, here is a 'good' test of the flock-tst script:

$ ./flock-tst
$ wc bug.*
  1520   7653  58346 bug.log
  1500   1595 133647 bug.pot
    38    194   1535 bug.stderr
  1156   2357  39695 bug.stdout
  4214  11799 233223 total

NOTE, I am not sure why bug.stdout is short. I would think it was 1500+ also.

NOTE the stdout is getting overwrites ??? I thought that was fixed.

<!-- gh-comment-id:73007537 --> @jfoug commented on GitHub (Feb 5, 2015): Btw, here is a 'good' test of the flock-tst script: ``` $ ./flock-tst $ wc bug.* 1520 7653 58346 bug.log 1500 1595 133647 bug.pot 38 194 1535 bug.stderr 1156 2357 39695 bug.stdout 4214 11799 233223 total ``` NOTE, I am not sure why bug.stdout is short. I would think it was 1500+ also. NOTE the stdout is getting overwrites ??? I thought that was fixed.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

here is a bug.stderr for one that worked

$ cat bug.stderr
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
successful LOCK_EX
 ***In log_file_flush, writing to offset 0, count=32771 total after write=32771
 ***In log_file_flush, reset crk_pot_pos to 0
successful LOCK_EX
 ***In log_file_flush, writing to offset 32771, count=32835 total after write=65606
successful LOCK_EX
 ***In log_file_flush, writing to offset 65606, count=32788 total after write=98394
successful LOCK_EX
 ***In log_file_flush, writing to offset 98394, count=1614 total after write=100008
successful LOCK_EX
 ***In log_file_flush, writing to offset 100008, count=32844 total after write=132852
1 755g 0:00:00:02 DONE (2015-02-05 02:01) 275.5g/s 1071p/s 1606Kc/s 1606KC/s Skippin� an�*..0A234567890123456789012
Waiting for 1 child to terminate
successful LOCK_EX
 ***In log_file_flush, writing to offset 132852, count=795 total after write=133647
2 745g 0:00:00:02 DONE (2015-02-05 02:01) 267.9g/s 1055p/s 1583Kc/s 1583KC/s Skipping and*..Z1234567890123456789012
At Program Exit

Updated (I only output successful FLOCK_EX, if it is a pot file)

<!-- gh-comment-id:73007943 --> @jfoug commented on GitHub (Feb 5, 2015): here is a bug.stderr for one that worked ``` $ cat bug.stderr Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status successful LOCK_EX ***In log_file_flush, writing to offset 0, count=32771 total after write=32771 ***In log_file_flush, reset crk_pot_pos to 0 successful LOCK_EX ***In log_file_flush, writing to offset 32771, count=32835 total after write=65606 successful LOCK_EX ***In log_file_flush, writing to offset 65606, count=32788 total after write=98394 successful LOCK_EX ***In log_file_flush, writing to offset 98394, count=1614 total after write=100008 successful LOCK_EX ***In log_file_flush, writing to offset 100008, count=32844 total after write=132852 1 755g 0:00:00:02 DONE (2015-02-05 02:01) 275.5g/s 1071p/s 1606Kc/s 1606KC/s Skippin� an�*..0A234567890123456789012 Waiting for 1 child to terminate successful LOCK_EX ***In log_file_flush, writing to offset 132852, count=795 total after write=133647 2 745g 0:00:00:02 DONE (2015-02-05 02:01) 267.9g/s 1055p/s 1583Kc/s 1583KC/s Skipping and*..Z1234567890123456789012 At Program Exit ``` Updated (I only output successful FLOCK_EX, if it is a pot file)
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Here is a bug.stderr from a failure (FLOCK_EX only printed for pot file locks)

$ cat bug.stderr
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
successful LOCK_EX
 ***In log_file_flush, writing to offset 0, count=32841 total after write=32841
 ***In log_file_flush, reset crk_pot_pos to 0
successful LOCK_EX
 ***In log_file_flush, writing to offset 0, count=32794 total after write=32794
 ***In log_file_flush, reset crk_pot_pos to 0
successful LOCK_EX
 ***In log_file_flush, writing to offset 32794, count=32841 total after write=65635
 ***In log_file_flush, reset crk_pot_pos to 32794
successful LOCK_EX
 ***In log_file_flush, writing to offset 65635, count=1602 total after write=67237
 ***In log_file_flush, reset crk_pot_pos to 65635
successful LOCK_EX
 ***In log_file_flush, writing to offset 32841, count=32841 total after write=65682
 ***In log_file_flush, reset crk_pot_pos to 32841
1 755g 0:00:00:03 DONE (2015-02-05 02:05) 251.6g/s 978.3p/s 1467Kc/s 1467KC/s Skippin� an�*..0A234567890123456789012
Waiting for 1 child to terminate
successful LOCK_EX
 ***In log_file_flush, writing to offset 65682, count=728 total after write=66410
 ***In log_file_flush, reset crk_pot_pos to 65682
2 745g 0:00:00:03 DONE (2015-02-05 02:05) 245.0g/s 965.1p/s 1447Kc/s 1447KC/s Skipping and*..Z1234567890123456789012
At Program Exit

And some info about the .pot file:

$ ls -l bug.pot
-rwxrwx--- 1 root vboxsf 100078 Feb  5 02:05 bug.pot
$ wc bug.pot
  1124   1192 100078 bug.pot
<!-- gh-comment-id:73008716 --> @jfoug commented on GitHub (Feb 5, 2015): Here is a bug.stderr from a failure (FLOCK_EX only printed for pot file locks) ``` $ cat bug.stderr Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status successful LOCK_EX ***In log_file_flush, writing to offset 0, count=32841 total after write=32841 ***In log_file_flush, reset crk_pot_pos to 0 successful LOCK_EX ***In log_file_flush, writing to offset 0, count=32794 total after write=32794 ***In log_file_flush, reset crk_pot_pos to 0 successful LOCK_EX ***In log_file_flush, writing to offset 32794, count=32841 total after write=65635 ***In log_file_flush, reset crk_pot_pos to 32794 successful LOCK_EX ***In log_file_flush, writing to offset 65635, count=1602 total after write=67237 ***In log_file_flush, reset crk_pot_pos to 65635 successful LOCK_EX ***In log_file_flush, writing to offset 32841, count=32841 total after write=65682 ***In log_file_flush, reset crk_pot_pos to 32841 1 755g 0:00:00:03 DONE (2015-02-05 02:05) 251.6g/s 978.3p/s 1467Kc/s 1467KC/s Skippin� an�*..0A234567890123456789012 Waiting for 1 child to terminate successful LOCK_EX ***In log_file_flush, writing to offset 65682, count=728 total after write=66410 ***In log_file_flush, reset crk_pot_pos to 65682 2 745g 0:00:00:03 DONE (2015-02-05 02:05) 245.0g/s 965.1p/s 1447Kc/s 1447KC/s Skipping and*..Z1234567890123456789012 At Program Exit ``` And some info about the .pot file: ``` $ ls -l bug.pot -rwxrwx--- 1 root vboxsf 100078 Feb 5 02:05 bug.pot $ wc bug.pot 1124 1192 100078 bug.pot ```
Author
Owner

@frank-dittrich commented on GitHub (Feb 5, 2015):

I guess it is related to these john.conf settings:

# 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

# If set to Y, resync pot file when saving session.
ReloadAtSave = Y

This also explains why it doesn't happen in core.

<!-- gh-comment-id:73018996 --> @frank-dittrich commented on GitHub (Feb 5, 2015): I guess it is related to these john.conf settings: ``` # 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 # If set to Y, resync pot file when saving session. ReloadAtSave = Y ``` This also explains why it doesn't happen in core.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

I ran these tests over and over again on Linux as well as OSX and can't reproduce. Apparently your system's flock() returns OK but does not lock the file. What system is this? What filesystem are you on?

With 6a749a162 and -DLOCK_DEBUG and running a 1000x larger test I can see the processes getting in line for locking, and waiting for each other.

(Here's running without that debug)

$ perl -ne 'print "\$0\$" . $_ if m/^[a-z0-9]{1,125}$/' < rockyou.lst >rockyou.plaintext

$ wc -l rockyou.plaintext
12147723 rockyou.plaintext

$ rm -f bug.* && ../run/john -fork=2 rockyou.plaintext -w:rockyou.lst -pot=bug.pot -ses=bug -form=plaintext -verb=1 ; wc -l bug.pot
Loaded 12147723 password hashes with no different salts (plaintext, $0$ [n/a])
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
1 6072671g 0:00:00:20 DONE (2015-02-05 17:15) 295650g/s 349181p/s 349181c/s 2454GC/s bicuspids1..Vk122503
Waiting for 1 child to terminate
2 6075052g 0:00:00:20 DONE (2015-02-05 17:15) 295766g/s 349181p/s 349181c/s 2383GC/s 651476..1450500134167
Session completed
12147723 bug.pot

Also tried fork=4 and higher. Never any problem. I also tried the above with "Save = 1" in john.conf. This means pot-sync will infere a whole lot more with the process. It still did not miss a beat.

<!-- gh-comment-id:73090668 --> @magnumripper commented on GitHub (Feb 5, 2015): I ran these tests over and over again on Linux as well as OSX and can't reproduce. Apparently your system's flock() returns OK but does not lock the file. What system is this? What filesystem are you on? With 6a749a162 and -DLOCK_DEBUG and running a 1000x larger test I can see the processes getting in line for locking, and waiting for each other. (Here's running without that debug) ``` $ perl -ne 'print "\$0\$" . $_ if m/^[a-z0-9]{1,125}$/' < rockyou.lst >rockyou.plaintext $ wc -l rockyou.plaintext 12147723 rockyou.plaintext $ rm -f bug.* && ../run/john -fork=2 rockyou.plaintext -w:rockyou.lst -pot=bug.pot -ses=bug -form=plaintext -verb=1 ; wc -l bug.pot Loaded 12147723 password hashes with no different salts (plaintext, $0$ [n/a]) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status 1 6072671g 0:00:00:20 DONE (2015-02-05 17:15) 295650g/s 349181p/s 349181c/s 2454GC/s bicuspids1..Vk122503 Waiting for 1 child to terminate 2 6075052g 0:00:00:20 DONE (2015-02-05 17:15) 295766g/s 349181p/s 349181c/s 2383GC/s 651476..1450500134167 Session completed 12147723 bug.pot ``` Also tried fork=4 and higher. Never any problem. I also tried the above with "Save = 1" in john.conf. This means pot-sync will infere a whole lot more with the process. It still did not miss a beat.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

Latest commit adds a little test script, unused/locktest.sh. It uses flock(1) which is a command for using flock(2). flock(1) is available on Linux, OpenBSD and some others. For OSX I used this one. Try it!

Here's "good" output:

$ unused/locktest.sh 
File initially not locked.
Locking file exclusively, using flock(2) for 5 seconds.
Confirmed, file is locked. Waiting for shared lock...
Got it, now releasing.
<!-- gh-comment-id:73090949 --> @magnumripper commented on GitHub (Feb 5, 2015): Latest commit adds a little test script, `unused/locktest.sh`. It uses flock(1) which is a command for using flock(2). flock(1) is available on Linux, OpenBSD and some others. For OSX I used [this one](https://dev.openwrt.org/browser/trunk/tools/flock/src). Try it! Here's "good" output: ``` $ unused/locktest.sh File initially not locked. Locking file exclusively, using flock(2) for 5 seconds. Confirmed, file is locked. Waiting for shared lock... Got it, now releasing. ```
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

successful LOCK_EX
 ***In log_file_flush, writing to offset 0, count=32841 total after write=32841
 ***In log_file_flush, reset crk_pot_pos to 0
successful LOCK_EX
 ***In log_file_flush, writing to offset 0, count=32794 total after write=32794
 ***In log_file_flush, reset crk_pot_pos to 0

Try latest commit with -DLOCK_DEBUG and re-run until you get the same situation. Does the first process release the lock before 2nd process get a "successful" one?

<!-- gh-comment-id:73097102 --> @magnumripper commented on GitHub (Feb 5, 2015): ``` successful LOCK_EX ***In log_file_flush, writing to offset 0, count=32841 total after write=32841 ***In log_file_flush, reset crk_pot_pos to 0 successful LOCK_EX ***In log_file_flush, writing to offset 0, count=32794 total after write=32794 ***In log_file_flush, reset crk_pot_pos to 0 ``` Try latest commit with -DLOCK_DEBUG and re-run until you get the same situation. Does the first process release the lock before 2nd process get a "successful" one?
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

What system is this? What filesystem are you on?

The system is a win8.1 laptop, running virtualbox VM, with Ubuntu 64 running on it. The actual file system is:

C_DRIVE on /media/sf_C_DRIVE type vboxsf (gid=999,rw)

This is an NTFS drive mounted by virutal box. Now, I can easily move the TS to this mount (on the virtual box VM)

/dev/sda1 on / type ext4 (rw,errors=remount-ro)

but I have no idea what a ext4 type means.

I will rebuild with latest locking and see if it is better, or show the problem.

<!-- gh-comment-id:73099979 --> @jfoug commented on GitHub (Feb 5, 2015): > What system is this? What filesystem are you on? The system is a win8.1 laptop, running virtualbox VM, with Ubuntu 64 running on it. The actual file system is: C_DRIVE on /media/sf_C_DRIVE type vboxsf (gid=999,rw) This is an NTFS drive mounted by virutal box. Now, I can easily move the TS to this mount (on the virtual box VM) /dev/sda1 on / type ext4 (rw,errors=remount-ro) but I have no idea what a ext4 type means. I will rebuild with latest locking and see if it is better, or show the problem.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Here is the 'first' failure.

Cmd_data = 
Will run 2 OpenMP threads per process (4 total across 2 processes)
Node numbers 1-2 of 2 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
log_file_flush(2): Successfully locked ./tst.pot LOCK_EX
log_file_flush(2): writing 32769 at 0, ending at 32769
log_file_flush(2): set crk_pot_pos to 32769
log_file_flush(2): Unlocked ./tst.pot
log_file_flush(1): Successfully locked ./tst.pot LOCK_EX
log_file_flush(1): writing 32794 at 0, ending at 32794
log_file_flush(1): set crk_pot_pos to 32794
log_file_flush(1): Unlocked ./tst.pot
log_file_flush(2): Successfully locked ./tst.pot LOCK_EX
log_file_flush(2): writing 16129 at 32769, ending at 48898
log_file_flush(2): set crk_pot_pos to 48898
log_file_flush(2): Unlocked ./tst.pot
2 748g 0:00:00:02 DONE (2015-02-05 12:41) 283.3g/s 1111p/s 1667Kc/s 1667KC/s Skipping and*..Z123456789012345678901234567890
At Program Exit
MemDbg_Validate level 0 checking Passed
log_file_flush(1): Successfully locked ./tst.pot LOCK_EX
log_file_flush(1): writing 16238 at 32794, ending at 49032
log_file_flush(1): set crk_pot_pos to 49032
log_file_flush(1): Unlocked ./tst.pot
1 752g 0:00:00:02 DONE (2015-02-05 12:41) 280.5g/s 1095p/s 1642Kc/s 1642KC/s Skippin� an�*..0A23456789012345678901234567890
Waiting for 1 child to terminate
Use the "--show" option to display all of the cracked passwords reliably
Session completed
At Program Exit
MemDbg_Validate level 0 checking Passed
$ ls -l tst.pot
-rwxrwx--- 1 root vboxsf 49032 Feb  5 12:41 tst.pot
$ wc tst.pot
  752   816 49032 tst.pot
<!-- gh-comment-id:73102853 --> @jfoug commented on GitHub (Feb 5, 2015): Here is the 'first' failure. ``` Cmd_data = Will run 2 OpenMP threads per process (4 total across 2 processes) Node numbers 1-2 of 2 (fork) Press 'q' or Ctrl-C to abort, almost any other key for status log_file_flush(2): Successfully locked ./tst.pot LOCK_EX log_file_flush(2): writing 32769 at 0, ending at 32769 log_file_flush(2): set crk_pot_pos to 32769 log_file_flush(2): Unlocked ./tst.pot log_file_flush(1): Successfully locked ./tst.pot LOCK_EX log_file_flush(1): writing 32794 at 0, ending at 32794 log_file_flush(1): set crk_pot_pos to 32794 log_file_flush(1): Unlocked ./tst.pot log_file_flush(2): Successfully locked ./tst.pot LOCK_EX log_file_flush(2): writing 16129 at 32769, ending at 48898 log_file_flush(2): set crk_pot_pos to 48898 log_file_flush(2): Unlocked ./tst.pot 2 748g 0:00:00:02 DONE (2015-02-05 12:41) 283.3g/s 1111p/s 1667Kc/s 1667KC/s Skipping and*..Z123456789012345678901234567890 At Program Exit MemDbg_Validate level 0 checking Passed log_file_flush(1): Successfully locked ./tst.pot LOCK_EX log_file_flush(1): writing 16238 at 32794, ending at 49032 log_file_flush(1): set crk_pot_pos to 49032 log_file_flush(1): Unlocked ./tst.pot 1 752g 0:00:00:02 DONE (2015-02-05 12:41) 280.5g/s 1095p/s 1642Kc/s 1642KC/s Skippin� an�*..0A23456789012345678901234567890 Waiting for 1 child to terminate Use the "--show" option to display all of the cracked passwords reliably Session completed At Program Exit MemDbg_Validate level 0 checking Passed ``` ``` $ ls -l tst.pot -rwxrwx--- 1 root vboxsf 49032 Feb 5 12:41 tst.pot $ wc tst.pot 752 816 49032 tst.pot ```
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

log_file_flush(2): Successfully locked ./tst.pot LOCK_EX
log_file_flush(2): writing 32769 at 0, ending at 32769
log_file_flush(2): set crk_pot_pos to 32769
log_file_flush(2): Unlocked ./tst.pot
log_file_flush(1): Successfully locked ./tst.pot LOCK_EX
log_file_flush(1): writing 32794 at 0, ending at 32794
log_file_flush(1): set crk_pot_pos to 32794
log_file_flush(1): Unlocked ./tst.pot

OK, so unless these fprint's to unbuffered stderr happens to end up in some other order than they REALLY happened, all things happen in correct order and YET process 1 get the wrong figure!? I have absolutely no idea what is going on but I write it off as your virtual environment having serious problems until you can show this happening on real gear.

ext4 is the current standard Linux filesystem, it does support locking.

<!-- gh-comment-id:73104614 --> @magnumripper commented on GitHub (Feb 5, 2015): ``` log_file_flush(2): Successfully locked ./tst.pot LOCK_EX log_file_flush(2): writing 32769 at 0, ending at 32769 log_file_flush(2): set crk_pot_pos to 32769 log_file_flush(2): Unlocked ./tst.pot log_file_flush(1): Successfully locked ./tst.pot LOCK_EX log_file_flush(1): writing 32794 at 0, ending at 32794 log_file_flush(1): set crk_pot_pos to 32794 log_file_flush(1): Unlocked ./tst.pot ``` OK, so unless these fprint's to unbuffered stderr happens to end up in some other order than they REALLY happened, all things happen in correct order and YET process 1 get the wrong figure!? I have absolutely no idea what is going on but I write it off as your virtual environment having serious problems until you can show this happening on real gear. ext4 is the current standard Linux filesystem, it does support locking.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

Do try that locktest.sh script!

<!-- gh-comment-id:73104831 --> @magnumripper commented on GitHub (Feb 5, 2015): Do try that locktest.sh script!
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

I did try locktest. It was happy to work right on my vboxfs fs. I did run it multiple times, and it was happy to say it was working.

I will copy all the TS stuff to the ext4 system and test there.

<!-- gh-comment-id:73105108 --> @jfoug commented on GitHub (Feb 5, 2015): I did try locktest. It was happy to work right on my vboxfs fs. I did run it multiple times, and it was happy to say it was working. I will copy all the TS stuff to the ext4 system and test there.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

On a side note I did heavy testing of these things all day today and I did find some interesting (frightening) facts. For example, a bog standard NFS share with Linux server and Linux clients: Client could lock, other clients would see the lock. But the server's native filesystem (at "same" directory) would NOT see clients' locks nor share its locks with the clients. This means you can run over NFS (required for MPI) just fine but you must NOT run any JtR process on the NFS server itself.

<!-- gh-comment-id:73108156 --> @magnumripper commented on GitHub (Feb 5, 2015): On a side note I did heavy testing of these things all day today and I did find some interesting (frightening) facts. For example, a bog standard NFS share with Linux server and Linux clients: Client could lock, other clients would see the lock. But the server's native filesystem (at "same" directory) would NOT see clients' locks nor share its locks with the clients. This means you can run over NFS (required for MPI) just fine but you must NOT run any JtR process on the NFS server itself.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

The fact locktest.sh worked fine indicates we have some other problem than we thought. I just can't fathom what it could be. It's kind of impossible... well, unless it's file caching inconsistency!?

<!-- gh-comment-id:73109036 --> @magnumripper commented on GitHub (Feb 5, 2015): The fact locktest.sh worked fine indicates we have some other problem than we thought. I just can't fathom what it could be. It's kind of impossible... well, unless it's file caching inconsistency!?
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

You could try this just for... trying it :-P

diff --git a/src/logger.c b/src/logger.c
index 719106d..a528257 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -133,6 +133,10 @@ static void log_file_flush(struct log_file *f)
        fprintf(stderr, "%s(%u): set crk_pot_pos to %ld\n", __FUNCTION__, options.node_min, crk_pot_pos);
 #endif
    }
+   if (f == &pot) {
+       fprintf(stderr, "%s(%u) fsync(%s)\n", __FUNCTION__, options.node_min, f->name);
+       if (fsync(f->fd)) pexit("fsync");
+   }
 #if OS_FLOCK
    if (flock(f->fd, LOCK_UN))
        pexit("flock(LOCK_UN)");
<!-- gh-comment-id:73110230 --> @magnumripper commented on GitHub (Feb 5, 2015): You could try this just for... trying it :-P ``` C diff --git a/src/logger.c b/src/logger.c index 719106d..a528257 100644 --- a/src/logger.c +++ b/src/logger.c @@ -133,6 +133,10 @@ static void log_file_flush(struct log_file *f) fprintf(stderr, "%s(%u): set crk_pot_pos to %ld\n", __FUNCTION__, options.node_min, crk_pot_pos); #endif } + if (f == &pot) { + fprintf(stderr, "%s(%u) fsync(%s)\n", __FUNCTION__, options.node_min, f->name); + if (fsync(f->fd)) pexit("fsync"); + } #if OS_FLOCK if (flock(f->fd, LOCK_UN)) pexit("flock(LOCK_UN)"); ```
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

You could try this just for... trying it :-P

Well, using -v -v -stop on the vboxfs, it made it past dyna_16 (2 files or more for each dyna). Before it was not making it nearly that far before dieing. I may get rid of the -v -v and simply run and see if the problem is gone. (Note, I restarted, since I was not 100% sure I used -stop on that run).

Damn, I took -v -v out, and it stopped almost instantly. But it does seem to vary per run. Some run with almost no errors for a while, then 'get into' them. Others simply start having every 3 to 5th run be an error.

I will also test more on the ext4 fs.

Running -v -v 'may' make it just a bit harder to trigger, since the screen IS being updated more. However, I thought the screen was only updated when jtr was not running. It may be that giving it a few extra 100 ms between each run was helping to 'calm' things down. But now I have another run without -v -v going, and am up past dynamic_12 (doubled) So I had 2 bad runs in a row, and now it is working 'better'. I will let it go and see.

Nope, died

form=dynamic_13                   guesses: 1500 0:00:00:03 DONE  [PASSED]
.pot CHK:dynamic_13               guesses: 1500 0:00:00:01 DONE  [PASSED] (1500 val-pwd)

form=dynamic_14                   guesses: 1500 0:00:00:02 DONE  [PASSED]
.pot CHK:dynamic_14               guesses: 1500 0:00:00:00 DONE  [PASSED] (1500 val-pwd)

form=dynamic_14                   guesses: 1237 0:00:00:01 DONE  [PASSED]
.pot CHK:dynamic_14               guesses: 1237 -show=1237 0:00:00:00 DONE : Expected count(s) (1500)  [!!!FAILED!!!]  (1237 val-pwd)
Exiting on error. The .pot file ./tst.pot contains the found data
The command used to run this test was:
<!-- gh-comment-id:73114510 --> @jfoug commented on GitHub (Feb 5, 2015): > You could try this just for... trying it :-P Well, using -v -v -stop on the vboxfs, it made it past dyna_16 (2 files or more for each dyna). Before it was not making it nearly that far before dieing. I may get rid of the -v -v and simply run and see if the problem is gone. (Note, I restarted, since I was not 100% sure I used -stop on that run). Damn, I took -v -v out, and it stopped almost instantly. But it does seem to vary per run. Some run with almost no errors for a while, then 'get into' them. Others simply start having every 3 to 5th run be an error. I will also test more on the ext4 fs. Running -v -v 'may' make it just a bit harder to trigger, since the screen IS being updated more. However, I thought the screen was only updated when jtr was not running. It may be that giving it a few extra 100 ms between each run was helping to 'calm' things down. But now I have another run without -v -v going, and am up past dynamic_12 (doubled) So I had 2 bad runs in a row, and now it is working 'better'. I will let it go and see. Nope, died ``` form=dynamic_13 guesses: 1500 0:00:00:03 DONE [PASSED] .pot CHK:dynamic_13 guesses: 1500 0:00:00:01 DONE [PASSED] (1500 val-pwd) form=dynamic_14 guesses: 1500 0:00:00:02 DONE [PASSED] .pot CHK:dynamic_14 guesses: 1500 0:00:00:00 DONE [PASSED] (1500 val-pwd) form=dynamic_14 guesses: 1237 0:00:00:01 DONE [PASSED] .pot CHK:dynamic_14 guesses: 1237 -show=1237 0:00:00:00 DONE : Expected count(s) (1500) [!!!FAILED!!!] (1237 val-pwd) Exiting on error. The .pot file ./tst.pot contains the found data The command used to run this test was: ```
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

That fsync() is not going to be committed though, unless you can come up with a sensible #ifdef to surround it with. We are chasing issues with a virtual environment as far as I can tell.

<!-- gh-comment-id:73117591 --> @magnumripper commented on GitHub (Feb 5, 2015): That `fsync()` is not going to be committed though, unless you can come up with a sensible #ifdef to surround it with. We are chasing issues with a virtual environment as far as I can tell.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Yes, I think so also, BUT it would certainly benefit us to know 'why'. Finding out why may allow things like cygwin (which has a much larger audience than someone using a VM like this). Cygwin has fork, and it 'claims' usable, but things go to shit, and I think this may be the reason.

NOTE, on this vm, I am running on that ext4 main fs, and things are running fine. There was an error on my 'new' dyna_25 run, but the numbers were right. I am not sure the error, it could be some line 'looking' like a pw, but not being one (i.e. ending with ) and having a " (" string in it). I hope that dyna_25 if run by itself will show the problem (in -v -v mode).

But as far as I can see now, the normal non NFS type fs is working at least much better right now. It is up to dyna-77 (doubled).

<!-- gh-comment-id:73118620 --> @jfoug commented on GitHub (Feb 5, 2015): Yes, I think so also, BUT it would certainly benefit us to know 'why'. Finding out why may allow things like cygwin (which has a much larger audience than someone using a VM like this). Cygwin has fork, and it 'claims' usable, but things go to shit, and I think this may be the reason. NOTE, on this vm, I am running on that ext4 main fs, and things are running fine. There was an error on my 'new' dyna_25 run, but the numbers were right. I am not sure the error, it could be some line 'looking' like a pw, but not being one (i.e. ending with ) and having a " (" string in it). I hope that dyna_25 if run by itself will show the problem (in -v -v mode). But as far as I can see now, the normal non NFS type fs is working at least much better right now. It is up to dyna-77 (doubled).
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

Did you try running on the ext4 fs without the extra fsync()? I would guess it works fine without it.

On another note you should try compiling that flock(1) utility and see how locktest.sh manages under Cygwin, on a normal "cygwin drive". I guess it will run just fine but it would be good to know it does.

<!-- gh-comment-id:73123808 --> @magnumripper commented on GitHub (Feb 5, 2015): Did you try running on the ext4 fs without the extra fsync()? I would guess it works fine without it. On another note you should try compiling that flock(1) utility and see how locktest.sh manages under Cygwin, on a normal "cygwin drive". I guess it will run just fine but it would be good to _know_ it does.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

flock is a command already built into cygwin. (at least cygwin64)

$ ./locktest.sh
File initially not locked.
Locking file exclusively, using flock(2) for 5 seconds.
Confirmed, file is locked. Waiting for shared lock...
Got it, now releasing.

It has no problem. I will run it multiple times.
NOTE, that example does not actually write anything, so just because a file 'gets' locked, does not seem to be enough to KNOW that multiple writes between processes will be done in a synchronous manner. We are seeing that with the vboxfs file system (or possibly other NFS type mounts).

It would be nice to have a stress test tool that would tell someone quickly (10-20 minutes at most), that some setup is NOT running properly to use john --fork=xx on, vs having them lose a shit load of work. That is why in cygwin we FORCED fork to fail. It was (is or appears) to be a known system where it simply fails.

<!-- gh-comment-id:73125770 --> @jfoug commented on GitHub (Feb 5, 2015): flock is a command already built into cygwin. (at least cygwin64) $ ./locktest.sh File initially not locked. Locking file exclusively, using flock(2) for 5 seconds. Confirmed, file is locked. Waiting for shared lock... Got it, now releasing. It has no problem. I will run it multiple times. NOTE, that example does not actually write anything, so just because a file 'gets' locked, does not seem to be enough to KNOW that multiple writes between processes will be done in a synchronous manner. We are seeing that with the vboxfs file system (or possibly other NFS type mounts). It would be nice to have a stress test tool that would tell someone quickly (10-20 minutes at most), that some setup is NOT running properly to use john --fork=xx on, vs having them lose a shit load of work. That is why in cygwin we FORCED fork to fail. It was (is or appears) to be a known system where it simply fails.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

NOTE, that example does not actually write anything

True, it only checks locking. Testing cache coherence is much harder and probably can't be done at all with a simple script like that. OTOH I would not expect Cygwin to have any file cache problems that NTFS in general doesn't have - and I don't know of any.

<!-- gh-comment-id:73128933 --> @magnumripper commented on GitHub (Feb 5, 2015): > NOTE, that example does not actually write anything True, it only checks locking. Testing cache coherence is much harder and probably can't be done at all with a simple script like that. OTOH I would not expect Cygwin to have any file cache problems that NTFS in general doesn't have - and I don't know of any.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

I do not either, BUT keep this in mind, the vboxfs has it's real parent being an NTFS file system. vboxfs is simply visualization to allow unix to 'think' it can use it natively, but I would be 90% under the hood passes through to NTFS. That along with Cygwin having known bad forking usage under JtR leads me to believe that possibly NTFS does not cache/lock the way we 'think' it should.

In many of the bad issues we are seeing now, it almost appears that the OS is NOT associating file handles between the 2 processes against the same file as BEING associated with same file (so that locking happens). If you look at the 'bad' runs, each process locks it's own file, starts at 0, writes bytes, then writes more to the end (which was what it wrote the first time), etc, etc. BUT there is only 1 file. So for -fork=2, I am seeing a lot of 748/751/753 type runs (just about half, and depends upon who wrote first). Each are seeing their own file handle, and NOT associating it with a share file between processes. So, I am not sold that caching is the problem. I really do not know enough of how this is really implemented to know how it is supposed to work under the hood.

<!-- gh-comment-id:73131759 --> @jfoug commented on GitHub (Feb 5, 2015): I do not either, BUT keep this in mind, the vboxfs has it's real parent being an NTFS file system. vboxfs is simply visualization to allow unix to 'think' it can use it natively, but I would be 90% under the hood passes through to NTFS. That along with Cygwin having known bad forking usage under JtR leads me to believe that possibly NTFS does not cache/lock the way we 'think' it should. In many of the bad issues we are seeing now, it almost appears that the OS is NOT associating file handles between the 2 processes against the same file as BEING associated with same file (so that locking happens). If you look at the 'bad' runs, each process locks it's own file, starts at 0, writes bytes, then writes more to the end (which was what it wrote the first time), etc, etc. BUT there is only 1 file. So for -fork=2, I am seeing a lot of 748/751/753 type runs (just about half, and depends upon who wrote first). Each are seeing their own file handle, and NOT associating it with a share file between processes. So, I am not sold that caching is the problem. I really do not know enough of how this is really implemented to know how it is supposed to work under the hood.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Question:

what if the lock was obtained on the 2nd process PRIOR to the file itself actually being created by the first???? Created might mean created and the inode being flushed to disk. In this case, both processes 'might' think they are the sole owner. Again, just a theory, I do not know shit about under the hood plumbing of this crap. But if that is the case, I wonder if we could do lock, if not exist create, close lock, and regain a lock?? I think that would ONLY have to happen if the file does not yet exist, so should be a zero impact on speed.

One bad thing, is I have NOT been able to get core to fail against the vboxfs (when run on the ubuntu VM). BUT there are not many formats there either. I did put a fflush in, and core works like a champ for the new (1500 val-pwd) testing (i.e. the stdout bug).

<!-- gh-comment-id:73132185 --> @jfoug commented on GitHub (Feb 5, 2015): Question: what if the lock was obtained on the 2nd process PRIOR to the file itself actually being created by the first???? Created might mean created and the inode being flushed to disk. In this case, both processes 'might' think they are the sole owner. Again, just a theory, I do not know shit about under the hood plumbing of this crap. But if that is the case, I wonder if we could do lock, if not exist create, close lock, and regain a lock?? I think that would ONLY have to happen if the file does not yet exist, so should be a zero impact on speed. One bad thing, is I have NOT been able to get core to fail against the vboxfs (when run on the ubuntu VM). BUT there are not many formats there either. I did put a fflush in, and core works like a champ for the new (1500 val-pwd) testing (i.e. the stdout bug).
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

The file is created in log_file_init(), way before this happens. I'm pretty sure this is about cache coherence and I'm not very surprised - unless I'm confused that file system is really not meant for things like this. It's mostly meant for easy file transfer between host and vm, no?

On the other hand - if it's NOT about cache coherence, it looks like a really bad bug in vbox.

<!-- gh-comment-id:73133882 --> @magnumripper commented on GitHub (Feb 5, 2015): The file is created in log_file_init(), way before this happens. I'm pretty sure this is about cache coherence and I'm not very surprised - unless I'm confused that file system is **really** not meant for things like this. It's mostly meant for easy file transfer between host and vm, no? On the other hand - if it's NOT about cache coherence, it looks like a really bad bug in vbox.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

The fact you can't reproduce this with core John bugs me. I think you should concentrate on that. Try thousands of dummy hashes and verify that you see this problem with Jumbo. Then do the exact same using core.

<!-- gh-comment-id:73135392 --> @magnumripper commented on GitHub (Feb 5, 2015): The fact you can't reproduce this with core John bugs me. I think you should concentrate on that. Try thousands of dummy hashes and verify that you see this problem with Jumbo. Then do the exact same using core.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

I made a simple change in log_file_init() and it 'may' have fixed things

this is the chagne:

    if ((f->fd = open(path_expand(name),
        O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) < 0)
        pexit("open: %s", path_expand(name));

+   close(f->fd);
+   if ((f->fd = open(path_expand(name),
+       O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) < 0)
+       pexit("open: %s", path_expand(name));

    f->ptr = f->buffer = mem_alloc(size + LINE_BUFFER_SIZE);

This simply means that the file pointer being used is NEVER one that actually created the file. I think there is caching going on, in that we are NOT locked, and the OS is caching the acutal flush out of the inode is being delayed.

NOPE, at dyna-29, I got a failure (614 vs 1229, so this is amost exactly half, and is 2 processes both thinking they are the only ones).

<!-- gh-comment-id:73135678 --> @jfoug commented on GitHub (Feb 5, 2015): I made a simple change in log_file_init() and it 'may' have fixed things this is the chagne: ``` C if ((f->fd = open(path_expand(name), O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) < 0) pexit("open: %s", path_expand(name)); + close(f->fd); + if ((f->fd = open(path_expand(name), + O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) < 0) + pexit("open: %s", path_expand(name)); f->ptr = f->buffer = mem_alloc(size + LINE_BUFFER_SIZE); ``` This simply means that the file pointer being used is NEVER one that actually created the file. I think there is caching going on, in that we are NOT locked, and the OS is caching the acutal flush out of the inode is being delayed. NOPE, at dyna-29, I got a failure (614 vs 1229, so this is amost exactly half, and is 2 processes both thinking they are the only ones).
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

The fact you can't reproduce this with core John bugs me. I think you should concentrate on that. Try thousands of dummy hashes and verify that you see this problem with Jumbo. Then do the exact same using core.

Oh, and leave TS out of it, it just adds confusion. Do something similar to https://github.com/magnumripper/JohnTheRipper/issues/1043#issuecomment-73090668 but with dummy instead of plaintext.

<!-- gh-comment-id:73135757 --> @magnumripper commented on GitHub (Feb 5, 2015): > The fact you can't reproduce this with core John bugs me. I think you should concentrate on that. Try thousands of dummy hashes and verify that you see this problem with Jumbo. Then do the exact same using core. Oh, and leave TS out of it, it just adds confusion. Do something similar to https://github.com/magnumripper/JohnTheRipper/issues/1043#issuecomment-73090668 but with dummy instead of plaintext.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

The fact you can't reproduce this with core John bugs me. I think you should concentrate on that.

One huge thing, is in jumbo, we fdopen (get a STDIO buffered handle) of the .pot file. In core, that file is WRITE ONLY, and never gets opened by anything other than a raw file handle.

But as far as I could tell, that pot reload code (where the FILE * handle is created/used) was not being called. I might have been wrong on that, but that was what I thought.

<!-- gh-comment-id:73143042 --> @jfoug commented on GitHub (Feb 5, 2015): > The fact you can't reproduce this with core John bugs me. I think you should concentrate on that. One huge thing, is in jumbo, we fdopen (get a STDIO buffered handle) of the .pot file. In core, that file is WRITE ONLY, and never gets opened by anything other than a raw file handle. But as far as I could tell, that pot reload code (where the FILE \* handle is created/used) was not being called. I might have been wrong on that, but that was what I thought.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

With the open/close/open in there, it is much harder to get a failure. I am still working on jumbo (1000 dummies). I think more is not going to show this problem any better. I think fewer is 'better'.

<!-- gh-comment-id:73145247 --> @jfoug commented on GitHub (Feb 5, 2015): With the open/close/open in there, it is much harder to get a failure. I am still working on jumbo (1000 dummies). I think more is not going to show this problem any better. I think fewer is 'better'.
Author
Owner

@magnumripper commented on GitHub (Feb 5, 2015):

What if you fsync() right after open instead of close-reopen?

<!-- gh-comment-id:73147101 --> @magnumripper commented on GitHub (Feb 5, 2015): What if you fsync() right after open instead of close-reopen?
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Right now, I am actually having a very hard time (with 'simple' script) to find the problem. I made a loop in my flock-tst script, and am simply looping until it fails, I am up to 100 runs (dyna_1 test again)

But running the TS, I was able to 'finally' have it chop the .pot file in half (2 forks). That was the only failure I have seen. This (along with fsync), is certainly much harder to corrupt. But that could also be because things have been slowed down. Hard to say for sure, unless I can comment out new stuff, rebuild, and have it go to hell again.

<!-- gh-comment-id:73148476 --> @jfoug commented on GitHub (Feb 5, 2015): Right now, I am actually having a very hard time (with 'simple' script) to find the problem. I made a loop in my flock-tst script, and am simply looping until it fails, I am up to 100 runs (dyna_1 test again) But running the TS, I was able to 'finally' have it chop the .pot file in half (2 forks). That was the only failure I have seen. This (along with fsync), is certainly much harder to corrupt. But that could also be because things have been slowed down. Hard to say for sure, unless I can comment out new stuff, rebuild, and have it go to hell again.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

It may be the fsync() that is making it hard to show this problem. I will build without that.

Nope at loop 31, it failed.
failed again at loop 9.

So without the open() / close() / open() it is easy to fail. I have rebuilt, and will continue testing, to see if I can get this 'simple' script to fail.

<!-- gh-comment-id:73149389 --> @jfoug commented on GitHub (Feb 5, 2015): It may be the fsync() that is making it hard to show this problem. I will build without that. Nope at loop 31, it failed. failed again at loop 9. So without the open() / close() / open() it is easy to fail. I have rebuilt, and will continue testing, to see if I can get this 'simple' script to fail.
Author
Owner

@jfoug commented on GitHub (Feb 5, 2015):

Ok, I have done 4 runs of 75 loops, with open()/close()/open() and I am not able to get failures. I do think this is the underlying FS simply not providing a file inode (or whatever it is) to other processes quickly enough.

Now why core works, I do not know.

<!-- gh-comment-id:73152580 --> @jfoug commented on GitHub (Feb 5, 2015): Ok, I have done 4 runs of 75 loops, with open()/close()/open() and I am not able to get failures. I do think this is the underlying FS simply not providing a file inode (or whatever it is) to other processes quickly enough. Now why core works, I do not know.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

OK try this then: With 09b03324 you can completely disable pot resync just editing john.conf. Set all of them to N and see if it still behaves different than core. It really should not.

ReloadAtCrack = N
ReloadAtDone = N
ReloadAtSave = N
<!-- gh-comment-id:73159529 --> @magnumripper commented on GitHub (Feb 6, 2015): OK try this then: With 09b03324 you can completely disable pot resync just editing john.conf. Set all of them to N and see if it still behaves different than core. It really should not. ``` ReloadAtCrack = N ReloadAtDone = N ReloadAtSave = N ```
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

Disregarding the pot sync and reviewing a git diff origin/master logger.c, I see one slight difference between jumbo and core: In jumbo we do an actual lseek(fd, 0, SEEK_END). Core doesn't, since the file is opened in O_APPEND anyway. Maybe this triggers some weird bug somewhere.

<!-- gh-comment-id:73160722 --> @magnumripper commented on GitHub (Feb 6, 2015): Disregarding the pot sync and reviewing a `git diff origin/master logger.c`, I see one slight difference between jumbo and core: In jumbo we do an actual `lseek(fd, 0, SEEK_END)`. Core doesn't, since the file is opened in O_APPEND anyway. Maybe this triggers some weird bug somewhere.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

In jumbo we do an actual lseek

...and if you turn pot sync off in john.conf, you could try to comment out both lseek's just for ruling them out.

<!-- gh-comment-id:73161671 --> @magnumripper commented on GitHub (Feb 6, 2015): > In jumbo we do an actual lseek ...and if you turn pot sync off in john.conf, you could try to comment out both lseek's just for ruling them out.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

Hmm wait a minute. Yes, we are opening with O_APPEND. So regardless of whether we seek or not, and wherever we seek to, and even without support from any file locking(!), the write is supposedly guaranteed to be atomically appending. Now THAT make your problems indicate a severe bug, wherever it actually lives (I still guess it's in your vboxfs but I have no idea how these low level things are implemented).

I always wondered why Solar doesn't even emit a warning if OS_FLOCK is not there. This is why.

<!-- gh-comment-id:73163614 --> @magnumripper commented on GitHub (Feb 6, 2015): Hmm wait a minute. Yes, we are opening with O_APPEND. So **regardless** of whether we seek or not, and wherever we seek to, and even without support from any file locking(!), the write is supposedly guaranteed to be atomically appending. Now THAT make your problems indicate a severe bug, wherever it actually lives (I still guess it's in your vboxfs but I have no idea how these low level things are implemented). I always wondered why Solar doesn't even emit a warning if OS_FLOCK is not there. This is why.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

I jumped the gun there. From some Linux man page: O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition.

"NFS file systems" can of course be replaced with "some file systems". It's a good idea using O_APPEND backed up with flock() but apparently it's not enough in this case.

<!-- gh-comment-id:73164639 --> @magnumripper commented on GitHub (Feb 6, 2015): I jumped the gun there. From some Linux man page: _O_APPEND may lead to corrupted files on NFS file systems if more than one process appends data to a file at once. This is because NFS does not support appending to a file, so the client kernel has to simulate it, which can't be done without a race condition._ "NFS file systems" can of course be replaced with "some file systems". It's a good idea using O_APPEND backed up with flock() but apparently it's not enough in this case.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

I am seeing the open()/close()/open() work wonders.

Now, the TS is somewhat of a 'ugly' beast. It does some things which are not always what you would 'see' in the wild. One of these, is to always start off with an empty .pot file. Many times (probably most of the time), jtr runs go where there is an existing john.pot (or whatever .pot file name) already on disk. I am going to make some changes to the TS to make sure that the .pot file is already there, written and flushed to disk. Now, the file will be a zero byte file, which on nix (and ntfs, I think), is just an inode. I will back out the open()/close()/open() code back to just open, and make sure that the fsync is not there, and start testing.

But I have been testing with existing open()/close()/open() and it is pretty damn stable. Yes, I did see one 1/2 sized .pot file, but only one. I Have not been able to make it fail since then. But if I remove that open()/close()/open(), it fails quickly, at a somewhat scary percentage. Again, the bug as I see it, is that both processes get that file handle, but there is no dependance at the OS level between them. With the file there, that problem appears to go away. That one failure could still be deemed to be some race condition, and I have not been able to replicate it. Having the file already there, prior to either JtR running might solve this.

_If that is the case, then we might be able to handle this with warning documentation within the -fork section, OR by having JtR create the .pot file early_, simply an open(create|append);close() during the john_init() or sometime like that. to make sure the file is there, prior to ever getting to any forking code.

I am also going to open this back up on cygwin and see if it works.

<!-- gh-comment-id:73224864 --> @jfoug commented on GitHub (Feb 6, 2015): I am seeing the open()/close()/open() work wonders. Now, the TS is somewhat of a 'ugly' beast. It does some things which are not always what you would 'see' in the wild. One of these, is to always start off with an empty .pot file. Many times (probably most of the time), jtr runs go where there is an existing john.pot (or whatever .pot file name) already on disk. I am going to make some changes to the TS to make sure that the .pot file is already there, written and flushed to disk. Now, the file will be a zero byte file, which on nix (and ntfs, I think), is just an inode. I will back out the open()/close()/open() code back to just open, and make sure that the fsync is not there, and start testing. But I have been testing with existing open()/close()/open() and it is pretty damn stable. Yes, I did see one 1/2 sized .pot file, but only one. I Have not been able to make it fail since then. But if I remove that open()/close()/open(), it fails quickly, at a somewhat scary percentage. Again, the bug as I see it, is that both processes get that file handle, but there is no dependance at the OS level between them. With the file there, that problem appears to go away. That one failure could still be deemed to be some race condition, and I have not been able to replicate it. Having the file already there, prior to either JtR running might solve this. **_If that is the case, then we might be able to handle this with warning documentation within the -fork section, OR by having JtR create the .pot file early**_, simply an open(create|append);close() during the john_init() or sometime like that. to make sure the file is there, prior to ever getting to any forking code. I am also going to open this back up on cygwin and see if it works.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Ok, I made this change to the TS. After every unlink($pot), except when at the bottom of the loop, and we REALLY want to clean it up, I call this sub

sub create_file_if_not_exist {
    my $filename = $_[0];
    if (-e $filename) { return; }
    open(FILE, ">".$filename);
    #print FILE "\n";
    close(FILE);
}

Now, the ubuntu-64 build, on the vm, using the vboxfs location of the test suite is running fine. I am going to build Cygwin with fork enabled, and see if now works in the TS. The reason we stopped using it before was it was having all sorts of problems. Possibly THIS is it. If not, it gives me more things to look into.

This is NOT the fix. It is just a work around to a newly discovered (we hope) problem on some non ext4-fs systems. Also, this likely is not the ONLY issue. There may be other systems we do not have our hooks into that have other issues with fork. Again, _the 'FIX', may be documentation, or it may be JtR always creates and closes the .pot file early on every run, or a combo of both._

OK, this did pop up in the ubuntu run with the changed TS. I have seen a couple of these, and I do not know exacty what the TS is complaining about.

form=dynamic_66                   guesses: 1500 0:00:00:07 DONE  [PASSED]
.pot CHK:dynamic_66               guesses: 1500 -show=1500 0:00:00:03 DONE : Expected count(s) (1500)  [!!!FAILED!!!]  (1500 val-pwd)

form=dynamic_77                   guesses: 1500 0:00:00:14 DONE  [PASSED]
.pot CHK:dynamic_77               guesses: 1500 -show=1500 0:00:00:07 DONE : Expected count(s) (1500)  [!!!FAILED!!!]  (1500 val-pwd)

Here everything on screen print checks out, but the TS still complains. I see these every once in a while and I am not sure why. I need to change my !!!FAILED!!! to be !!!FAILED1!!! !!!FAILED2!!! etc so I know at least what statement failed them. Here i have a pretty good idea, since the (1500 val-pwd) is listed, and I think there is only 1 failure point with that on it. Something in the if statement is not 'happy', BUT is not printed on screen.

<!-- gh-comment-id:73228084 --> @jfoug commented on GitHub (Feb 6, 2015): Ok, I made this change to the TS. After every unlink($pot), except when at the bottom of the loop, and we REALLY want to clean it up, I call this sub ``` Perl sub create_file_if_not_exist { my $filename = $_[0]; if (-e $filename) { return; } open(FILE, ">".$filename); #print FILE "\n"; close(FILE); } ``` Now, the ubuntu-64 build, on the vm, using the vboxfs location of the test suite is running fine. I am going to build Cygwin with fork enabled, and see if now works in the TS. The reason we stopped using it before was it was having all sorts of problems. Possibly THIS is it. If not, it gives me more things to look into. This is NOT the fix. It is just a work around to a newly discovered (we hope) problem on some non ext4-fs systems. Also, this likely is not the ONLY issue. There may be other systems we do not have our hooks into that have other issues with fork. Again, **_the 'FIX', may be documentation, or it may be JtR always creates and closes the .pot file early on every run, or a combo of both.**_ OK, this did pop up in the ubuntu run with the changed TS. I have seen a couple of these, and I do not know exacty what the TS is complaining about. ``` form=dynamic_66 guesses: 1500 0:00:00:07 DONE [PASSED] .pot CHK:dynamic_66 guesses: 1500 -show=1500 0:00:00:03 DONE : Expected count(s) (1500) [!!!FAILED!!!] (1500 val-pwd) form=dynamic_77 guesses: 1500 0:00:00:14 DONE [PASSED] .pot CHK:dynamic_77 guesses: 1500 -show=1500 0:00:00:07 DONE : Expected count(s) (1500) [!!!FAILED!!!] (1500 val-pwd) ``` Here everything on screen print checks out, but the TS still complains. I see these every once in a while and I am not sure why. I need to change my !!!FAILED!!! to be !!!FAILED1!!! !!!FAILED2!!! etc so I know at least what statement failed them. Here i have a pretty good idea, since the (1500 val-pwd) is listed, and I think there is only 1 failure point with that on it. Something in the if statement is not 'happy', BUT is not printed on screen.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Also note, the .pot file may not be the ONLY culprit here. Any files written to during the fork may behave like this. The .pot, the .log, etc. I am not sure about session files. Do we have a single one, or does each process get it's own? If a singleton, then yes, the session files also.

<!-- gh-comment-id:73228365 --> @jfoug commented on GitHub (Feb 6, 2015): Also note, the .pot file may not be the ONLY culprit here. Any files written to during the fork may behave like this. The .pot, the .log, etc. I am not sure about session files. Do we have a single one, or does each process get it's own? If a singleton, then yes, the session files also.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Ok, for cygwin, if I run it, it will start fork=2 processes, but they just hang. If i kill one of of them, the other proccess will complete. the .pot file will contain only the hashes cracked by that half (assuming fork=2). Also, the tty is hosed, and i have to run stty echo to get any screen IO (happens sometimes on JtR screw ups where screen is not released from raw mode).

So cygwin bug was not this one (goes beyond). But I may look into that a bit and see if it is some not 'too' hard. Likely it is both processes deadlocked on something (possibly the flock). Tried re-running with LOCK_DEBUG and I get no extra output, so cygwin may be deadlocked prior to getting to the .pot file stuff.

<!-- gh-comment-id:73229842 --> @jfoug commented on GitHub (Feb 6, 2015): Ok, for cygwin, if I run it, it will start fork=2 processes, but they just hang. If i kill one of of them, the other proccess will complete. the .pot file will contain only the hashes cracked by that half (assuming fork=2). Also, the tty is hosed, and i have to run `stty echo` to get any screen IO (happens sometimes on JtR screw ups where screen is not released from raw mode). So cygwin bug was not this one (goes beyond). But I may look into that a bit and see if it is some not 'too' hard. Likely it is both processes deadlocked on something (possibly the flock). Tried re-running with LOCK_DEBUG and I get no extra output, so cygwin may be deadlocked prior to getting to the .pot file stuff.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

@magnumripper how does rec_save type stuff work for forked processes (recovery record crap) ?

Ok, tested on ubuntu (working), and i see this:

$ ls -l xxxx.*
-rwxrwx--- 1 root vboxsf  189 Feb  6 08:47 xxxx.2.rec
-rwxrwx--- 1 root vboxsf 1711 Feb  6 08:47 xxxx.log
-rwxrwx--- 1 root vboxsf 1106 Feb  6 08:47 xxxx.pot
-rwxrwx--- 1 root vboxsf  188 Feb  6 08:47 xxxx.rec

So I see xxx.rec and xxx.2.rec That answers my question. But I have been slowly drilling down in cygwin, and it may be in the record save that cygwin is having problems. There is a special ftruncate code in there. I am not sure if that is the problem or not.

<!-- gh-comment-id:73246696 --> @jfoug commented on GitHub (Feb 6, 2015): @magnumripper how does rec_save type stuff work for forked processes (recovery record crap) ? Ok, tested on ubuntu (working), and i see this: ``` $ ls -l xxxx.* -rwxrwx--- 1 root vboxsf 189 Feb 6 08:47 xxxx.2.rec -rwxrwx--- 1 root vboxsf 1711 Feb 6 08:47 xxxx.log -rwxrwx--- 1 root vboxsf 1106 Feb 6 08:47 xxxx.pot -rwxrwx--- 1 root vboxsf 188 Feb 6 08:47 xxxx.rec ``` So I see xxx.rec and xxx.2.rec That answers my question. But I have been slowly drilling down in cygwin, and it may be in the record save that cygwin is having problems. There is a special ftruncate code in there. I am not sure if that is the problem or not.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Why do we do lseek(end) on the .pot file, but NOT on the log file??? Is that simply for that 'pot reload' logic??

<!-- gh-comment-id:73257028 --> @jfoug commented on GitHub (Feb 6, 2015): Why do we do lseek(end) on the .pot file, but NOT on the log file??? Is that simply for that 'pot reload' logic??
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

On my ubuntu system, not having _john.log_ there, ALSO _triggers the same disjoint file handle_ for locking the log file. NOTE on this run, neither file existed. Here is results after. The .pot should be 1500 lines, the .log 15xx (about 1520 or so I think).

$ wc xxxx.*
  1355   6827  51902 xxxx.log
  1500   1639  84430 xxxx.pot
  2855   8466 136332 total

I am going to make a 'simple' script and start looking for this one also.

As for cygwin, I have made progress, but I am about ready to throw in the towel. Now I have it working (for a while), but it seems to deadlock often in the flock(LOCK_UN) call, or possibly some race condition between 2 processes doing flock(LOCK_UN)/flock(LOCK_EX). I do have some simplification to the log_flush function however, and will be getting that checked in, once I have it tested better. I removed some of the if(fd==&pot) stuff, and simply always print stuff (to debug the true calls to that locking stuff). Also, the crk_pot_pos logic is simplified (now that I understand just wtf it was used for). We still do a SEEK_END on the .pot (but not .log). I am not 100% sure WHY we do that. I really think that should be a SEEK_CUR, and allow the append mode logic to work, BUT you mentioned that something about NFS having issues. BUT if that is the case, then I would think we would ALWAYS SEEK_END, both for the .pot and .log file ??? Rereading that, it appears that possibly using APPEND open with flock 'may' allow the system to simulate proper appending (which was what you found out about corruption).

All this is hard to tell, BUT overall, this is an exercise we have needed to do, trying to figure out how better to handle this. I still may not be able to get cygwin working (I have somewhat given up). BUT this is also testing a lot with the files not already existing on disk. Once i get my script updated (to look at both log and pot file line counts), I will also see if cygwin will work, if the files are 'always' there and flushed to disk, prior to jtr running. _THAT_ has pretty much eliminated the problem on the vboxfs for ubuntu running on virtualbox. I still get an error now and again on the TS, BUT those errors are 'invalid' password, and I think what is happening is something in screen IO is getting corrupted in the stderr stuff, triggering a 'looks like' situation for a password. BUT every time I get one of those errors, there also are 1500 GOOD matching passwords (or the correct amount), so this 'bad password' is spurious from somewhere else.

<!-- gh-comment-id:73277630 --> @jfoug commented on GitHub (Feb 6, 2015): On my ubuntu system, not having **_john.log**_ there, ALSO **_triggers the same disjoint file handle**_ for locking the log file. NOTE on this run, neither file existed. Here is results after. The .pot should be 1500 lines, the .log 15xx (about 1520 or so I think). ``` $ wc xxxx.* 1355 6827 51902 xxxx.log 1500 1639 84430 xxxx.pot 2855 8466 136332 total ``` I am going to make a 'simple' script and start looking for this one also. As for cygwin, I have made progress, but I am about ready to throw in the towel. Now I have it working (for a while), but it seems to deadlock often in the flock(LOCK_UN) call, or possibly some race condition between 2 processes doing flock(LOCK_UN)/flock(LOCK_EX). I do have some simplification to the log_flush function however, and will be getting that checked in, once I have it tested better. I removed some of the if(fd==&pot) stuff, and simply always print stuff (to debug the true calls to that locking stuff). Also, the crk_pot_pos logic is simplified (now that I understand just wtf it was used for). We still do a SEEK_END on the .pot (but not .log). I am not 100% sure WHY we do that. I really think that should be a SEEK_CUR, and allow the append mode logic to work, BUT you mentioned that something about NFS having issues. BUT if that is the case, then I would think we would ALWAYS SEEK_END, both for the .pot and .log file ??? Rereading that, it appears that possibly using APPEND open with flock 'may' allow the system to simulate proper appending (which was what you found out about corruption). All this is hard to tell, BUT overall, this is an exercise we have needed to do, trying to figure out how better to handle this. I still may not be able to get cygwin working (I have somewhat given up). BUT this is also testing a lot with the files not already existing on disk. Once i get my script updated (to look at both log and pot file line counts), I will also see if cygwin will work, if the files are 'always' there and flushed to disk, prior to jtr running. **_THAT**_ has pretty much eliminated the problem on the vboxfs for ubuntu running on virtualbox. I still get an error now and again on the TS, BUT those errors are 'invalid' password, and I think what is happening is something in screen IO is getting corrupted in the stderr stuff, triggering a 'looks like' situation for a password. BUT every time I get one of those errors, there also are 1500 GOOD matching passwords (or the correct amount), so this 'bad password' is spurious from somewhere else.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Ok, here is my 'test' script (to run without worry about JtRTS crap)

#!/bin/bash
CNT=0
CNT1=1
while [ true ]
do
Err=""
rm bug.*

# these 2 lines are CRITICAL on vboxfs file system (virtual box writing to native NTFS disk)
# this makes sure there ARE both of these files, before JtR starts.
echo -n > bug.pot
echo -n > bug.log

/JtR/bleed/run/john -fork=2 -w=pw.dic dynamic_1_tst.in -pot=./bug.pot -ses=./bug -form=dynamic >./bug.stdout 2>./bug.stderr

RET=$(wc bug.pot | awk '{print $1;}')

if [ x$RET != x1500 ] ; 
then
    Err="failed pot $RET"
else
RET=$(wc bug.log | awk '{print $1;}')
if [ x$RET != x1520 ] ; 
then
    Err="failed log $RET"
fi
fi

if [ "x$Err" != "x" ] ; 
then
    read -p "press ^C to break now, error was:  $Err  "
fi
CNT=$(( $CNT1 + $CNT ))
echo $CNT
done

Not really clean, but works for me.

<!-- gh-comment-id:73283606 --> @jfoug commented on GitHub (Feb 6, 2015): Ok, here is my 'test' script (to run without worry about JtRTS crap) ``` sh #!/bin/bash CNT=0 CNT1=1 while [ true ] do Err="" rm bug.* # these 2 lines are CRITICAL on vboxfs file system (virtual box writing to native NTFS disk) # this makes sure there ARE both of these files, before JtR starts. echo -n > bug.pot echo -n > bug.log /JtR/bleed/run/john -fork=2 -w=pw.dic dynamic_1_tst.in -pot=./bug.pot -ses=./bug -form=dynamic >./bug.stdout 2>./bug.stderr RET=$(wc bug.pot | awk '{print $1;}') if [ x$RET != x1500 ] ; then Err="failed pot $RET" else RET=$(wc bug.log | awk '{print $1;}') if [ x$RET != x1520 ] ; then Err="failed log $RET" fi fi if [ "x$Err" != "x" ] ; then read -p "press ^C to break now, error was: $Err " fi CNT=$(( $CNT1 + $CNT )) echo $CNT done ``` Not really clean, but works for me.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

Why do we do lseek(end) on the .pot file, but NOT on the log file??? Is that simply for that 'pot reload' logic??

Yep, it's just for getting the position before/after writing. We don't have to seek for the write, the O_APPEND guarantees a seek to end when writing anyway. Except for vboxsf...

<!-- gh-comment-id:73295842 --> @magnumripper commented on GitHub (Feb 6, 2015): > Why do we do lseek(end) on the .pot file, but NOT on the log file??? Is that simply for that 'pot reload' logic?? Yep, it's just for getting the position before/after writing. We don't have to seek for the write, the O_APPEND guarantees a seek to end when writing anyway. Except for vboxsf...
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

I am going to make a 'simple' script and start looking for this one also.

Why? It's just the exact same symptoms from the exact same vboxsf bug. IMHO time would be better spent trying to create a good isolated test case and report this to Oracle or whoever is the author of vbox.

<!-- gh-comment-id:73297855 --> @magnumripper commented on GitHub (Feb 6, 2015): > I am going to make a 'simple' script and start looking for this one also. Why? It's just the exact same symptoms from the exact same vboxsf bug. IMHO time would be better spent trying to create a good isolated test case and report this to Oracle or whoever is the author of vbox.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

We still do a SEEK_END on the .pot (but not .log). I am not 100% sure WHY we do that. I really think that should be a SEEK_CUR

Current what!? Who's current position? What we are doing here is 1. Remember the eof-position after WE wrote to the pot file, and 2. next time we write, first check if a SEEK_END now show a different figure. If it does, someone else wrote to the pot file so we need a pot sync.

and allow the append mode logic to work, BUT you mentioned that something about NFS having

The O_APPEND totally ignores where we seek. You can seek to pos 0 before writing and it will still write to the end of file. The seeks are solely for keeping track of what we did vs. what someone else possibly did.

issues. BUT if that is the case, then I would think we would ALWAYS SEEK_END, both for the .pot and .log file ??? Rereading that, it appears that possibly using APPEND open with flock 'may' allow the system to simulate proper appending (which was what you found out about corruption).

We are opening with O_APPEND. That's core code.

<!-- gh-comment-id:73299379 --> @magnumripper commented on GitHub (Feb 6, 2015): > We still do a SEEK_END on the .pot (but not .log). I am not 100% sure WHY we do that. I really think that should be a SEEK_CUR Current what!? Who's current position? What we are doing here is 1. Remember the eof-position after WE wrote to the pot file, and 2. next time we write, first check if a SEEK_END now show a different figure. If it does, _someone else wrote to the pot file_ so we need a pot sync. > and allow the append mode logic to work, BUT you mentioned that something about NFS having The O_APPEND totally ignores where we seek. You can seek to pos 0 before writing and it will still write to the end of file. The seeks are solely for keeping track of what we did vs. what someone else possibly did. > issues. BUT if that is the case, then I would think we would ALWAYS SEEK_END, both for the .pot and .log file ??? Rereading that, it appears that possibly using APPEND open with flock 'may' allow the system to simulate proper appending (which was what you found out about corruption). We _are_ opening with O_APPEND. That's core code.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Ok, I had to go out and left the above script on. It was at 3600 when I returned, and no problems.

Without the creation of the files (empty but there), prior to calling JtR, that script will die very quickly when run, from 1st run, to 10th run about 90% of the time, usually on 1st or 2nd run.

So I would say this is _the problem_ seen on -fork=x on vboxfs, and possibly on other file systems.

I am going to spend time on core. It may be that the TS does not smoke the .pot or .log file the same way for core. The code to handle that is very different than the code for jumbo. I will be testing core using a 'simple' script like we have on this page. I am still pretty concerned that we see this problem on jumbo but NOT on core. The code for logging should be somewhat similar. There is no 2nd opening of the log file with fopen/fdopen, no lseek(END), etc. It is pretty much the same crap. And I was seeing the .log file failing also, not just the .pot file.

<!-- gh-comment-id:73300726 --> @jfoug commented on GitHub (Feb 6, 2015): Ok, I had to go out and left the above script on. It was at 3600 when I returned, and no problems. Without the creation of the files (empty but there), prior to calling JtR, that script will die very quickly when run, from 1st run, to 10th run about 90% of the time, usually on 1st or 2nd run. So I would say this is **_the problem**_ seen on -fork=x on vboxfs, and possibly on other file systems. I am going to spend time on core. It may be that the TS does not smoke the .pot or .log file the same way for core. The code to handle that is very different than the code for jumbo. I will be testing core using a 'simple' script like we have on this page. I am still pretty concerned that we see this problem on jumbo but NOT on core. The code for logging should be somewhat similar. There is no 2nd opening of the log file with fopen/fdopen, no lseek(END), etc. It is pretty much the same crap. And I was seeing the .log file failing also, not just the .pot file.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

If it does, someone else wrote to the pot file so we need a pot sync.

Oh, and another detail: If we need a pot sync, we are not always just doing that from the start of the file! We are doing it from the last known "synced" position. The code might look weird unless you know why.

<!-- gh-comment-id:73300738 --> @magnumripper commented on GitHub (Feb 6, 2015): > If it does, someone else wrote to the pot file so we need a pot sync. Oh, and another detail: **If** we need a pot sync, we are not always just doing that from the start of the file! We are doing it from the last known "synced" position. The code might look weird unless you know why.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

Rereading that, it appears that possibly using APPEND open with flock 'may' allow the system to simulate proper appending (which was what you found out about corruption).

We are opening with O_APPEND. That's core code.

OK, now I re-read what you wrote :-P Yes, as I understand it, the O_APPEND alone is enough to be virtually 100% safe on a non-network, non virtual, file system. Or perhaps more generally speaking, one where we own the actual block device. So the flock() is a second-layer protection for network filesystems and other situations where O_APPEND is not 100% safe.

<!-- gh-comment-id:73302699 --> @magnumripper commented on GitHub (Feb 6, 2015): > > Rereading that, it appears that possibly using APPEND open with flock 'may' allow the system to simulate proper appending (which was what you found out about corruption). > > We are opening with O_APPEND. That's core code. OK, now I re-read what you wrote :-P Yes, as I understand it, the O_APPEND alone is enough to be virtually 100% safe on a non-network, non virtual, file system. Or perhaps more generally speaking, one where we own the actual block device. So the flock() is a second-layer protection for network filesystems and other situations where O_APPEND is not 100% safe.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

We still do a SEEK_END on the .pot (but not .log). I am not 100% sure WHY we do that. I really think that should be a SEEK_CUR

Current what!? Who's current position? What we are doing here is 1. Remember the eof-position after WE wrote to the pot file, and 2. next time we write, first check if a SEEK_END now show a different figure. If it does, someone else wrote to the pot file so we need a pot sync.

I think you are wrong on this one. The file handle used for the read is not the same as for the write. The write is at the end, I am using SEEK_CUR for that, and I believe it is 100% happy (on vboxsf!)

<!-- gh-comment-id:73304686 --> @jfoug commented on GitHub (Feb 6, 2015): > > We still do a SEEK_END on the .pot (but not .log). I am not 100% sure WHY we do that. I really think that should be a SEEK_CUR > > Current what!? Who's current position? What we are doing here is 1. Remember the eof-position after WE wrote to the pot file, and 2. next time we write, first check if a SEEK_END now show a different figure. If it does, someone else wrote to the pot file so we need a pot sync. I think you are wrong on this one. The file handle used for the read is not the same as for the write. The write is at the end, I am using SEEK_CUR for that, and I believe it is 100% happy (on vboxsf!)
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

I can't believe I'm wrong. If someone else writes to the file, my "current" will not change. See?

<!-- gh-comment-id:73305201 --> @magnumripper commented on GitHub (Feb 6, 2015): I can't believe I'm wrong. If someone else writes to the file, my "current" will not change. See?
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Sorry, I posted the above while catching up, prior to reading your last comment.

I changed to a SEEK_CUR to get the current offset (keeps the same logic for when/how much to reload), and the code is working 100% on vboxfs (with the files there).

That is the KEY for vboxfs. I think I can try to test this on an NFS mount at work. It possibly is the same problem. That once the file is 'there' and we flock(), then the APPEND mode gets non-corrupted files.

<!-- gh-comment-id:73305264 --> @jfoug commented on GitHub (Feb 6, 2015): Sorry, I posted the above while catching up, prior to reading your last comment. I changed to a SEEK_CUR to get the current offset (keeps the same logic for when/how much to reload), and the code is working 100% on vboxfs (with the files there). That is the KEY for vboxfs. I think I can try to test this on an NFS mount at work. It possibly is the same problem. That once the file is 'there' and we flock(), then the APPEND mode gets non-corrupted files.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

The current WILL change (in SEEK_CUR). Keep in mind, the APPEND mode. I am running that way right now, works fine. Try it out, you will (i think) be surprised ;) put the debugging on, so that you can follow the file offsets and lengths.

We are not using 'buffered' file stuff, where the CRTL will (or possibly) not hit the OS level. Here we are using 'raw' files. So we lock and get exclusive access, do a seek_cur, and the OS will seek to end of file, and give us the length. It sounds 'funny', but that is what is happening.

I have not tested this on cygwin yet. I will do a head slap if cygwin all of a sudden magically works, lol.

<!-- gh-comment-id:73305416 --> @jfoug commented on GitHub (Feb 6, 2015): The current WILL change (in SEEK_CUR). Keep in mind, the APPEND mode. I am running that way right now, works fine. Try it out, you will (i think) be surprised ;) put the debugging on, so that you can follow the file offsets and lengths. We are not using 'buffered' file stuff, where the CRTL will (or possibly) not hit the OS level. Here we are using 'raw' files. So we lock and get exclusive access, do a seek_cur, and the OS will seek to end of file, and give us the length. It sounds 'funny', but that is what is happening. I have not tested this on cygwin yet. I will do a head slap if cygwin all of a sudden magically works, lol.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

The current WILL change. Keep in mind, the APPEND mode. I am running that way right now, works fine.

Think again. We seek to end before writing.

What do you mean "works fine"? Does pot sync work fine? That is ALL this is about.

<!-- gh-comment-id:73305691 --> @magnumripper commented on GitHub (Feb 6, 2015): > The current WILL change. Keep in mind, the APPEND mode. I am running that way right now, works fine. Think again. We seek to end _before_ writing. What do you mean "works fine"? Does pot sync work fine? That is ALL this is about.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

No, I am saying that the return from lseek for SEEK_CUR and SEEK_END are the same. But under the hood, I am not sure they are the same. With the return being the same, the other logic (determining that some other process has dropped a hunk of .pot that we need to re-read) should be the same as it was before.

<!-- gh-comment-id:73305970 --> @jfoug commented on GitHub (Feb 6, 2015): No, I am saying that the return from lseek for SEEK_CUR and SEEK_END are the same. But under the hood, I am not sure they are the same. With the return being the same, the other logic (determining that some other process has dropped a hunk of .pot that we need to re-read) should be the same as it was before.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

No, I am saying that the return from lseek for SEEK_CUR and SEEK_END are the same

Of course they are, until someone else writes to the file.

<!-- gh-comment-id:73306132 --> @magnumripper commented on GitHub (Feb 6, 2015): > No, I am saying that the return from lseek for SEEK_CUR and SEEK_END are the same Of course they are, until someone else writes to the file.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Nope. Again, lseek(fp, SEEK_CUR) IF fp was opened in APPEND mode, does not give a shit about what the value was last time it checked. It will hit the OS and return the current end of file location. Now, if the file is exclusive locked, then the lseek(cur) will be the same location that we now write to. We then unlock. If 5 other processes add 500k of data to the file, and we later get exclusive to the file and lseek(cur), the value returned will still be the end of the file (500k bytes past the end of our last write).

<!-- gh-comment-id:73307096 --> @jfoug commented on GitHub (Feb 6, 2015): Nope. Again, lseek(fp, SEEK_CUR) IF fp was opened in APPEND mode, does not give a shit about what the value was last time it checked. It will hit the OS and return the current end of file location. Now, if the file is exclusive locked, then the lseek(cur) will be the same location that we now write to. We then unlock. If 5 other processes add 500k of data to the file, and we later get exclusive to the file and lseek(cur), the value returned will still be the end of the file (500k bytes past the end of our last write).
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

It probably does not matter either way. This made no change at all to either cygwin or to vboxsf systems (NFS is still to be seen). We can certainly keep the SEEK_END, but it does not matter at all.

<!-- gh-comment-id:73307197 --> @jfoug commented on GitHub (Feb 6, 2015): It probably does not matter either way. This made no change at all to either cygwin or to vboxsf systems (NFS is still to be seen). We can certainly keep the SEEK_END, but it does not matter at all.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

lseek(fp, SEEK_CUR) IF fp was opened in APPEND mode, does not give a shit about what the value was last time it checked. It will hit the OS and return the current end of file location.

Some implementation may work like you say (but that would waste resources), but that's not the spec. I hope you are not using vboxsf as any kind of reference as we have established it's very b0rken.

<!-- gh-comment-id:73307394 --> @magnumripper commented on GitHub (Feb 6, 2015): > lseek(fp, SEEK_CUR) IF fp was opened in APPEND mode, does not give a shit about what the value was last time it checked. It will hit the OS and return the current end of file location. Some implementation may work like you say (but that would waste resources), but that's not the spec. I hope you are not using vboxsf as any kind of reference as we have established it's very b0rken.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

lseek(fp, SEEK_CUR) IF fp was opened in APPEND mode, does not give a shit about what the value was last time it checked. It will hit the OS and return the current end of file location.

What you say is guaranteed AFTER writing and BEFORE releasing the lock. But not BEFORE writing, and that's where we do have the SEEK_END you questioned.

<!-- gh-comment-id:73307720 --> @magnumripper commented on GitHub (Feb 6, 2015): > lseek(fp, SEEK_CUR) IF fp was opened in APPEND mode, does not give a shit about what the value was last time it checked. It will hit the OS and return the current end of file location. What you say is guaranteed AFTER writing and BEFORE releasing the lock. But not BEFORE writing, and that's where we do have the SEEK_END you questioned.
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

I have only made a local change, and since it improved nothing, there is absolutely no reason to commit. I have been trying quite a bit to try to get cygwin working. vboxsf is not nearly as b0rked as cygwin. I 'can' get some runs to work out of it, but very few. Probably 75% of the time, a TS run will get part way through and deadlock.

<!-- gh-comment-id:73308313 --> @jfoug commented on GitHub (Feb 6, 2015): I have only made a local change, and since it improved nothing, there is absolutely no reason to commit. I have been trying quite a bit to try to get cygwin working. vboxsf is not nearly as b0rked as cygwin. I 'can' get some runs to work out of it, but very few. Probably 75% of the time, a TS run will get part way through and deadlock.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

I have a feeling you should open a separate issue for Cygwin and keep this one solely for vboxsf. We are confused enough without mixing them in one :-)

<!-- gh-comment-id:73308667 --> @magnumripper commented on GitHub (Feb 6, 2015): I have a feeling you should open a separate issue for Cygwin and keep this one solely for vboxsf. We are confused enough without mixing them in one :-)
Author
Owner

@jfoug commented on GitHub (Feb 6, 2015):

Ok. I doubt cygwin will get fixed, but an issue certainly is not a bad thing. At least it gives me a place to dump WHAT I have seen and tried, even if I do not get it, someone else that wants it enough, may pick it up and continue.

<!-- gh-comment-id:73308811 --> @jfoug commented on GitHub (Feb 6, 2015): Ok. I doubt cygwin will get fixed, but an issue certainly is not a bad thing. At least it gives me a place to dump WHAT I have seen and tried, even if I do not get it, someone else that wants it enough, may pick it up and continue.
Author
Owner

@magnumripper commented on GitHub (Feb 6, 2015):

With all we learnt here I think we could track down the actual problem in Cygwin. If nothing else, we should be able to describe the exact problem. It's just a matter of establishing exactly when things are starting to go bad.

<!-- gh-comment-id:73309209 --> @magnumripper commented on GitHub (Feb 6, 2015): With all we learnt here I think we could track down the actual problem in Cygwin. If nothing else, we should be able to describe the exact problem. It's just a matter of establishing exactly when things are starting to go bad.
Author
Owner

@magnumripper commented on GitHub (Feb 7, 2015):

Who knows, maybe the new fcntl() locking fixes your problem with vboxsf too.

<!-- gh-comment-id:73378975 --> @magnumripper commented on GitHub (Feb 7, 2015): Who knows, maybe the new fcntl() locking fixes your problem with vboxsf too.
Author
Owner

@magnumripper commented on GitHub (Feb 7, 2015):

I doubt cygwin will get fixed, but an issue certainly is not a bad thing.

😄

<!-- gh-comment-id:73379176 --> @magnumripper commented on GitHub (Feb 7, 2015): > I doubt cygwin will get fixed, but an issue certainly is not a bad thing. :smile:
Author
Owner

@jfoug commented on GitHub (Feb 7, 2015):

I doubt cygwin will get fixed, but an issue certainly is not a bad thing.

😄

😲

<!-- gh-comment-id:73381524 --> @jfoug commented on GitHub (Feb 7, 2015): > > I doubt cygwin will get fixed, but an issue certainly is not a bad thing. > > :smile: :astonished:
Author
Owner

@magnumripper commented on GitHub (Feb 7, 2015):

I doubt cygwin will get fixed, but an issue certainly is not a bad thing.

😄

😲

Quoting RFC 1925: With sufficient thrust, pigs fly just fine.

<!-- gh-comment-id:73384769 --> @magnumripper commented on GitHub (Feb 7, 2015): > > > I doubt cygwin will get fixed, but an issue certainly is not a bad thing. > > > > :smile: > > :astonished: Quoting [RFC 1925](https://tools.ietf.org/html/rfc1925): _With sufficient thrust, pigs fly just fine._
Author
Owner

@jfoug commented on GitHub (Feb 8, 2015):


On vboxfs with latest code:

$ ./flock-tst fail
this run is expected to TO FAIL on systems that have flock problems on non-existant files.
1
2
...
52
53
press ^C to break now, error was:  failed pot 1331  

Still failing. But I just checked build-info, and yes locking is fcntl(), BUT I also am built with memdbg=on and asan on. I will remove those and recheck.

Nope, fails just as bad, with or without memdbg and ASAN.

<!-- gh-comment-id:73391771 --> @jfoug commented on GitHub (Feb 8, 2015): ``` On vboxfs with latest code: $ ./flock-tst fail this run is expected to TO FAIL on systems that have flock problems on non-existant files. 1 2 ... 52 53 press ^C to break now, error was: failed pot 1331 ``` Still failing. But I just checked build-info, and yes locking is fcntl(), BUT I also am built with memdbg=on and asan on. I will remove those and recheck. Nope, fails just as bad, with or without memdbg and ASAN.
Author
Owner

@jfoug commented on GitHub (Feb 8, 2015):

Quoting RFC 1925: With sufficient thrust, pigs fly just fine.

But when quoting that truth, only telling a 1/3 truth is unwise:

(3) With sufficient thrust, pigs fly just fine. However, this is
not necessarily a good idea. It is hard to be sure where they
are going to land, and it could be dangerous sitting under them
as they fly overhead.

<!-- gh-comment-id:73392053 --> @jfoug commented on GitHub (Feb 8, 2015): > Quoting RFC 1925: _With sufficient thrust, pigs fly just fine._ But when quoting that truth, only telling a 1/3 truth is unwise: _(3) With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead._
Author
Owner

@jfoug commented on GitHub (Feb 8, 2015):

I am just glad cygwin is working. I still am getting a machine lock up, but i think it is in the same format. I will lock the machine up again and make sure that the TS window is on top, so I can watch it ;)

I think it is one of the formats that has a flock in it (dmg_format ?) Nope, not that one. Well, I will run and make sure I write down where it crashed (after saving my desktop for quick restart, lol).

<!-- gh-comment-id:73392131 --> @jfoug commented on GitHub (Feb 8, 2015): I am just glad cygwin is working. I still am getting a machine lock up, but i think it is in the same format. I will lock the machine up again and make sure that the TS window is on top, so I can watch it ;) I think it is one of the formats that has a flock in it (dmg_format ?) Nope, not that one. Well, I will run and make sure I write down where it crashed (after saving my desktop for quick restart, lol).
Author
Owner

@magnumripper commented on GitHub (Feb 8, 2015):

dmg format has locking in some debug code iirc, not otherwise.

<!-- gh-comment-id:73393084 --> @magnumripper commented on GitHub (Feb 8, 2015): dmg format has locking in some debug code iirc, not otherwise.
Author
Owner

@jfoug commented on GitHub (Feb 8, 2015):

Are we happy with this issue?

The original problem I made this issue for still stands, but now we KNOW the work around. That is the corrupted files on vboxfs. That is Oracle's problem. If we run with the .pot file (and .log file) being on disk, then vboxfs works just fine. So that being the case, we really can not do much to fix John to fix this problem, other than creating and closing a zero byte .pot/.log file when john starts, IF they do not exist prior to the forking code launching children.

<!-- gh-comment-id:73408417 --> @jfoug commented on GitHub (Feb 8, 2015): Are we happy with this issue? The original problem I made this issue for still stands, but now we KNOW the work around. That is the corrupted files on vboxfs. That is Oracle's problem. If we run with the .pot file (and .log file) being on disk, then vboxfs works just fine. So that being the case, we really can not do much to fix John to fix this problem, other than creating and closing a zero byte .pot/.log file when john starts, IF they do not exist prior to the forking code launching children.
Author
Owner

@magnumripper commented on GitHub (Feb 8, 2015):

Yes. It should be reported to Oracle and I think we can close this. You could add some text in doc/BUGS if you like, describing the known issue and workaround.

<!-- gh-comment-id:73426192 --> @magnumripper commented on GitHub (Feb 8, 2015): Yes. It should be reported to Oracle and I think we can close this. You could add some text in doc/BUGS if you like, describing the known issue and workaround.
Author
Owner

@magnumripper commented on GitHub (Feb 9, 2015):

On a side note I did heavy testing of these things all day today and I did find some interesting (frightening) facts. For example, a bog standard NFS share with Linux server and Linux clients: Client could lock, other clients would see the lock. But the server's native filesystem (at "same" directory) would NOT see clients' locks nor share its locks with the clients. This means you can run over NFS (required for MPI) just fine but you must NOT run any JtR process on the NFS server itself.

Just in case some random googler find this: The above was 100% fixed when we switched to fcntl() locks instead of flock().

<!-- gh-comment-id:73576510 --> @magnumripper commented on GitHub (Feb 9, 2015): > On a side note I did heavy testing of these things all day today and I did find some interesting (frightening) facts. For example, a bog standard NFS share with Linux server and Linux clients: Client could lock, other clients would see the lock. But the server's native filesystem (at "same" directory) would NOT see clients' locks nor share its locks with the clients. This means you can run over NFS (required for MPI) just fine but you must NOT run any JtR process on the NFS server itself. Just in case some random googler find this: The above was 100% fixed when we switched to fcntl() locks instead of flock().
Author
Owner

@jfoug commented on GitHub (Feb 9, 2015):

That is really good to hear that fcntl() works better. I was hoping that was the case, once I found the older documentation listing that it handled NFS correctly. I think the older BSD flock interface simply has not been given the same usage as fcntl, and thus bugs are not fixed as frequently.

Looking back, this was a pretty long thread over a bug. One of our longer ones. Both of us had to unlearn a few things we thought were true and also learn a few things we did not know about.

<!-- gh-comment-id:73580244 --> @jfoug commented on GitHub (Feb 9, 2015): That is really good to hear that fcntl() works better. I was hoping that was the case, once I found the older documentation listing that it handled NFS correctly. I think the older BSD flock interface simply has not been given the same usage as fcntl, and thus bugs are not fixed as frequently. Looking back, this was a pretty long thread over a bug. One of our longer ones. Both of us had to unlearn a few things we thought were true and also learn a few things we did not know about.
Author
Owner

@magnumripper commented on GitHub (Feb 9, 2015):

Learning is easy, unlearning is the tricky shit! I was almost sure there would be no difference because I thought flock() was using fcntl() for NFS (at least). But this is now unlearned. I'm glad I tested it.

BTW I wrote a clone of flock(1) that was using fcntl instead just for testing. Maybe I should publish it somewhere.

<!-- gh-comment-id:73593962 --> @magnumripper commented on GitHub (Feb 9, 2015): Learning is easy, unlearning is the tricky shit! I was almost sure there would be no difference because I thought flock() was using fcntl() for NFS (at least). But this is now unlearned. I'm glad I tested it. BTW I wrote a clone of flock(1) that was using fcntl instead just for testing. Maybe I should publish it somewhere.
Author
Owner

@magnumripper commented on GitHub (Feb 9, 2015):

Maybe I should publish it somewhere.

Heck, why not! https://github.com/magnumripper/fcntl-lock

<!-- gh-comment-id:73596771 --> @magnumripper commented on GitHub (Feb 9, 2015): > Maybe I should publish it somewhere. Heck, why not! https://github.com/magnumripper/fcntl-lock
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#645
No description provided.