Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-118041

selftests don't appear to respect ASAN_OPTIONS environment variable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.4, 6.7.0 FF
    • dev
    • Testing: qtestlib
    • None
    • 3f2b54f0a (dev), c30dabc37 (tqtc/lts-6.5)

    Description

      While attempting to investigate a selftest failure in https://codereview.qt-project.org/c/qt/qtbase/+/501399/2#message-1a0f121a40d110a022842e69ef9a132c6ccace7f, I ran into an issue where a test failed because it expected no errors in the output, but ASAN produced warnings:

      mitch@mitch-kubuntu:~/dev/qt-dev2-debug/qtbase$ ./tests/auto/testlib/selftests/tst_selftests "Scenario: Test output of the loggers is as expected" -c "Given: The QTestLog::Plain logger"
      Filters: Scenario: Test output of the loggers is as expected
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      tst_selftests is a Catch v2.13.10 host application.
      Run with -? for options
      
      -------------------------------------------------------------------------------
      Scenario: Test output of the loggers is as expected
            Given: The QTestLog::Plain logger
        And given: The "benchlibcallgrind" subtest
      -------------------------------------------------------------------------------
      /home/mitch/dev/qt-dev2/qtbase/tests/auto/testlib/selftests/tst_selftests.cpp:1202
      ...............................................................................
      
      /home/mitch/dev/qt-dev2/qtbase/tests/auto/testlib/selftests/tst_selftests.cpp:683: warning:
        Valgrind broken or not available. Not running benchlibcallgrind test!
      
      -------------------------------------------------------------------------------
      Scenario: Test output of the loggers is as expected
            Given: The QTestLog::Plain logger
        And given: The "keyboard" subtest
      -------------------------------------------------------------------------------
      /home/mitch/dev/qt-dev2/qtbase/tests/auto/testlib/selftests/tst_selftests.cpp:1202
      ...............................................................................
      
      /home/mitch/dev/qt-dev2/qtbase/tests/auto/testlib/selftests/tst_selftests.cpp:794: FAILED:
        REQUIRE( errorOutput.isEmpty() )
      with expansion:
        false
      with messages:
        test := "keyboard"
        arguments := QList("-o", "-,txt")
        
      =================================================================
        ==5840==ERROR: LeakSanitizer: detected memory leaks
        
      Direct leak of 552 byte(s) in 3 object(s) allocated from:
            #0 0x7f583e6b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
            #1 0x7f58348d316f  (<unknown module>)
        
      Direct leak of 520 byte(s) in 13 object(s) allocated from:
            #0 0x7f583e6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7f58348e4045  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x728045)
        
      Direct leak of 184 byte(s) in 1 object(s) allocated from:
            #0 0x7f583e6b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
            #1 0x7f58348d316f  (<unknown module>)
            #2 0x140000000b  (<unknown module>)
        
      Direct leak of 184 byte(s) in 1 object(s) allocated from:
            #0 0x7f583e6b4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
            #1 0x7f58348d316f  (<unknown module>)
            #2 0xd00000004  (<unknown module>)
        
      Direct leak of 67 byte(s) in 2 object(s) allocated from:
            #0 0x7f583e6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7f58348e08f3  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x7248f3)
        
      Direct leak of 36 byte(s) in 1 object(s) allocated from:
            #0 0x7f583e6b4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
            #1 0x7f58348e13f4  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x7253f4)
            #2 0x1200000009  (<unknown module>)
        
      Direct leak of 24 byte(s) in 1 object(s) allocated from:
            #0 0x7f583e6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7f58348e7f3d  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x72bf3d)
        
      Indirect leak of 1342 byte(s) in 7 object(s) allocated from:
            #0 0x7f583e6b4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
            #1 0x7f58348e13f4  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x7253f4)
        
      Indirect leak of 120 byte(s) in 3 object(s) allocated from:
            #0 0x7f583e6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7f58348d3272  (<unknown module>)
        
      Indirect leak of 24 byte(s) in 1 object(s) allocated from:
            #0 0x7f583e6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7f58348e7f3d  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x72bf3d)
        
      Indirect leak of 24 byte(s) in 1 object(s) allocated from:
            #0 0x7f583e6b4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7f58348d872a  (<unknown module>)
        
      SUMMARY: AddressSanitizer: 3077 byte(s) leaked in 34 allocation(s).
      
      -------------------------------------------------------------------------------
      Scenario: Test output of the loggers is as expected
            Given: The QTestLog::Plain logger
        And given: The "mouse" subtest
      -------------------------------------------------------------------------------
      /home/mitch/dev/qt-dev2/qtbase/tests/auto/testlib/selftests/tst_selftests.cpp:1202
      ...............................................................................
      
      /home/mitch/dev/qt-dev2/qtbase/tests/auto/testlib/selftests/tst_selftests.cpp:794: FAILED:
        REQUIRE( errorOutput.isEmpty() )
      with expansion:
        false
      with messages:
        test := "mouse"
        arguments := QList("-o", "-,txt")
        
      =================================================================
        ==5858==ERROR: LeakSanitizer: detected memory leaks
        
      Direct leak of 552 byte(s) in 3 object(s) allocated from:
            #0 0x7fb29fab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
            #1 0x7fb295c9f16f  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x73b16f)
        
      Direct leak of 520 byte(s) in 13 object(s) allocated from:
            #0 0x7fb29fab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7fb295cb0045  (<unknown module>)
        
      Direct leak of 184 byte(s) in 1 object(s) allocated from:
            #0 0x7fb29fab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
            #1 0x7fb295c9f16f  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x73b16f)
            #2 0x140000000b  (<unknown module>)
        
      Direct leak of 184 byte(s) in 1 object(s) allocated from:
            #0 0x7fb29fab4a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
            #1 0x7fb295c9f16f  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x73b16f)
            #2 0xd00000004  (<unknown module>)
        
      Direct leak of 67 byte(s) in 2 object(s) allocated from:
            #0 0x7fb29fab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7fb295cac8f3  (<unknown module>)
        
      Direct leak of 36 byte(s) in 1 object(s) allocated from:
            #0 0x7fb29fab4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
            #1 0x7fb295cad3f4  (<unknown module>)
            #2 0x1200000009  (<unknown module>)
        
      Direct leak of 24 byte(s) in 1 object(s) allocated from:
            #0 0x7fb29fab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7fb295cb3f3d  (<unknown module>)
        
      Indirect leak of 1342 byte(s) in 7 object(s) allocated from:
            #0 0x7fb29fab4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
            #1 0x7fb295cad3f4  (<unknown module>)
        
      Indirect leak of 120 byte(s) in 3 object(s) allocated from:
            #0 0x7fb29fab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7fb295c9f272  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x73b272)
        
      Indirect leak of 24 byte(s) in 1 object(s) allocated from:
            #0 0x7fb29fab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7fb295cb3f3d  (<unknown module>)
        
      Indirect leak of 24 byte(s) in 1 object(s) allocated from:
            #0 0x7fb29fab4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
            #1 0x7fb295ca472a  (/usr/lib/x86_64-linux-gnu/libasan.so.6.0.0+0x74072a)
        
      SUMMARY: AddressSanitizer: 3077 byte(s) leaked in 34 allocation(s).
      
      ===============================================================================
      test cases:   1 |   0 passed | 1 failed
      assertions: 382 | 380 passed | 2 failed
      
      Test outputs left in /tmp/tst_selftests.RCxaKQ
      

      Running a specific subtest works:

      mitch@mitch-kubuntu:~/dev/qt-dev2-debug/qtbase$ ./tests/auto/testlib/selftests/tst_selftests "Scenario: Test output of the loggers is as expected" -c "Given: The QTestLog::Plain logger" -c 'And given: The "cmptest" subtest'
      Filters: Scenario: Test output of the loggers is as expected
      ===============================================================================
      All tests passed (6 assertions in 1 test case)
      

      I've exported an environment variable in ~/.profile that silences ASAN's memory leak warnings, which I've verified is picked up by the shell I'm running the tests from:

      mitch@mitch-kubuntu:~/dev/qt-dev2-debug/qtbase$ env | grep ASAN
      ASAN_OPTIONS=detect_leaks=0,new_delete_type_mismatch=0
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes