Closed mfernan2 closed 4 years ago
@mfernan2 Appreciate to reveal this issue. I'll check it. Thanks.
Thanks! However, unfortunately those changes don't fix all the ASan errors:
$ git log -1
commit d1f6cdef8b9f8dba885ef612cba35251e13e5089 (HEAD -> master, origin/master, origin/HEAD)
Author: Tom G. Huang <tomghuang@gmail.com>
Date: Mon May 18 14:57:55 2020 -0700
chore: Add variable to control arg_rex debug output
$ mkdir build
$ cd build
$ CFLAGS="-g -fsanitize=address" CXXFLAGS="-g -fsanitize=address" cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmp.zDPAQ7i9CN/argtable3/build
$ make
...
$ CTEST_OUTPUT_ON_FAILURE=1 make test
Running tests...
Test project /tmp/tmp.zDPAQ7i9CN/argtable3/build
Start 1: test_shared
1/4 Test #1: test_shared ...................... Passed 4.74 sec
Start 2: test_static
2/4 Test #2: test_static ...................... Passed 4.72 sec
Start 3: test_src
3/4 Test #3: test_src ......................... Passed 4.73 sec
Start 4: test_amalgamation
4/4 Test #4: test_amalgamation ................***Failed 0.03 sec
=================================================================
==4548==ERROR: AddressSanitizer: global-buffer-overflow on address 0x556b93c07e44 at pc 0x556b93bf0d15 bp 0x7ffe55ae6350 sp 0x7ffe55ae6340
READ of size 1 at 0x556b93c07e44 thread T0
#0 0x556b93bf0d14 in arg_extension /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:2782
#1 0x556b93bf1013 in arg_file_scanfn /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:2803
#2 0x556b93bfc752 in arg_parse_untagged /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:5149
#3 0x556b93bfce4e in arg_parse /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:5251
#4 0x556b93bd71d3 in test_argfile_basic_008 /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c:198
#5 0x556b93be495f in CuTestRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:144
#6 0x556b93be59aa in CuSuiteRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:283
#7 0x556b93b96147 in RunAllTests /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:66
#8 0x556b93b9620a in main /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:79
#9 0x7f84cdcf4b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#10 0x556b93b95f29 in _start (/tmp/tmp.zDPAQ7i9CN/argtable3/build/tests/test_amalgamation+0x12f29)
0x556b93c07e44 is located 60 bytes to the left of global variable '*.LC15' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x556b93c07e80) of size 1
'*.LC15' is ascii string ''
0x556b93c07e44 is located 0 bytes to the right of global variable '*.LC14' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x556b93c07e40) of size 4
'*.LC14' is ascii string 'foo'
SUMMARY: AddressSanitizer: global-buffer-overflow /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:2782 in arg_extension
Shadow bytes around the buggy address:
0x0aadf2778f70: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 06 f9 f9
0x0aadf2778f80: f9 f9 f9 f9 00 00 00 00 00 00 02 f9 f9 f9 f9 f9
0x0aadf2778f90: 05 f9 f9 f9 f9 f9 f9 f9 00 01 f9 f9 f9 f9 f9 f9
0x0aadf2778fa0: 00 02 f9 f9 f9 f9 f9 f9 00 04 f9 f9 f9 f9 f9 f9
0x0aadf2778fb0: 00 06 f9 f9 f9 f9 f9 f9 00 03 f9 f9 f9 f9 f9 f9
=>0x0aadf2778fc0: 00 06 f9 f9 f9 f9 f9 f9[04]f9 f9 f9 f9 f9 f9 f9
0x0aadf2778fd0: 01 f9 f9 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
0x0aadf2778fe0: 06 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
0x0aadf2778ff0: 00 02 f9 f9 f9 f9 f9 f9 07 f9 f9 f9 f9 f9 f9 f9
0x0aadf2779000: 00 02 f9 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
0x0aadf2779010: 06 f9 f9 f9 f9 f9 f9 f9 07 f9 f9 f9 f9 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==4548==ABORTING
75% tests passed, 1 tests failed out of 4
Total Test time (real) = 14.24 sec
The following tests FAILED:
4 - test_amalgamation (Failed)
Errors while running CTest
Makefile:85: recipe for target 'test' failed
make: *** [test] Error 8
Hi @mfernan2 , I cannot reproduce the issue.
Since it happens to the amalgamation build only, I guess maybe the amalgamation version of your argtable3.c
is not updated. I don't know why this can happen because the build script should take care of updating the amalgamation argtable3.c
. Could you please help to provide more details? Thanks.
Hm, strange, I cannot now reproduce this either. This is surprising as I double checked my result yesterday by even deleting my build directory and starting from scratch. I guess I must have somehow missed something. Apologies for the false alarm, and thanks for fixing this so quickly.
By the way, I noticed you now have ASan instructions in the README. You may also want to recommend adding -g
to the CFLAGS, as without this ASan's backtraces lack filenames and line numbers.
Hi @mfernan2 , in the README instruction, I hope users will add -DCMAKE_BUILD_TYPE=Debug
to the CMake command line to build the Debug version, which will add -g
to CFLAGS
. However, the message is not clear enough, so I will enhance the instruction.
The test suite triggers the following Address Sanitizer error: