Skip to content

Commit

Permalink
Workaround clang bug on OSX when the tls variable is too large
Browse files Browse the repository at this point in the history
By allocating the buffer at runtime with `mmap`.

Fixes #15647
  • Loading branch information
yuyichao committed Apr 16, 2016
1 parent b991db1 commit 698e107
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/julia_threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ typedef struct _jl_tls_states_t {
jl_jmp_buf *safe_restore;
int16_t tid;
size_t bt_size;
uintptr_t bt_data[JL_MAX_BT_SIZE + 1];
// JL_MAX_BT_SIZE + 1 elements long
uintptr_t *bt_data;
} jl_tls_states_t;

#ifdef __MIC__
Expand Down
7 changes: 7 additions & 0 deletions src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ static void ti_initthread(int16_t tid)
ptls->pgcstack = NULL;
ptls->gc_state = 0; // GC unsafe
ptls->current_module = NULL;
void *bt_data = malloc(sizeof(uintptr_t) * (JL_MAX_BT_SIZE + 1));
if (bt_data == NULL) {
jl_printf(JL_STDERR, "could not allocate backtrace buffer\n");
gc_debug_critical_error();
abort();
}
ptls->bt_data = (uintptr_t*)bt_data;
#ifdef JULIA_ENABLE_THREADING
jl_all_heaps[tid] = jl_mk_thread_heap();
#else
Expand Down

0 comments on commit 698e107

Please sign in to comment.