Fixed OSX stack overflow - v2

pull/552/head
Gabriele Gristina 8 years ago
parent dbe60b845b
commit e7406bec33

@ -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)

@ -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);
@ -230,14 +230,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);
@ -665,13 +706,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++;
}

@ -231,9 +231,7 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
// hash
char *out_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
if (!out_buf) return;
char out_buf[HCBUFSIZ_LARGE];
out_buf[0] = 0;
@ -278,8 +276,6 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
const int tmp_len = outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, tmp_buf);
free (out_buf);
outfile_write_close (hashcat_ctx);
EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len);

@ -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++;
}

@ -256,9 +256,7 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
if (potfile_ctx->enabled == false) return;
char *tmp_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE);
if (!tmp_buf) return;
char tmp_buf[HCBUFSIZ_LARGE];
int tmp_len = 0;
@ -302,8 +300,6 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
tmp_buf[tmp_len] = 0;
fprintf (potfile_ctx->fp, "%s" EOL, tmp_buf);
free (tmp_buf);
}
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)

Loading…
Cancel
Save