[GH-ISSUE #2135] Segfault with descrypt-opencl #1423

Closed
opened 2026-10-15 04:16:45 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @tomtastic on GitHub (May 13, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2135

Git clone as of : Fri 13 May 2016 15:45:01 BST

Complied with :

$ CPPFLAGS="-I/Users/trcm/Documents/src/openssl-0.9.8zh/include" CFLAGS="-I/Users/trcm/Documents/src/openssl-0.9.8zh/include" OPENSSL_CFLAGS="-I/Users/trcm/Documents/src/openssl-0.9.8zh/include" OPENSSL_LIBS="-L/Users/trcm/Documents/src/openssl-0.9.8zh/lib -lssl -lcrypto -lz" ./configure --disable-cuda; make -s clean && make -s
Configured for building John the Ripper jumbo:

Target CPU ................................. x86_64 AVX2, 64-bit LE
AES-NI support ............................. depends on OpenSSL
Target OS .................................. darwin15.4.0
Cross compiling ............................ no
Legacy arch header ......................... x86-64.h

Optional libraries/features found:
Fuzzing test ............................... no
Experimental code .......................... no
OpenMPI support (default disabled) ......... no
Fork support ............................... yes
OpenMP support ............................. no
CUDA support (default disabled by OpenCL) .. no
OpenCL support ............................. yes
Generic crypt(3) format .................... yes
Rexgen (extra cracking mode) ............... no
GMP (PRINCE mode and faster SRP formats) ... no
PCAP (vncpcap2john and SIPdump) ............ yes
Z (pkzip format, gpg2john) ................. yes
BZ2 (gpg2john extra decompression logic) ... yes
128-bit integer (faster PRINCE mode) ....... yes
Memory map (share/page large files) ........ yes

Development options (these may hurt performance when enabled):
Memdbg memory debugging settings ........... disabled
AddressSanitizer ("ASan") .................. disabled
UndefinedBehaviorSanitizer ("UbSan") ....... disabled

Install missing libraries to get any needed features that were omitted.

Configure finished.  Now 'make clean && make -s' to compile.
opencl_phpass_fmt_plug.c:54:19: warning: unused variable 'phpassH_prefix' [-Wunused-const-variable]
static const char phpassH_prefix[] = "$H$";
                  ^
1 warning generated.
ar: creating archive aes.a
clang: warning: argument unused during compilation: '-pthread'
clang: warning: argument unused during compilation: '-pthread'

Make process completed.

Build info :

Version: 1.8.0-jumbo-1-4891-ge1d58d9
Build: darwin15.4.0 64-bit AVX2-ac
SIMD: AVX2, interleaving: MD4:4 MD5:5 SHA1:2 SHA256:1 SHA512:1
$JOHN is ./
Format interface version: 13
Max. number of reported tunable costs: 3
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
Max. Markov mode level: 400
Max. Markov mode password length: 30
clang version: 7.3.0 (clang-703.0.31) (gcc 4.2.1 compatibility)
OpenCL headers version: 1.2
Crypto library: OpenSSL
OpenSSL library version: 00090821f  (loaded: 0009081df)
OpenSSL 0.9.8zh 3 Dec 2015  (loaded: OpenSSL 0.9.8zh 14 Jan 2016)
File locking: fcntl()
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): System's

OpenCL devices :

   Platform #0 name: Apple, version: OpenCL 1.2 (Feb  7 2016 15:43:50)
    Device #0 (0) name:     Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
    Device vendor:          Intel
    Device type:            CPU (LE)
    Device version:         OpenCL 1.2 
    Driver version:         1.1 
    Native vector widths:   char 16, short 8, int 4, long 2
    Preferred vector width: char 16, short 8, int 4, long 2
    Global Memory:          8.0 GB
    Global Memory Cache:    64.0  B
    Local Memory:           32.0 KB (Global)
    Max memory alloc. size: 2.0 GB
    Max clock (MHz):        2900
    Profiling timer res.:   1 ns
    Max Work Group Size:    1024
    Parallel compute cores: 4
    Speed index:            46400

   Device #1 (1) name:     Intel(R) Iris(TM) Graphics 6100
    Device vendor:          Intel Inc.
    Device type:            GPU (LE)
    Device version:         OpenCL 1.2 
    Driver version:         1.2(Feb 26 2016 23:23:58) 
    Native vector widths:   char 1, short 1, int 1, long 1
    Preferred vector width: char 1, short 1, int 1, long 1
    Global Memory:          1.0 GB
    Local Memory:           64.0 KB (Local)
    Max memory alloc. size: 384.3 MB
    Max clock (MHz):        1100
    Profiling timer res.:   80 ns
    Max Work Group Size:    256
    Parallel compute cores: 48
    Speed index:            52800

Segmentation fault under lldb :

0 trcm:~/Documents/src/JohnTheRipper/run $ lldb -- ./john passwd.db --form=descrypt-opencl
(lldb) target create "./john"
Current executable set to './john' (x86_64).
(lldb) settings set -- target.run-args  "passwd.db" "--form=descrypt-opencl"
(lldb) r
Process 69710 launched: './john' (x86_64)
Device 1: Intel(R) Iris(TM) Graphics 6100
Using default input encoding: UTF-8
Loaded 2 password hashes with 2 different salts (descrypt-opencl, traditional crypt(3) [DES OpenCL])
Binary Build log: <program source>:116:12: warning: comparison of integers of different signs: 'unsigned int' and 'int'
                if (mask != ~(int)0) {
      ~~~~ ^  ~~~~~~~

Binary Build log: <program source>:116:12: warning: comparison of integers of different signs: 'unsigned int' and 'int'
                if (mask != ~(int)0) {
      ~~~~ ^  ~~~~~~~

Press 'q' or Ctrl-C to abort, almost any other key for status
Process 69710 stopped
* thread #1: tid = 0x14941c, 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635
OpenCL`___lldb_unnamed_function411$$OpenCL:
->  0x7fff96dc9c6b <+1635>: movq   (%r12), %rax
    0x7fff96dc9c6f <+1639>: movq   %r12, %rdi
    0x7fff96dc9c72 <+1642>: callq  *0x20(%rax)
    0x7fff96dc9c75 <+1645>: testb  $0x8, (%rax)
(lldb) bt
* thread #1: tid = 0x14941c, 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635
    frame #1: 0x00007fff96dca044 OpenCL`clEnqueueNDRangeKernel + 125
    frame #2: 0x0000000100263e20 john`___lldb_unnamed_function4785$$john + 608
    frame #3: 0x00000001003f68fb john`___lldb_unnamed_function8186$$john + 123
    frame #4: 0x00000001003f67a7 john`___lldb_unnamed_function8185$$john + 391
    frame #5: 0x000000010042e6a3 john`___lldb_unnamed_function8526$$john + 19
    frame #6: 0x000000010042eeb6 john`___lldb_unnamed_function8527$$john + 1526
    frame #7: 0x000000010042e487 john`___lldb_unnamed_function8525$$john + 583
    frame #8: 0x000000010042e0e6 john`___lldb_unnamed_function8524$$john + 118
    frame #9: 0x000000010042dbd4 john`___lldb_unnamed_function8517$$john + 564
    frame #10: 0x000000010042d600 john`___lldb_unnamed_function8515$$john + 64
    frame #11: 0x00000001003e9a4e john`___lldb_unnamed_function8037$$john + 14
    frame #12: 0x00000001003e999e john`___lldb_unnamed_function8036$$john + 110
    frame #13: 0x0000000100404947 john`___lldb_unnamed_function8283$$john + 1719
    frame #14: 0x0000000100403a86 john`___lldb_unnamed_function8280$$john + 1174
    frame #15: 0x00007fff8f3535ad libdyld.dylib`start + 1
(lldb) q
Originally created by @tomtastic on GitHub (May 13, 2016). Original GitHub issue: https://github.com/openwall/john/issues/2135 **Git clone as of :** Fri 13 May 2016 15:45:01 BST **Complied with :** ``` $ CPPFLAGS="-I/Users/trcm/Documents/src/openssl-0.9.8zh/include" CFLAGS="-I/Users/trcm/Documents/src/openssl-0.9.8zh/include" OPENSSL_CFLAGS="-I/Users/trcm/Documents/src/openssl-0.9.8zh/include" OPENSSL_LIBS="-L/Users/trcm/Documents/src/openssl-0.9.8zh/lib -lssl -lcrypto -lz" ./configure --disable-cuda; make -s clean && make -s Configured for building John the Ripper jumbo: Target CPU ................................. x86_64 AVX2, 64-bit LE AES-NI support ............................. depends on OpenSSL Target OS .................................. darwin15.4.0 Cross compiling ............................ no Legacy arch header ......................... x86-64.h Optional libraries/features found: Fuzzing test ............................... no Experimental code .......................... no OpenMPI support (default disabled) ......... no Fork support ............................... yes OpenMP support ............................. no CUDA support (default disabled by OpenCL) .. no OpenCL support ............................. yes Generic crypt(3) format .................... yes Rexgen (extra cracking mode) ............... no GMP (PRINCE mode and faster SRP formats) ... no PCAP (vncpcap2john and SIPdump) ............ yes Z (pkzip format, gpg2john) ................. yes BZ2 (gpg2john extra decompression logic) ... yes 128-bit integer (faster PRINCE mode) ....... yes Memory map (share/page large files) ........ yes Development options (these may hurt performance when enabled): Memdbg memory debugging settings ........... disabled AddressSanitizer ("ASan") .................. disabled UndefinedBehaviorSanitizer ("UbSan") ....... disabled Install missing libraries to get any needed features that were omitted. Configure finished. Now 'make clean && make -s' to compile. opencl_phpass_fmt_plug.c:54:19: warning: unused variable 'phpassH_prefix' [-Wunused-const-variable] static const char phpassH_prefix[] = "$H$"; ^ 1 warning generated. ar: creating archive aes.a clang: warning: argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' Make process completed. ``` **Build info :** ``` Version: 1.8.0-jumbo-1-4891-ge1d58d9 Build: darwin15.4.0 64-bit AVX2-ac SIMD: AVX2, interleaving: MD4:4 MD5:5 SHA1:2 SHA256:1 SHA512:1 $JOHN is ./ Format interface version: 13 Max. number of reported tunable costs: 3 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 Max. Markov mode level: 400 Max. Markov mode password length: 30 clang version: 7.3.0 (clang-703.0.31) (gcc 4.2.1 compatibility) OpenCL headers version: 1.2 Crypto library: OpenSSL OpenSSL library version: 00090821f (loaded: 0009081df) OpenSSL 0.9.8zh 3 Dec 2015 (loaded: OpenSSL 0.9.8zh 14 Jan 2016) File locking: fcntl() fseek(): fseek ftell(): ftell fopen(): fopen memmem(): System's ``` **OpenCL devices :** ``` Platform #0 name: Apple, version: OpenCL 1.2 (Feb 7 2016 15:43:50) Device #0 (0) name: Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz Device vendor: Intel Device type: CPU (LE) Device version: OpenCL 1.2 Driver version: 1.1 Native vector widths: char 16, short 8, int 4, long 2 Preferred vector width: char 16, short 8, int 4, long 2 Global Memory: 8.0 GB Global Memory Cache: 64.0 B Local Memory: 32.0 KB (Global) Max memory alloc. size: 2.0 GB Max clock (MHz): 2900 Profiling timer res.: 1 ns Max Work Group Size: 1024 Parallel compute cores: 4 Speed index: 46400 Device #1 (1) name: Intel(R) Iris(TM) Graphics 6100 Device vendor: Intel Inc. Device type: GPU (LE) Device version: OpenCL 1.2 Driver version: 1.2(Feb 26 2016 23:23:58) Native vector widths: char 1, short 1, int 1, long 1 Preferred vector width: char 1, short 1, int 1, long 1 Global Memory: 1.0 GB Local Memory: 64.0 KB (Local) Max memory alloc. size: 384.3 MB Max clock (MHz): 1100 Profiling timer res.: 80 ns Max Work Group Size: 256 Parallel compute cores: 48 Speed index: 52800 ``` **Segmentation fault under lldb :** ``` 0 trcm:~/Documents/src/JohnTheRipper/run $ lldb -- ./john passwd.db --form=descrypt-opencl (lldb) target create "./john" Current executable set to './john' (x86_64). (lldb) settings set -- target.run-args "passwd.db" "--form=descrypt-opencl" (lldb) r Process 69710 launched: './john' (x86_64) Device 1: Intel(R) Iris(TM) Graphics 6100 Using default input encoding: UTF-8 Loaded 2 password hashes with 2 different salts (descrypt-opencl, traditional crypt(3) [DES OpenCL]) Binary Build log: <program source>:116:12: warning: comparison of integers of different signs: 'unsigned int' and 'int' if (mask != ~(int)0) { ~~~~ ^ ~~~~~~~ Binary Build log: <program source>:116:12: warning: comparison of integers of different signs: 'unsigned int' and 'int' if (mask != ~(int)0) { ~~~~ ^ ~~~~~~~ Press 'q' or Ctrl-C to abort, almost any other key for status Process 69710 stopped * thread #1: tid = 0x14941c, 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635 OpenCL`___lldb_unnamed_function411$$OpenCL: -> 0x7fff96dc9c6b <+1635>: movq (%r12), %rax 0x7fff96dc9c6f <+1639>: movq %r12, %rdi 0x7fff96dc9c72 <+1642>: callq *0x20(%rax) 0x7fff96dc9c75 <+1645>: testb $0x8, (%rax) (lldb) bt * thread #1: tid = 0x14941c, 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) * frame #0: 0x00007fff96dc9c6b OpenCL`___lldb_unnamed_function411$$OpenCL + 1635 frame #1: 0x00007fff96dca044 OpenCL`clEnqueueNDRangeKernel + 125 frame #2: 0x0000000100263e20 john`___lldb_unnamed_function4785$$john + 608 frame #3: 0x00000001003f68fb john`___lldb_unnamed_function8186$$john + 123 frame #4: 0x00000001003f67a7 john`___lldb_unnamed_function8185$$john + 391 frame #5: 0x000000010042e6a3 john`___lldb_unnamed_function8526$$john + 19 frame #6: 0x000000010042eeb6 john`___lldb_unnamed_function8527$$john + 1526 frame #7: 0x000000010042e487 john`___lldb_unnamed_function8525$$john + 583 frame #8: 0x000000010042e0e6 john`___lldb_unnamed_function8524$$john + 118 frame #9: 0x000000010042dbd4 john`___lldb_unnamed_function8517$$john + 564 frame #10: 0x000000010042d600 john`___lldb_unnamed_function8515$$john + 64 frame #11: 0x00000001003e9a4e john`___lldb_unnamed_function8037$$john + 14 frame #12: 0x00000001003e999e john`___lldb_unnamed_function8036$$john + 110 frame #13: 0x0000000100404947 john`___lldb_unnamed_function8283$$john + 1719 frame #14: 0x0000000100403a86 john`___lldb_unnamed_function8280$$john + 1174 frame #15: 0x00007fff8f3535ad libdyld.dylib`start + 1 (lldb) q ```
Author
Owner

@solardiz commented on GitHub (Aug 10, 2016):

The crash seen in this report is a NULL pointer dereference in the OpenCL so-called driver in code running on the CPU. Since the target device was the (embedded) GPU rather than CPU, this suggests to me it's more likely a bug in the driver rather than in our code. My reasoning is that our code is supposed to be run on the GPU, not on the CPU - well, except possibly for compile-time evaluation of constant expressions, but here we see the crash happen after a successful build of the kernel had completed (and in fact after it's been successfully self-tested, so it's not even the first invocation). It could also be a bug in our code other than the OpenCL kernel itself, causing improper use of OpenCL APIs or a memory overwrite. There are many possibilities here.

This CPU will likely run our non-OpenCL descrypt format much faster on its CPU cores, with AVX2, than it will run descrypt-opencl on the embedded GPU, even if/when whatever bug shows up here is fixed or goes away. Of course, you could run both at once, if it worked, and of course, it'd be nice to find and fix the bug regardless, but it's tough.

<!-- gh-comment-id:238835842 --> @solardiz commented on GitHub (Aug 10, 2016): The crash seen in this report is a NULL pointer dereference in the OpenCL so-called driver in code running on the CPU. Since the target device was the (embedded) GPU rather than CPU, this suggests to me it's more likely a bug in the driver rather than in our code. My reasoning is that our code is supposed to be run on the GPU, not on the CPU - well, except possibly for compile-time evaluation of constant expressions, but here we see the crash happen after a successful build of the kernel had completed (and in fact after it's been successfully self-tested, so it's not even the first invocation). It could also be a bug in our code other than the OpenCL kernel itself, causing improper use of OpenCL APIs or a memory overwrite. There are many possibilities here. This CPU will likely run our non-OpenCL descrypt format much faster on its CPU cores, with AVX2, than it will run descrypt-opencl on the embedded GPU, even if/when whatever bug shows up here is fixed or goes away. Of course, you could run both at once, if it worked, and of course, it'd be nice to find and fix the bug regardless, but it's tough.
Author
Owner

@solardiz commented on GitHub (Aug 10, 2016):

FWIW, descrypt-opencl works for me on Linux with HD 4600 (in i7-4770K), but as expected delivers performance several times lower than descrypt on the CPU cores does (with AVX2). It also works simultaneously with descrypt on the CPU, so the total performance for the chip is increased slightly compared to using the CPU cores alone. When running against 10 descrypt hashes with 10 different salts, I get these speeds (c/s): GPU: 5.8M, CPU OpenMP: 41M, CPU --fork=8: 5.6M*8 = 44.8M. So the embedded GPU adds only 11.5% for this format (on top of --fork=8's speed). Maybe Iris 6100 would add more, but probably not a lot more. (For some other formats, things are not as bad, e.g. for md5crypt using i7-4770K's embedded GPU adds ~30% on top of the CPU, or 1/4 of total cumulative speed.)

<!-- gh-comment-id:238883050 --> @solardiz commented on GitHub (Aug 10, 2016): FWIW, descrypt-opencl works for me on Linux with HD 4600 (in i7-4770K), but as expected delivers performance several times lower than descrypt on the CPU cores does (with AVX2). It also works simultaneously with descrypt on the CPU, so the total performance for the chip is increased slightly compared to using the CPU cores alone. When running against 10 descrypt hashes with 10 different salts, I get these speeds (c/s): GPU: 5.8M, CPU OpenMP: 41M, CPU --fork=8: 5.6M*8 = 44.8M. So the embedded GPU adds only 11.5% for this format (on top of --fork=8's speed). Maybe Iris 6100 would add more, but probably not a lot more. (For some other formats, things are not as bad, e.g. for md5crypt using i7-4770K's embedded GPU adds ~30% on top of the CPU, or 1/4 of total cumulative speed.)
Author
Owner

@solardiz commented on GitHub (Jun 9, 2024):

With no news on this in 8 years, it's not an issue we need to track.

<!-- gh-comment-id:2156657492 --> @solardiz commented on GitHub (Jun 9, 2024): With no news on this in 8 years, it's not an issue we need to track.
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#1423
No description provided.