Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
08500 Misc. Critical (emulator) Always Nov 4, 2022, 14:14 Dec 4, 2022, 19:51
Tester Firewave View Status Public Platform MAME (Official Binary)
Assigned To hap Resolution Fixed OS Linux (64-bit)
Status [?] Resolved Driver
Version 0.249 Fixed in Version 0.251 Build 64-bit
Fixed in Git Commit 35d28d3 Github Pull Request #
Summary 08500: optiger: AddressSanitizer: heap-buffer-overflow
Description
==30512==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f91c93f1800 at pc 0x7f92149739ab bp 0x7fffe9151e40 sp 0x7fffe9151e38
READ of size 2 at 0x7f91c93f1800 thread T0
    #0 0x7f92149739aa in taitopjc_state::dsp_rom_r() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/taito/taitopjc.cpp:713:18
    #1 0x7f9224057175 in operator() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/lib/util/delegate.h:765:11
    #2 0x7f9224057175 in std::enable_if<(((std::is_same<emu::device_delegate<unsigned short ()>, emu::device_delegate<unsigned char ()> >::value) || (std::is_same<emu::device_delegate<unsigned short ()>, emu::device_delegate<unsigned short ()> >::value)) || (std::is_same<emu::device_delegate<unsigned short ()>, emu::device_delegate<unsigned int ()> >::value)) || (std::is_same<emu::device_delegate<unsigned short ()>, emu::device_delegate<unsigned long ()> >::value), unsigned short>::type handler_entry_read_delegate<1, -1, emu::device_delegate<unsigned short ()> >::read_impl<emu::device_delegate<unsigned short ()> >(unsigned int, unsigned short) const /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem_hedp.cpp:65:9
    #3 0x7f92240570d0 in handler_entry_read_delegate<1, -1, emu::device_delegate<unsigned short ()> >::read(unsigned int, unsigned short) const /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem_hedp.cpp:70:9
    #4 0x7f92188c5d0e in emu::detail::handler_entry_size<1>::uX dispatch_read<0, 1, -1>(unsigned int, unsigned int, emu::detail::handler_entry_size<1>::uX, handler_entry_read<1, -1> const* const*) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1570:47
    #5 0x7f9224bf5059 in handler_entry_read_dispatch<14, 1, -1>::read(unsigned int, unsigned short) const /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem_hedr.ipp:132:9
    #6 0x7f9218d62e21 in emu::detail::handler_entry_size<1>::uX dispatch_read<1, 1, -1>(unsigned int, unsigned int, emu::detail::handler_entry_size<1>::uX, handler_entry_read<1, -1> const* const*) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1570:47
    #7 0x7f9218d5b3a1 in read_native /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1737:10
    #8 0x7f9218d5b3a1 in emu::detail::memory_access_specific<1, 1, -1, (util::endianness)0>::read_word(unsigned int) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1644:66
    #9 0x7f921d1e8d28 in tms32051_device::cpuregs_r(unsigned int) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/devices/cpu/tms32051/tms32051.cpp:614:16
    #10 0x7f922404dd98 in operator() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/lib/util/delegate.h:765:11
    #11 0x7f922404dd98 in std::enable_if<(((std::is_same<emu::device_delegate<unsigned short (unsigned int)>, emu::device_delegate<unsigned char (unsigned int)> >::value) || (std::is_same<emu::device_delegate<unsigned short (unsigned int)>, emu::device_delegate<unsigned short (unsigned int)> >::value)) || (std::is_same<emu::device_delegate<unsigned short (unsigned int)>, emu::device_delegate<unsigned int (unsigned int)> >::value)) || (std::is_same<emu::device_delegate<unsigned short (unsigned int)>, emu::device_delegate<unsigned long (unsigned int)> >::value), unsigned short>::type handler_entry_read_delegate<1, -1, emu::device_delegate<unsigned short (unsigned int)> >::read_impl<emu::device_delegate<unsigned short (unsigned int)> >(unsigned int, unsigned short) const /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem_hedp.cpp:45:9
    #12 0x7f922404dc20 in handler_entry_read_delegate<1, -1, emu::device_delegate<unsigned short (unsigned int)> >::read(unsigned int, unsigned short) const /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem_hedp.cpp:70:9
    #13 0x7f92188c5d0e in emu::detail::handler_entry_size<1>::uX dispatch_read<0, 1, -1>(unsigned int, unsigned int, emu::detail::handler_entry_size<1>::uX, handler_entry_read<1, -1> const* const*) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1570:47
    #14 0x7f9224bf5059 in handler_entry_read_dispatch<14, 1, -1>::read(unsigned int, unsigned short) const /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem_hedr.ipp:132:9
    #15 0x7f9218d62e21 in emu::detail::handler_entry_size<1>::uX dispatch_read<1, 1, -1>(unsigned int, unsigned int, emu::detail::handler_entry_size<1>::uX, handler_entry_read<1, -1> const* const*) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1570:47
    #16 0x7f9218d5b3a1 in read_native /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1737:10
    #17 0x7f9218d5b3a1 in emu::detail::memory_access_specific<1, 1, -1, (util::endianness)0>::read_word(unsigned int) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.h:1644:66
    #18 0x7f921d2055de in DM_READ16 /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/devices/cpu/tms32051/tms32051.cpp:151:16
    #19 0x7f921d2055de in tms32051_device::op_bldd_dlimm() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/devices/cpu/tms32051/32051ops.hxx:1269:19
    #20 0x7f921d21ea54 in tms32051_device::execute_run() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/devices/cpu/tms32051/tms32051.cpp:503:4
    #21 0x7f921d21fe3f in non-virtual thunk to tms32051_device::execute_run() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/devices/cpu/tms32051/tms32051.cpp
    #22 0x7f92297e8817 in run /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/diexec.h:190:15
    #23 0x7f92297e8817 in device_scheduler::timeslice() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/schedule.cpp:456:14
    #24 0x7f92296814a7 in running_machine::run(bool) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:329:17
    #25 0x7f922c7e7f7f in mame_machine_manager::execute() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:290:19
    #26 0x7f922c9dc8d6 in cli_frontend::start_execution(mame_machine_manager*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:275:22
    #27 0x7f922c9e041f in cli_frontend::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:291:3
    #28 0x7f922c7ecd5f in emulator_info::start_frontend(emu_options&, osd_interface&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:454:18
    #29 0x7f92299c358b in main /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:191:9
    #30 0x7f91e7ec9209 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #31 0x7f91e7ec92bb in __libc_start_main csu/../csu/libc-start.c:389:3
    #32 0x7f920714d260 in _start (/mnt/s/GitHub/mame/mame+0x1d397260) (BuildId: 603d3d1c300651feb2a8e3ac6e9cb58d3f85e77b)

0x7f91c93f1800 is located 0 bytes to the right of 12582912-byte region [0x7f91c87f1800,0x7f91c93f1800)
allocated by thread T0 here:
    #0 0x7f920720ae7d in operator new(unsigned long) (/mnt/s/GitHub/mame/mame+0x1d454e7d) (BuildId: 603d3d1c300651feb2a8e3ac6e9cb58d3f85e77b)
    #1 0x7f92077de742 in allocate /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/new_allocator.h:137:27
    #2 0x7f92077de742 in allocate /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:464:20
    #3 0x7f92077de742 in std::_Vector_base<unsigned char, std::allocator<unsigned char> >::_M_allocate(unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:378:20
    #4 0x7f92077de6a1 in std::_Vector_base<unsigned char, std::allocator<unsigned char> >::_M_create_storage(unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:395:33
    #5 0x7f92077de603 in std::_Vector_base<unsigned char, std::allocator<unsigned char> >::_Vector_base(unsigned long, std::allocator<unsigned char> const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:332:9
    #6 0x7f92077de586 in std::vector<unsigned char, std::allocator<unsigned char> >::vector(unsigned long, std::allocator<unsigned char> const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:552:9
    #7 0x7f922302a382 in memory_region::memory_region(running_machine&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned char, util::endianness) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.cpp:1040:3
    #8 0x7f922303eb37 in std::__detail::_MakeUniq<memory_region>::__single_object std::make_unique<memory_region, running_machine&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned int&, unsigned char&, util::endianness&>(running_machine&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned int&, unsigned char&, util::endianness&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:1065:34
    #9 0x7f92230177d4 in memory_manager::region_alloc(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned char, util::endianness) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/emumem.cpp:331:36
    #10 0x7f92297bae76 in rom_load_manager::process_region_list() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/romload.cpp:1369:35
    #11 0x7f92297bd19d in rom_load_manager::rom_load_manager(running_machine&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/romload.cpp:1481:2
    #12 0x7f922967dbbd in make_unique<rom_load_manager, running_machine &> /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:1065:34
    #13 0x7f922967dbbd in running_machine::start() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:182:15
    #14 0x7f92296810dc in running_machine::run(bool) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:281:3
    #15 0x7f922c7e7f7f in mame_machine_manager::execute() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:290:19
    #16 0x7f922c9dc8d6 in cli_frontend::start_execution(mame_machine_manager*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:275:22
    #17 0x7f922c9e041f in cli_frontend::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:291:3
    #18 0x7f922c7ecd5f in emulator_info::start_frontend(emu_options&, osd_interface&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:454:18
    #19 0x7f92299c358b in main /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:191:9
    #20 0x7f91e7ec9209 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

SUMMARY: AddressSanitizer: heap-buffer-overflow /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/taito/taitopjc.cpp:713:18 in taitopjc_state::dsp_rom_r()
Shadow bytes around the buggy address:
  0x0ff2b92762b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff2b92762c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff2b92762d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff2b92762e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff2b92762f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ff2b9276300:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0ff2b9276310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0ff2b9276320: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0ff2b9276330: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0ff2b9276340: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0ff2b9276350: 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
Steps To Reproduce
Additional Information
Github Commit
Flags
Regression Version
Affected Sets / Systems optiger
Attached Files
 
Relationships
There are no relationship linked to this issue.
Notes
2
User avatar
No.20701
Firewave
Senior Tester
Nov 4, 2022, 15:08
The "poly" region is 12582912 (0xc00000) bytes.

taitopjc_state::dsp_rom_r() has an assert which checks if m_dsp_rom_address is in range but it only checks for 0x800000. That checks seems outdated. Also with this check it should assert in a debug build.
User avatar
No.20914
hap
Developer
Dec 4, 2022, 17:35
rom region was simply the wrong size (there's an unpopulated 4th rom, address range should be good now)
should be fixed here: https://github.com/mamedev/mame/commit/35d28d3cd4ac2b3e3e758112007e69524e8392e9