Skip to content

heap-buffer-overflow in disable-no_post_except_lib #36

@jeking3

Description

@jeking3

Due to this issue, a test was disabled so that CI can pass all other tests.

Ubuntu 24 with clang 14

only happens with the release build. Changing visibility to global does not fix it. Changing link to shared does.

...skipped 3 targets...
   <pbin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-11-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden>disable-no_post_except_lib.test
   <pbin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-17-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden>disable-no_post_except_lib.test
   <pbin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden>disable-no_post_except_lib.test

...failed updating 3 targets...
   testing.capture-output bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-11-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib.run
   testing.capture-output bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-17-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib.run
   testing.capture-output bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib.run
./b2 libs/contract/test toolset=clang cxxstd=11,17,20 link=shared,static variant=debug,release address-sanitizer=norecover undefined-sanitizer=on

testing.capture-output bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib.run
> ====== BEGIN OUTPUT ======
f::pre
f::old
f::body
f::post
x::pre
> =================================================================
==467498==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x606000000058 at pc 0x561f4773bf4d bp 0x7ffea0408d10 sp 0x7ffea0408d08
READ of size 8 at 0x606000000058 thread T0
    #0 0x561f4773bf4c in boost::contract::detail::cond_base::copy_old() (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0xfff4c) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #1 0x561f47738bb5 in boost::contract::detail::function::init() (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0xfcbb5) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #2 0x561f47736771 in boost::contract::check::check(boost::contract::specify_except const&) (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0xfa771) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #3 0x561f4773f660 in x() (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0x103660) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #4 0x561f4773495e in main (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0xf895e) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #5 0x7f43a4be4249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #6 0x7f43a4be4304 in __libc_start_main csu/../csu/libc-start.c:360:3
    #7 0x561f47673700 in _start (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0x37700) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)

0x606000000058 is located 0 bytes to the right of 56-byte region [0x606000000020,0x606000000058)
allocated by thread T0 here:
    #0 0x561f4773131d in operator new(unsigned long) (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0xf531d) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #1 0x561f4773f3d0 in x() (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0x1033d0) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #2 0x561f4773495e in main (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0xf895e) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d)
    #3 0x7f43a4be4249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/jking/boost/bin.v2/libs/contract/test/disable-no_post_except_lib.test/clang-linux-14/release/x86_64/address-sanitizer-norecover/cxxstd-20-iso/link-static/threading-multi/undefined-sanitizer-on/visibility-hidden/disable-no_post_except_lib+0xfff4c) (BuildId: 8f2a9e923ff5885af07d2c319f72d582dbe4014d) in boost::contract::detail::cond_base::copy_old()
Shadow bytes around the buggy address:
  0x0c0c7fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c0c7fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c0c7fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c0c7fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c0c7fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c0c7fff8000: fa fa fa fa 00 00 00 00 00 00 00[fa]fa fa fa fa
  0x0c0c7fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
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
==467498==ABORTING
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
f::pre

Breakpoint 1, boost::contract::detail::cond_base::copy_old (this=0x60e000000040)
    at ../../../boost/contract/detail/condition/cond_base.hpp:106
106                 if(failed()) return;
(gdb) c
Continuing.
f::old
f::body
f::post
x::pre

Breakpoint 1, boost::contract::detail::cond_base::copy_old (this=0x60e000000120)
    at ../../../boost/contract/detail/condition/cond_base.hpp:106
106                 if(failed()) return;
(gdb) bt
#0  boost::contract::detail::cond_base::copy_old (this=0x60e000000120)
    at ../../../boost/contract/detail/condition/cond_base.hpp:106
#1  0x00005555556841a8 in boost::contract::detail::function::init (this=0x60e000000120)
    at ../../../boost/contract/detail/operation/function.hpp:52
#2  0x000055555568a389 in boost::contract::detail::cond_base::initialize (
    this=0x60e000000120) at ../../../boost/contract/detail/condition/cond_base.hpp:55
#3  0x000055555567e37d in boost::contract::check::check (this=0x7fffffffcfa0, 
    contract=...) at ../../../boost/contract/check.hpp:283
#4  0x000055555569450a in x () at disable/lib_x.cpp:22
#5  0x00005555556762fb in main () at disable/lib_xy.hpp:49
(gdb) p old_
$1 = {<boost::function_n<void>> = {<boost::function_base> = {vtable = 0x0, functor = {
        members = {obj_ptr = 0xbebebebebebebebe, type = {type = 0xbebebebebebebebe, 
            const_qualified = 190, volatile_qualified = 190}, 
          func_ptr = 0xbebebebebebebebe, bound_memfunc_ptr = {
            memfunc_ptr = (void (boost::detail::function::X::*)(boost::detail::function::X * const, int)) 0xbebebebebebebebe, this adjustment -4702111234474983746, 
            obj_ptr = 0xbebebebebebebebe}, obj_ref = {obj_ptr = 0xbebebebebebebebe, 
            is_const_qualified = 190, is_volatile_qualified = 190}}, 
        data = '\276' <repeats 24 times>}}, <boost::detail::function::variadic_function_base<>> = {<No data fields>}, static arity = 0}, <No data fields>}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions