Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
06830 Misc. Critical (emulator) Always Jan 6, 2018, 23:37 31 days ago
Tester Firewave View Status Public Platform
Assigned To hap Resolution Fixed OS
Status [?] Resolved Driver
Version 0.193 Fixed in Version 0.250 Build
Fixed in Git Commit e8de74e Github Pull Request #
Summary 06830: starshp1, starshpp: AddressSanitizer: heap-buffer-overflow
Description
==196184==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f0955199800 at pc 0x0000067205e9 bp 0x7ffe101819f0 sp 0x7ffe101819e8
READ of size 2 at 0x7f0955199800 thread T0
    #0 0x67205e8 in draw_starfield /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/video/starshp1.cpp:161:9
    #1 0x67205e8 in starshp1_state::screen_update_starshp1(screen_device&, bitmap_ind16&, rectangle const&) /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/video/starshp1.cpp:354
    #2 0xe7ac132 in operator() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/lib/util/delegate.h:544:11
    #3 0xe7ac132 in screen_device::update_partial(int) /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/screen.cpp:1219
    #4 0xe833c67 in video_manager::finish_screen_updates() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/video.cpp:694:10
    #5 0xe8332a0 in video_manager::frame_update(bool) /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/video.cpp:208:27
    #6 0xe7aa719 in screen_device::vblank_begin() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/screen.cpp:1524:21
    #7 0xe7a9c7c in screen_device::device_timer(emu_timer&, unsigned int, int, void*) /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/screen.cpp:997:4
    #8 0xe795168 in timer_expired /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/device.h:520:83
    #9 0xe795168 in device_scheduler::execute_timers() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/schedule.cpp:906
    #10 0xe78ea0f in device_scheduler::timeslice() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/schedule.cpp:530:2
    #11 0xe6a324b in running_machine::run(bool) /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:357:17
    #12 0x8cd10e0 in mame_machine_manager::execute() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:236:19
    #13 0x8e1e0d3 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/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:257:22
    #14 0x8e20ee0 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/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:273:3
    #15 0x8cd3717 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/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:336:18
    #16 0x8acddf2 in main /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:216:9
    #17 0x7f096f46182f in __libc_start_main /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291
    #18 0x1431838 in _start (/mnt/mame/mame64_as+0x1431838)

0x7f0955199800 is located 0 bytes to the right of 131072-byte region [0x7f0955179800,0x7f0955199800)
allocated by thread T0 here:
    #0 0x14fd8a2 in operator new[](unsigned long) /opt/media/clang_nightly/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_new_delete.cc:95:3
    #1 0x671da85 in make_unique<unsigned short []> /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:771:30
    #2 0x671da85 in starshp1_state::video_start() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/video/starshp1.cpp:67
    #3 0xe1f11e9 in driver_device::device_start() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/driver.cpp:225:3
    #4 0xe0e345d in device_t::start() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/device.cpp:489:2
    #5 0xe6a1f65 in running_machine::start_all_devices() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:1040:13
    #6 0xe6a005d in running_machine::start() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:265:2
    #7 0xe6a2a41 in running_machine::run(bool) /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:310:3
    #8 0x8cd10e0 in mame_machine_manager::execute() /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:236:19
    #9 0x8e1e0d3 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/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:257:22
    #10 0x8e20ee0 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/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/clifront.cpp:273:3
    #11 0x8cd3717 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/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:336:18
    #12 0x8acddf2 in main /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:216:9
    #13 0x7f096f46182f in __libc_start_main /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291

SUMMARY: AddressSanitizer: heap-buffer-overflow /mnt/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/video/starshp1.cpp:161:9 in draw_starfield
Shadow bytes around the buggy address:
  0x0fe1aaa2b2b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe1aaa2b2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe1aaa2b2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe1aaa2b2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fe1aaa2b2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0fe1aaa2b300:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe1aaa2b310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe1aaa2b320: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe1aaa2b330: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe1aaa2b340: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fe1aaa2b350: 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 starshp1, starshpp
Attached Files
 
Relationships
There are no relationship linked to this issue.
Notes
5
User avatar
No.17335
Firewave
Senior Tester
Jan 9, 2020, 00:34
edited on: Jan 9, 2020, 01:10
m_LSFR is simply to small. It has a size of 0x10000 (65536) but starshp1_state::draw_starfield() accesses it up to the whole bitmap which is 768x262 although it clamps the start pointer. There's also some hard-coded usages of the screen size in the video code.
User avatar
No.20728
Firewave
Senior Tester
Nov 5, 2022, 08:53
0.249 on Linux reports:
==20659==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7ff442e91800 at pc 0x7ff47dd0183c bp 0x7fffd2e3a820 sp 0x7fffd2e3a818
READ of size 2 at 0x7ff442e91800 thread T0
    #0 0x7ff47dd0183b in starshp1_state::draw_starfield(bitmap_ind16&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/atari/starshp1_v.cpp:156:9
    #1 0x7ff47dd049a2 in starshp1_state::screen_update_starshp1(screen_device&, bitmap_ind16&, rectangle const&) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/atari/starshp1_v.cpp:344:3
    #2 0x7ff49ec9f56d in util::detail::delegate_base<delegate_late_bind, unsigned int, screen_device&, bitmap_ind16&, rectangle const&>::operator()(screen_device&, bitmap_ind16&, rectangle const&) const /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/lib/util/delegate.h:765:11
    #3 0x7ff49ec8f386 in screen_device::update_partial(int) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/screen.cpp:1215:41
    #4 0x7ff49ed8cbc9 in video_manager::finish_screen_updates() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/video.cpp:622:10
    #5 0x7ff49ed8b9cb in video_manager::frame_update(bool) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/video.cpp:215:44
    #6 0x7ff49ec857c8 in screen_device::vblank_begin(int) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/screen.cpp:1646:21
    #7 0x7ff49ec6e304 in operator() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/lib/util/delegate.h:765:11
    #8 0x7ff49ec6e304 in device_scheduler::execute_timers() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/schedule.cpp:951:5
    #9 0x7ff49ec69858 in device_scheduler::timeslice() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/schedule.cpp:505:2
    #10 0x7ff49eb014a7 in running_machine::run(bool) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:329:17
    #11 0x7ff4a1c67f7f in mame_machine_manager::execute() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:290:19
    #12 0x7ff4a1e5c8d6 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
    #13 0x7ff4a1e6041f 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
    #14 0x7ff4a1c6cd5f 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
    #15 0x7ff49ee4358b in main /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:191:9
    #16 0x7ff45d349209 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #17 0x7ff45d3492bb in __libc_start_main csu/../csu/libc-start.c:389:3
    #18 0x7ff47c5cd260 in _start (/mnt/s/GitHub/mame/mame+0x1d397260) (BuildId: 603d3d1c300651feb2a8e3ac6e9cb58d3f85e77b)

0x7ff442e91800 is located 0 bytes to the right of 131072-byte region [0x7ff442e71800,0x7ff442e91800)
allocated by thread T0 here:
    #0 0x7ff47c68af8d in operator new[](unsigned long) (/mnt/s/GitHub/mame/mame+0x1d454f8d) (BuildId: 603d3d1c300651feb2a8e3ac6e9cb58d3f85e77b)
    #1 0x7ff47dcffa3b in make_unique<unsigned short[]> /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:1080:30
    #2 0x7ff47dcffa3b in starshp1_state::video_start() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/mame/atari/starshp1_v.cpp:65:11
    #3 0x7ff49848fa89 in driver_device::device_start() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/driver.cpp:226:3
    #4 0x7ff4982dd410 in device_t::start() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/device.cpp:562:2
    #5 0x7ff49eb002df in running_machine::start_all_devices() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:1013:13
    #6 0x7ff49eafe2b4 in running_machine::start() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:211:2
    #7 0x7ff49eb010dc in running_machine::run(bool) /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/emu/machine.cpp:281:3
    #8 0x7ff4a1c67f7f in mame_machine_manager::execute() /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/frontend/mame/mame.cpp:290:19
    #9 0x7ff4a1e5c8d6 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
    #10 0x7ff4a1e6041f 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
    #11 0x7ff4a1c6cd5f 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
    #12 0x7ff49ee4358b in main /mnt/s/GitHub/mame/build/projects/sdl/mame/gmake-linux-clang/../../../../../src/osd/sdl/sdlmain.cpp:191:9
    #13 0x7ff45d349209 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/atari/starshp1_v.cpp:156:9 in starshp1_state::draw_starfield(bitmap_ind16&)
Shadow bytes around the buggy address:
  0x0fff085ca2b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fff085ca2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fff085ca2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fff085ca2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fff085ca2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0fff085ca300:[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fff085ca310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fff085ca320: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fff085ca330: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fff085ca340: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fff085ca350: 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
User avatar
No.20766
hap
Developer
31 days ago
maybe fixed here: https://github.com/mamedev/mame/commit/e8de74ea0540affa18a37b265ac9bab3dc884ca7
User avatar
No.20767
Firewave
Senior Tester
31 days ago
Cherry-picked and fix confirmed.

This does fix the ASAN error but I am not convinced this is correct. I left a comment on the commit and CC'd Frank Palazzolo who actually has the knowledge what it is supposed to do.
User avatar
No.20770
hap
Developer
31 days ago
There was a comment in the driver saying that the LFSR is not active in screen blanking area.