fix await multithreaded data race

coro return was reading from a value that coro await was
writing to. that wasn't how it was designed to work, it
was an implementation mistake.

this commit also has some work-in-progress code for fixing
error return traces across suspend points.
This commit is contained in:
Andrew Kelley
2018-03-10 01:12:22 -05:00
parent 3b3649b86f
commit 84e952c230
6 changed files with 111 additions and 22 deletions

View File

@@ -4251,6 +4251,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
case IrInstructionIdExport:
case IrInstructionIdErrorUnion:
case IrInstructionIdPromiseResultType:
case IrInstructionIdAwaitBookkeeping:
zig_unreachable();
case IrInstructionIdReturn:
@@ -5279,7 +5280,7 @@ static void do_code_gen(CodeGen *g) {
uint32_t err_ret_trace_arg_index = get_err_ret_trace_arg_index(g, fn_table_entry);
if (err_ret_trace_arg_index != UINT32_MAX) {
g->cur_err_ret_trace_val = LLVMGetParam(fn, err_ret_trace_arg_index);
} else if (g->have_err_ret_tracing && fn_table_entry->calls_errorable_function) {
} else if (g->have_err_ret_tracing && fn_table_entry->calls_or_awaits_errorable_fn) {
// TODO call graph analysis to find out what this number needs to be for every function
static const size_t stack_trace_ptr_count = 30;