Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AddressSanitizerUseAfterScope

Evgeniy Stepanov edited this pageApr 4, 2017 ·4 revisions

Introduction

Stack-use-after-scope bug appears when a stack object is used outside the scopeit was defined.Example (see alsoAddressSanitizerExampleUseAfterScope):

void f() {  int *p;  if (b) {    int x[10];    p = x;  }  *p = 1;}

This check is enabled by default inAddressSanitizer. It can be disabled with the clang flag -fno-sanitize-address-use-after-scope.

Algorithm

AddressSanitizer detects this kind of bugs by marking memory used by local variablesas good when control reached variable definitions. Then it marks memory as bad when control reaches theend of the scope of definition. Implementation relies on @llvm.lifetime.start and @llvm.lifetime.end.

Example above we will be changed into a code similar to the following:

void f() {  int *p;  if (b) {    __asan_unpoison_stack_memory(x);    int x[10];    p = x;    __asan_poison_stack_memory(x);  }  *p = 1;   __asan_unpoison_stack_memory(frame);}

Before a function returned, its stack memory need to be unpoisoned to avoid false reports fornon-instrumented code.

Memory consumption

Memory consumption is the same as with default set ofAddressSanitizerFlags.

Performance

TODO

Compatibility

TODO

Clone this wiki locally


[8]ページ先頭

©2009-2026 Movatter.jp