argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
372 stars 65 forks source link

ASan errors #46

Closed mfernan2 closed 4 years ago

mfernan2 commented 4 years ago

The test suite triggers the following Address Sanitizer error:

$ mkdir build
$ cd build
$ CFLAGS="-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 ......................***Failed    0.04 sec
=================================================================
==19690==ERROR: AddressSanitizer: global-buffer-overflow on address 0x564055790304 at pc 0x7f2b2a83f901 bp 0x7ffc68f6fef0 sp 0x7ffc68f6fee0
READ of size 1 at 0x564055790304 thread T0
    #0 0x7f2b2a83f900 in arg_extension /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:95
    #1 0x7f2b2a83fbff in arg_file_scanfn /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:116
    #2 0x7f2b2a84d672 in arg_parse_untagged /tmp/tmp.zDPAQ7i9CN/argtable3/src/argtable3.c:356
    #3 0x7f2b2a84deb2 in arg_parse /tmp/tmp.zDPAQ7i9CN/argtable3/src/argtable3.c:458
    #4 0x56405577a259 in test_argfile_basic_008 /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c:198
    #5 0x5640557879d6 in CuTestRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:144
    #6 0x564055788a15 in CuSuiteRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:282
    #7 0x5640557391eb in RunAllTests /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:66
    #8 0x564055739290 in main /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:75
    #9 0x7f2b2a462b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #10 0x564055738fe9 in _start (/tmp/tmp.zDPAQ7i9CN/argtable3/build/tests/test_shared+0xdfe9)

0x564055790304 is located 60 bytes to the left of global variable '*.LC15' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x564055790340) of size 1
  '*.LC15' is ascii string ''
0x564055790304 is located 0 bytes to the right of global variable '*.LC14' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x564055790300) of size 4
  '*.LC14' is ascii string 'foo'
SUMMARY: AddressSanitizer: global-buffer-overflow /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:95 in arg_extension
Shadow bytes around the buggy address:
  0x0ac88aaea010: f9 f9 f9 f9 00 06 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ac88aaea020: 00 00 02 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
  0x0ac88aaea030: 00 01 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x0ac88aaea040: 00 04 f9 f9 f9 f9 f9 f9 00 06 f9 f9 f9 f9 f9 f9
  0x0ac88aaea050: 00 03 f9 f9 f9 f9 f9 f9 00 06 f9 f9 f9 f9 f9 f9
=>0x0ac88aaea060:[04]f9 f9 f9 f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9
  0x0ac88aaea070: 05 f9 f9 f9 f9 f9 f9 f9 06 f9 f9 f9 f9 f9 f9 f9
  0x0ac88aaea080: 00 f9 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x0ac88aaea090: 07 f9 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x0ac88aaea0a0: 05 f9 f9 f9 f9 f9 f9 f9 06 f9 f9 f9 f9 f9 f9 f9
  0x0ac88aaea0b0: 07 f9 f9 f9 f9 f9 f9 f9 00 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
==19690==ABORTING

    Start 2: test_static
2/4 Test #2: test_static ......................***Failed    0.03 sec
=================================================================
==19691==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55cc049d6e44 at pc 0x55cc049bc1cb bp 0x7fffa7eb6bb0 sp 0x7fffa7eb6ba0
READ of size 1 at 0x55cc049d6e44 thread T0
    #0 0x55cc049bc1ca in arg_extension /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:95
    #1 0x55cc049bc4c9 in arg_file_scanfn /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:116
    #2 0x55cc049c9c50 in arg_parse_untagged /tmp/tmp.zDPAQ7i9CN/argtable3/src/argtable3.c:356
    #3 0x55cc049ca478 in arg_parse /tmp/tmp.zDPAQ7i9CN/argtable3/src/argtable3.c:458
    #4 0x55cc049a5de9 in test_argfile_basic_008 /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c:198
    #5 0x55cc049b3566 in CuTestRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:144
    #6 0x55cc049b45a5 in CuSuiteRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:282
    #7 0x55cc04964d7b in RunAllTests /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:66
    #8 0x55cc04964e20 in main /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:75
    #9 0x7f652cc09b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #10 0x55cc04964b79 in _start (/tmp/tmp.zDPAQ7i9CN/argtable3/build/tests/test_static+0x13b79)

0x55cc049d6e44 is located 60 bytes to the left of global variable '*.LC15' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x55cc049d6e80) of size 1
  '*.LC15' is ascii string ''
0x55cc049d6e44 is located 0 bytes to the right of global variable '*.LC14' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x55cc049d6e40) of size 4
  '*.LC14' is ascii string 'foo'
SUMMARY: AddressSanitizer: global-buffer-overflow /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:95 in arg_extension
Shadow bytes around the buggy address:
  0x0aba00932d70: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 06 f9 f9
  0x0aba00932d80: f9 f9 f9 f9 00 00 00 00 00 00 02 f9 f9 f9 f9 f9
  0x0aba00932d90: 05 f9 f9 f9 f9 f9 f9 f9 00 01 f9 f9 f9 f9 f9 f9
  0x0aba00932da0: 00 02 f9 f9 f9 f9 f9 f9 00 04 f9 f9 f9 f9 f9 f9
  0x0aba00932db0: 00 06 f9 f9 f9 f9 f9 f9 00 03 f9 f9 f9 f9 f9 f9
=>0x0aba00932dc0: 00 06 f9 f9 f9 f9 f9 f9[04]f9 f9 f9 f9 f9 f9 f9
  0x0aba00932dd0: 01 f9 f9 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
  0x0aba00932de0: 06 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x0aba00932df0: 00 02 f9 f9 f9 f9 f9 f9 07 f9 f9 f9 f9 f9 f9 f9
  0x0aba00932e00: 00 02 f9 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
  0x0aba00932e10: 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
==19691==ABORTING

    Start 3: test_src
3/4 Test #3: test_src .........................***Failed    0.03 sec
=================================================================
==19692==ERROR: AddressSanitizer: global-buffer-overflow on address 0x564034bb9144 at pc 0x564034b9e227 bp 0x7fff9f261e00 sp 0x7fff9f261df0
READ of size 1 at 0x564034bb9144 thread T0
    #0 0x564034b9e226 in arg_extension /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:95
    #1 0x564034b9e525 in arg_file_scanfn /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:116
    #2 0x564034babf53 in arg_parse_untagged /tmp/tmp.zDPAQ7i9CN/argtable3/src/argtable3.c:356
    #3 0x564034bac77b in arg_parse /tmp/tmp.zDPAQ7i9CN/argtable3/src/argtable3.c:458
    #4 0x564034b87e45 in test_argfile_basic_008 /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c:198
    #5 0x564034b955c2 in CuTestRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:144
    #6 0x564034b96601 in CuSuiteRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:282
    #7 0x564034b46dd7 in RunAllTests /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:66
    #8 0x564034b46e7c in main /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:75
    #9 0x7f8e18385b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #10 0x564034b46bb9 in _start (/tmp/tmp.zDPAQ7i9CN/argtable3/build/tests/test_src+0x13bb9)

0x564034bb9144 is located 60 bytes to the left of global variable '*.LC15' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x564034bb9180) of size 1
  '*.LC15' is ascii string ''
0x564034bb9144 is located 0 bytes to the right of global variable '*.LC14' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x564034bb9140) of size 4
  '*.LC14' is ascii string 'foo'
SUMMARY: AddressSanitizer: global-buffer-overflow /tmp/tmp.zDPAQ7i9CN/argtable3/src/arg_file.c:95 in arg_extension
Shadow bytes around the buggy address:
  0x0ac88696f1d0: f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9 00 06 f9 f9
  0x0ac88696f1e0: f9 f9 f9 f9 00 00 00 00 00 00 02 f9 f9 f9 f9 f9
  0x0ac88696f1f0: 05 f9 f9 f9 f9 f9 f9 f9 00 01 f9 f9 f9 f9 f9 f9
  0x0ac88696f200: 00 02 f9 f9 f9 f9 f9 f9 00 04 f9 f9 f9 f9 f9 f9
  0x0ac88696f210: 00 06 f9 f9 f9 f9 f9 f9 00 03 f9 f9 f9 f9 f9 f9
=>0x0ac88696f220: 00 06 f9 f9 f9 f9 f9 f9[04]f9 f9 f9 f9 f9 f9 f9
  0x0ac88696f230: 01 f9 f9 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
  0x0ac88696f240: 06 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x0ac88696f250: 00 02 f9 f9 f9 f9 f9 f9 07 f9 f9 f9 f9 f9 f9 f9
  0x0ac88696f260: 00 02 f9 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
  0x0ac88696f270: 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
==19692==ABORTING

    Start 4: test_amalgamation
4/4 Test #4: test_amalgamation ................***Failed    0.03 sec
=================================================================
==19693==ERROR: AddressSanitizer: global-buffer-overflow on address 0x55ea1bb7ee04 at pc 0x55ea1bb67cdc bp 0x7ffead4c2250 sp 0x7ffead4c2240
READ of size 1 at 0x55ea1bb7ee04 thread T0
    #0 0x55ea1bb67cdb in arg_extension /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:2782
    #1 0x55ea1bb67fda in arg_file_scanfn /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:2803
    #2 0x55ea1bb73719 in arg_parse_untagged /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:5149
    #3 0x55ea1bb73e15 in arg_parse /tmp/tmp.zDPAQ7i9CN/argtable3/dist/argtable3.c:5251
    #4 0x55ea1bb4e1b5 in test_argfile_basic_008 /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c:198
    #5 0x55ea1bb5b932 in CuTestRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:144
    #6 0x55ea1bb5c971 in CuSuiteRun /tmp/tmp.zDPAQ7i9CN/argtable3/tests/CuTest.c:282
    #7 0x55ea1bb0d147 in RunAllTests /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:66
    #8 0x55ea1bb0d1ec in main /tmp/tmp.zDPAQ7i9CN/argtable3/tests/testall.c:75
    #9 0x7f457ce7ab96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #10 0x55ea1bb0cf29 in _start (/tmp/tmp.zDPAQ7i9CN/argtable3/build/tests/test_amalgamation+0x12f29)

0x55ea1bb7ee04 is located 60 bytes to the left of global variable '*.LC15' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x55ea1bb7ee40) of size 1
  '*.LC15' is ascii string ''
0x55ea1bb7ee04 is located 0 bytes to the right of global variable '*.LC14' defined in '/tmp/tmp.zDPAQ7i9CN/argtable3/tests/testargfile.c' (0x55ea1bb7ee00) 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:
  0x0abdc3767d70: f9 f9 f9 f9 00 06 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0abdc3767d80: 00 00 02 f9 f9 f9 f9 f9 05 f9 f9 f9 f9 f9 f9 f9
  0x0abdc3767d90: 00 01 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x0abdc3767da0: 00 04 f9 f9 f9 f9 f9 f9 00 06 f9 f9 f9 f9 f9 f9
  0x0abdc3767db0: 00 03 f9 f9 f9 f9 f9 f9 00 06 f9 f9 f9 f9 f9 f9
=>0x0abdc3767dc0:[04]f9 f9 f9 f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9
  0x0abdc3767dd0: 05 f9 f9 f9 f9 f9 f9 f9 06 f9 f9 f9 f9 f9 f9 f9
  0x0abdc3767de0: 00 f9 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x0abdc3767df0: 07 f9 f9 f9 f9 f9 f9 f9 00 02 f9 f9 f9 f9 f9 f9
  0x0abdc3767e00: 05 f9 f9 f9 f9 f9 f9 f9 06 f9 f9 f9 f9 f9 f9 f9
  0x0abdc3767e10: 07 f9 f9 f9 f9 f9 f9 f9 00 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
==19693==ABORTING

0% tests passed, 4 tests failed out of 4

Total Test time (real) =   0.14 sec

The following tests FAILED:
      1 - test_shared (Failed)
      2 - test_static (Failed)
      3 - test_src (Failed)
      4 - test_amalgamation (Failed)
Errors while running CTest
Makefile:94: recipe for target 'test' failed
make: *** [test] Error 8
$ git log -1
commit e58754ed716542a54f75a9c9ba5c85a057b8ea00 (HEAD -> master, origin/master, origin/HEAD)
Author: Tom G. Huang <tomghuang@gmail.com>
Date:   Sun Nov 24 12:03:02 2019 -0800

    doc: How to get details when unit tests go wrong
$ cc --version
cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ uname -rms
Linux 5.0.0-23-generic x86_64
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic
tomghuang commented 4 years ago

@mfernan2 Appreciate to reveal this issue. I'll check it. Thanks.

mfernan2 commented 4 years ago

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
tomghuang commented 4 years ago

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.

mfernan2 commented 4 years ago

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.

mfernan2 commented 4 years ago

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.

tomghuang commented 4 years ago

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.