diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-05-07 10:21:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-07 10:21:16 +0100 |
| commit | 90a30a145af7a8f75f95fe38817667efb00452db (patch) | |
| tree | b35da071ab68e811fd7b34ffd5d4061873792061 /src/llvm_backend_general.cpp | |
| parent | 7c1a9f1e7a769f17fcd74699b0f4ea89a077b50b (diff) | |
| parent | 46e0c7ad74d0868d473dfd95a455dbe8a64bacbf (diff) | |
Merge pull request #5122 from Lperlind/asan-allocators
Add asan support for various allocators and stack unpoisoning
Diffstat (limited to 'src/llvm_backend_general.cpp')
| -rw-r--r-- | src/llvm_backend_general.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 421720c4c..dad5d4dd5 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -3070,6 +3070,13 @@ gb_internal lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e, bool zero if (e != nullptr) { lb_add_entity(p->module, e, val); lb_add_debug_local_variable(p, ptr, type, e->token); + + // NOTE(lucas): In LLVM 20 and below we do not have the option to have asan cleanup poisoned stack + // locals ourselves. So we need to manually track and unpoison these locals on proc return. + // LLVM 21 adds the 'use-after-scope' asan option which does this for us. + if (build_context.sanitizer_flags & SanitizerFlag_Address && !p->entity->Procedure.no_sanitize_address) { + array_add(&p->asan_stack_locals, val); + } } if (zero_init) { |