1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-22 21:51:07 +00:00

Merge pull request #552 from matrix/master

Fix OSX segfault on check_hash()
This commit is contained in:
Jens Steube 2016-10-30 14:00:35 +01:00 committed by GitHub
commit cf1c133678
3 changed files with 49 additions and 8 deletions

View File

@ -18,7 +18,7 @@
#if defined (_WIN)
#define hc_thread_create(t,f,a) t = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) &f, a, 0, NULL)
#define hc_thread_create(t,T,f,a) t = CreateThread (T, 0, (LPTHREAD_START_ROUTINE) &f, a, 0, NULL)
#define hc_thread_wait(n,a) for (u32 i = 0; i < n; i++) WaitForSingleObject ((a)[i], INFINITE)
#define hc_thread_exit(t) ExitThread (t)
@ -29,7 +29,7 @@
#elif defined (_POSIX)
#define hc_thread_create(t,f,a) pthread_create (&t, NULL, f, a)
#define hc_thread_create(t,T,f,a) pthread_create (&t, T, f, a)
#define hc_thread_wait(n,a) for (u32 i = 0; i < n; i++) pthread_join ((a)[i], NULL)
#define hc_thread_exit(t) pthread_exit (&t)

View File

@ -179,7 +179,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
thread_param->hashcat_ctx = hashcat_ctx;
thread_param->tid = device_id;
hc_thread_create (c_threads[device_id], thread_autotune, thread_param);
hc_thread_create (c_threads[device_id], NULL, thread_autotune, thread_param);
}
hc_thread_wait (opencl_ctx->devices_cnt, c_threads);
@ -232,14 +232,55 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
thread_param->hashcat_ctx = hashcat_ctx;
thread_param->tid = device_id;
#if defined (__APPLE__)
size_t stackSize;
pthread_attr_t tattr;
pthread_attr_t *attrp = NULL;
if (pthread_attr_init (&tattr) != 0)
{
event_log_error (hashcat_ctx, "Failed to initialize thread attributes");
return -1;
}
if (pthread_attr_getstacksize (&tattr, &stackSize) != 0)
{
event_log_error (hashcat_ctx, "Failed to get thread stack size");
return -1;
}
if (stackSize == 0) stackSize = PTHREAD_STACK_MIN;
stackSize *= 2; // mitigate OSX stack overflow
if (pthread_attr_setstacksize (&tattr, stackSize) != 0)
{
event_log_error (hashcat_ctx, "Failed to set thread stack size");
return -1;
}
attrp = &tattr;
#endif
if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
{
hc_thread_create (c_threads[device_id], thread_calc_stdin, thread_param);
#if defined (__APPLE__)
hc_thread_create (c_threads[device_id], attrp, thread_calc_stdin, thread_param);
#else
hc_thread_create (c_threads[device_id], NULL, thread_calc_stdin, thread_param);
#endif
}
else
{
hc_thread_create (c_threads[device_id], thread_calc, thread_param);
#if defined (__APPLE__)
hc_thread_create (c_threads[device_id], attrp, thread_calc, thread_param);
#else
hc_thread_create (c_threads[device_id], NULL, thread_calc, thread_param);
#endif
}
#if defined (__APPLE__)
if (attrp) pthread_attr_destroy (attrp);
#endif
}
hc_thread_wait (opencl_ctx->devices_cnt, c_threads);
@ -669,13 +710,13 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false && user_options->speed_only == false)
{
hc_thread_create (inner_threads[inner_threads_cnt], thread_monitor, hashcat_ctx);
hc_thread_create (inner_threads[inner_threads_cnt], NULL, thread_monitor, hashcat_ctx);
inner_threads_cnt++;
if (outcheck_ctx->enabled == true)
{
hc_thread_create (inner_threads[inner_threads_cnt], thread_outfile_remove, hashcat_ctx);
hc_thread_create (inner_threads[inner_threads_cnt], NULL, thread_outfile_remove, hashcat_ctx);
inner_threads_cnt++;
}

View File

@ -170,7 +170,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA
{
// see thread_keypress() how to access status information
hc_thread_create (hashcat_user->outer_threads[hashcat_user->outer_threads_cnt], thread_keypress, hashcat_ctx);
hc_thread_create (hashcat_user->outer_threads[hashcat_user->outer_threads_cnt], NULL, thread_keypress, hashcat_ctx);
hashcat_user->outer_threads_cnt++;
}