This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1468909 - gcc + asan + exceptions = stack-use-after-scope false positive
gcc + asan + exceptions = stack-use-after-scope false positive
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
26
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-09 14:47 EDT by Avi Kivity
Modified: 2017-09-19 11:36 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-09-19 11:36:32 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 81021 None None None 2017-07-09 14:47 EDT

  None (edit)
Description Avi Kivity 2017-07-09 14:47:35 EDT
Description of problem:

gcc 7 Address Sanitizer warns about false positives


Version-Release number of selected component (if applicable):
gcc-7.1.1-3.fc26.x86_64

How reproducible:
Always


Steps to Reproduce:
1. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81021

Actual results:
False error detected.


Expected results:
No false error

Additional info:

This was fixed on gcc trunk, so this is just a request to backport into Fedora.
Comment 1 Georg Sauthoff 2017-07-22 11:00:41 EDT
I can reproduce this issue with a relatively simple unittest case - one that uses the Boost unittest framework library (UTF).

==8426==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffcc390b8c0 at pc 0x00000057ad7e bp 0x7ffcc390b760 sp 0x7ffcc390b750
WRITE of size 32 at 0x7ffcc390b8c0 thread T0

    #1 0x5f1eb1 in maildir::flags_except::test_method() ../unittest/maildir.cc:149
    #2 0x5f08b2 in flags_except_invoker ../unittest/maildir.cc:134

The test checks if an exception is thrown:

    bool caught = false;
    try {
      m.move_to_cur("XYZ");
    } catch (std::runtime_error) {
      caught = true;
    }
    BOOST_CHECK_EQUAL(caught, true);

The last line is line 149 from the adress sanitizer error report.

The code isn't multi-threaded.

(Yes, I know that the UTF includes some specialized assertion macros for checking if an exception was thrown.)
Comment 2 Benjamin Kircher 2017-07-27 05:00:56 EDT
Are you/is anybody able to disable the check with `ASAN_OPTIONS=detect_stack_use_after_scope=0`?

[1] https://github.com/google/sanitizers/wiki/AddressSanitizerExampleUseAfterScope
Comment 3 Georg Sauthoff 2017-07-28 17:05:03 EDT
No, I am not able to disable the check with that option.

That means when I call my unittest binary like this:

ASAN_OPTIONS=detect_stack_use_after_scope=0 ./ut --run_test=maildir/flags_except

then I still get:

==4323==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fff5b2fb1c0 at pc 0x00000057ad7e bp 0x7fff5b2fb060 sp 0x7fff5b2fb050
WRITE of size 32 at 0x7fff5b2fb1c0 thread T0


FWIW, clang+asan works as expected on those unittests. (modulo some non-whitelisted pseudo leaks in libstdc++)
Comment 4 Avi Kivity 2017-08-28 09:27:30 EDT
This was fixed in gcc 7.2. An update would be appreciated.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81021
Comment 5 Benjamin Kircher 2017-09-19 11:32:49 EDT
gcc 7.2 has landed in F26 via updates. Tested and behaves nicely now. Think this here can be closed now.

Note You need to log in before you can comment on or make changes to this bug.