From 125e9ec86389f9e1da396190fcb79414e1e7afc8 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 9 Mar 2020 11:13:43 +0100 Subject: [PATCH 1/3] Do not redirect stderr to /dev/null to prevent rocm 3.1 from crashing on debian --- src/backend.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/backend.c b/src/backend.c index de6ce9c5d..7e7caee89 100644 --- a/src/backend.c +++ b/src/backend.c @@ -369,32 +369,7 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; - // LLVM seems to write an error message (if there's an error) directly to stderr - // and not (as supposted to) into buffer for later request using clGetProgramBuildInfo() - - #ifndef DEBUG - #ifndef _WIN - fflush (stderr); - int bak = fcntl(2, F_DUPFD_CLOEXEC); - int tmp = open ("/dev/null", O_WRONLY | O_CLOEXEC); - dup2 (tmp, 2); - close (tmp); - #endif - #endif - - int CL_rc = ocl->clBuildProgram (program, 1, &device, "-Werror", NULL, NULL); // do not use the wrapper to avoid the error message - - #ifndef DEBUG - #ifndef _WIN - fflush (stderr); - #ifndef __APPLE__ - dup3 (bak, 2, O_CLOEXEC); - #else - dup2 (bak, 2); - #endif - close (bak); - #endif - #endif + const int CL_rc = ocl->clBuildProgram (program, 1, &device, NULL, NULL, NULL); if (CL_rc != CL_SUCCESS) { From 3e4d110fd21271e1d2765fc7c47cbf0dc3d0f1b7 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 9 Mar 2020 20:05:23 +0100 Subject: [PATCH 2/3] Add stderr redirection the regular way --- src/backend.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/backend.c b/src/backend.c index 7e7caee89..b020825e9 100644 --- a/src/backend.c +++ b/src/backend.c @@ -369,8 +369,26 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; + const int fd_stderr = fileno (stderr); + + #ifndef DEBUG + const int stderr_bak = dup (fd_stderr); + #ifdef _WIN + const int tmp = open ("NIL", O_WRONLY); + #else + const int tmp = open ("/dev/null", O_WRONLY); + #endif + dup2 (tmp, fd_stderr); + close (tmp); + #endif + const int CL_rc = ocl->clBuildProgram (program, 1, &device, NULL, NULL, NULL); + #ifndef DEBUG + dup2 (stderr_bak, fd_stderr); + close (stderr_bak); + #endif + if (CL_rc != CL_SUCCESS) { #if defined (DEBUG) From 8c3808bad5f5ff07b8428e98c84ae310a164e5f5 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 9 Mar 2020 20:12:36 +0100 Subject: [PATCH 3/3] Fix NUL filename on windows --- src/backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index b020825e9..1989359a9 100644 --- a/src/backend.c +++ b/src/backend.c @@ -374,7 +374,7 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont #ifndef DEBUG const int stderr_bak = dup (fd_stderr); #ifdef _WIN - const int tmp = open ("NIL", O_WRONLY); + const int tmp = open ("NUL", O_WRONLY); #else const int tmp = open ("/dev/null", O_WRONLY); #endif