HomePhabricator

[backport#17205] ci: Enable address sanitizer (ASan) stack-use-after-return…

Description

[backport#17205] ci: Enable address sanitizer (ASan) stack-use-after-return checking

Summary:
8d22ab0e503ccaa464cbecd94d1059dbc5a61f4a ci: Enable address sanitizer (ASan) stack-use-after-return checking (practicalswift)

Pull request description:

Enable address sanitizer (ASan) stack-use-after-return checking (`detect_stack_use_after_return=1`).

Example:

```
#include <iostream>
#include <string>

const std::string& get_string(int i) {
    return std::to_string(i);
}

int main() {
    std::cout << get_string(41) << "\n";
}
```

Without address sanitizer (ASan) stack-use-after-return checking:

```
$ ./stack-use-after-return

$
```

With address sanitizer (ASan) stack-use-after-return checking:

```
$ ASAN_OPTIONS="detect_stack_use_after_return=1" ./stack-use-after-return
=================================================================
==10400==ERROR: AddressSanitizer: stack-use-after-return on address 0x7f7fa0400030 at pc 0x00000049d2cc bp 0x7ffcbd617070 sp 0x7ffcbd616820
READ of size 2 at 0x7f7abbecd030 thread T0
    #0 0x439781 in fwrite
    #1 0x7f7ac0504cb3 in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x113cb3)
    #2 0x4f9b5f in main stack-use-after-return.cpp:9:15
    #3 0x7f7abf440b96 in __libc_start_main
    #4 0x41bbc9 in _start
…
$
```

Backport of Core PR17205

Test Plan:

cmake -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_SANITIZERS=address
ninja all check check-functional

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D8756

Details

Provenance
MarcoFalke <falke.marco@gmail.com>Authored on Oct 22 2019, 17:14
majcostaCommitted on Dec 28 2020, 21:34
majcostaPushed on Dec 28 2020, 21:34
Reviewer
Restricted Project
Differential Revision
D8756: [backport#17205] ci: Enable address sanitizer (ASan) stack-use-after-return checking
Parents
rABCddbf732e42fb: Support npm pkgs in extension-specific files
Branches
Unknown
Tags
Unknown