tim-janik / anklang

MIDI and Audio Synthesizer and Composer
https://anklang.testbit.eu/
Mozilla Public License 2.0
55 stars 4 forks source link

With MODE=asan, Anklang fails to build from source #68

Open swesterfeld opened 4 months ago

swesterfeld commented 4 months ago

As far as I understand the issue, the problem is the class tree generation

out/lib/AnklangSynthEngine --norc -P null -M null --class-tree

which triggers this asan error

=================================================================
==3659961==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffede49a7a0 at pc 0x558b395510b4 bp 0x7ffede49a3f0 sp 0x7ffede49a3e0
READ of size 1 at 0x7ffede49a7a0 thread T0
=================================================================
==3659959==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffd09d68ef0 at pc 0x563b2525f0b4 bp 0x7ffd09d68b40 sp 0x7ffd09d68b30
READ of size 1 at 0x7ffd09d68ef0 thread T0
    #0 0x558b395510b3 in std::char_traits<char>::assign(char&, char const&) /usr/include/c++/11/bits/char_traits.h:357
    #0 0x563b2525f0b3 in std::char_traits<char>::assign(char&, char const&) /usr/include/c++/11/bits/char_traits.h:357
    #1 0x558b39587878 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned long) /usr/include/c++/11/bits/basic_string.h:357
    #1 0x563b25295878 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned long) /usr/include/c++/11/bits/basic_string.h:357
    #2 0x563b252958a2 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char const*, char const*) /usr/include/c++/11/bits/basic_string.h:406
    #2 0x558b395878a2 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char const*, char const*) /usr/include/c++/11/bits/basic_string.h:406
    #3 0x563b25295c90 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) /usr/include/c++/11/bits/basic_string.tcc:225
    #3 0x558b39587c90 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) /usr/include/c++/11/bits/basic_string.tcc:225
    #4 0x563b25298543 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*>(char const*, char const*, std::__false_type) /usr/include/c++/11/bits/basic_string.h:255
    #4 0x558b3958a543 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*>(char const*, char const*, std::__false_type) /usr/include/c++/11/bits/basic_string.h:255
    #5 0x563b25298579 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*) /usr/include/c++/11/bits/basic_string.h:274
    #5 0x558b3958a579 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*) /usr/include/c++/11/bits/basic_string.h:274
    #6 0x563b252985e0 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) /usr/include/c++/11/bits/basic_string.h:521
    #6 0x558b3958a5e0 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) /usr/include/c++/11/bits/basic_string.h:521
    #7 0x563b25531ea1 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::__sv_wrapper, std::allocator<char> const&) /usr/include/c++/11/bits/basic_string.h:154
    #7 0x558b39823ea1 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::__sv_wrapper, std::allocator<char> const&) /usr/include/c++/11/bits/basic_string.h:154
    #8 0x563b25531ffe in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::basic_string_view<char, std::char_traits<char> >, void>(std::basic_string_view<char, std::char_traits<char> > const&, std::allocator<char> const&) /usr/include/c++/11/bits/basic_string.h:665
    #8 0x558b39823ffe in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::basic_string_view<char, std::char_traits<char> >, void>(std::basic_string_view<char, std::char_traits<char> > const&, std::allocator<char> const&) /usr/include/c++/11/bits/basic_string.h:665
    #9 0x563b25b43fdb in Ase::debug_key_enabled(char const*) ase/utils.cc:40
    #9 0x558b39e35fdb in Ase::debug_key_enabled(char const*) ase/utils.cc:40
    #10 0x558b39ad6831 in void Ase::debug<char [12], int, unsigned long, void*>(char const*, char const*, char const (&) [12], int const&, unsigned long const&, void* const&) ase/utils.hh:192
    #10 0x563b257e4831 in void Ase::debug<char [12], int, unsigned long, void*>(char const*, char const*, char const (&) [12], int const&, unsigned long const&, void* const&) ase/utils.hh:192
    #11 0x558b39ad6831 in Ase::Loft::BumpAllocator::memmap(unsigned long, bool) ase/loft.cc:175
    #11 0x563b257e4831 in Ase::Loft::BumpAllocator::memmap(unsigned long, bool) ase/loft.cc:175
    #12 0x558b39ad81f0 in Ase::Loft::BumpAllocator::grow_spans(unsigned long, bool) ase/loft.cc:119
    #12 0x563b257e61f0 in Ase::Loft::BumpAllocator::grow_spans(unsigned long, bool) ase/loft.cc:119
    #13 0x558b39addd49 in Ase::loft_grow_preallocate(unsigned long) ase/loft.cc:577
    #13 0x563b257ebd49 in Ase::loft_grow_preallocate(unsigned long) ase/loft.cc:577
    #14 0x558b39b1a25b in preallocate_loft ase/main.cc:379
    #15 0x558b39b28bd7 in main ase/main.cc:432
    #14 0x563b2582825b in preallocate_loft ase/main.cc:379
    #15 0x563b25836bd7 in main ase/main.cc:432
    #16 0x7f1561fe0d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #17 0x7f1561fe0e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #16 0x7fc5045ded8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #18 0x558b39548634 in _start (/home/stefan/src/anklang/out/lib/AnklangSynthEngine+0x199634)
    #17 0x7fc5045dee3f in __libc_start_main_impl ../csu/libc-start.c:392

    #18 0x563b25256634 in _start (/home/stefan/src/anklang/out/lib/AnklangSynthEngine+0x199634)

Address 0x7ffede49a7a0 is located in stack of thread T0 at offset 144 in frame
Address 0x7ffd09d68ef0 is located in stack of thread T0 at offset 144 in frame
    #0 0x558b39e35de4 in Ase::debug_key_enabled(char const*) ase/utils.cc:38

    #0 0x563b25b43de4 in Ase::debug_key_enabled(char const*) ase/utils.cc:38
  This frame has 7 object(s):

    [48, 49) '<unknown>'
  This frame has 7 object(s):
    [64, 65) '<unknown>'
    [48, 49) '<unknown>'
    [80, 81) '<unknown>'
    [64, 65) '<unknown>'
    [96, 112) 'sv' (line 39)
    [80, 81) '<unknown>'
    [128, 160) '<unknown>' <== Memory access at offset 144 is inside this variable
    [96, 112) 'sv' (line 39)
    [192, 224) '<unknown>'
    [128, 160) '<unknown>' <== Memory access at offset 144 is inside this variable
    [256, 288) '<unknown>'
    [192, 224) '<unknown>'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
    [256, 288) '<unknown>'
      (longjmp and C++ exceptions *are* supported)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-scope /usr/include/c++/11/bits/char_traits.h:357 in std::char_traits<char>::assign(char&, char const&)
SUMMARY: AddressSanitizer: stack-use-after-scope /usr/include/c++/11/bits/char_traits.h:357 in std::char_traits<char>::assign(char&, char const&)
Shadow bytes around the buggy address:
  0x10005bc8b4a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005bc8b4b0: 00 00 00 00 00 00 f1 f1 f1 f1 00 00 f3 f3 00 00
  0x10005bc8b4c0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
  0x10005bc8b4d0: 00 00 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005bc8b4e0: 00 00 f1 f1 f1 f1 f1 f1 f8 f2 f8 f2 01 f2 00 00
=>0x10005bc8b4f0: f2 f2 f8 f8[f8]f8 f2 f2 f2 f2 f8 f8 f8 f8 f2 f2
  0x10005bc8b500: f2 f2 00 00 00 00 f3 f3 f3 f3 00 00 00 00 00 00
  0x10005bc8b510: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 04 f2
  0x10005bc8b520: 04 f2 04 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2
  0x10005bc8b530: 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2
  0x10005bc8b540: 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2
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
  Shadow gap:              cc
Shadow bytes around the buggy address:
  0x1000213a5180: f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000213a5190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000213a51a0: f1 f1 f1 f1 00 00 f3 f3 00 00 00 00 00 00 00 00
  0x1000213a51b0: 00 00 00 00 00 00 f1 f1 f1 f1 00 00 f3 f3 00 00
  0x1000213a51c0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
=>0x1000213a51d0: f1 f1 f8 f2 f8 f2 01 f2 00 00 f2 f2 f8 f8[f8]f8
  0x1000213a51e0: f2 f2 f2 f2 f8 f8 f8 f8 f2 f2 f2 f2 00 00 00 00
  0x1000213a51f0: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000213a5200: 00 00 f1 f1 f1 f1 04 f2 04 f2 04 f2 04 f2 00 f2
  0x1000213a5210: f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2
  0x1000213a5220: f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2 f2 f2 00 f2
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
  Shadow gap:              cc
==3659961==ABORTING
==3659959==ABORTING
make: *** [doc/Makefile.mk:104: out/doc/class-tree.md] Fehler 1
make: *** Auf noch nicht beendete Prozesse wird gewartet …
make: *** [ui/Makefile.mk:137: out/ui/aseapi.js] Fehler 1

which in turn makes the build fail. I'm using KUbuntu 22.04 with g++-11

g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABUsingILITY or FITNESS FOR A PARTICULAR PURPOSE.

as compiler.