Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate some debug.cpp commands to Lua #6774

Merged
merged 1 commit into from
Nov 4, 2023
Merged

Conversation

glebm
Copy link
Collaborator

@glebm glebm commented Nov 4, 2023

Introduces a new devilutionx.dev Lua module, automatically loaded in the console prelude.

Arguments and basic help are shown in autocompletion.

lua-dev-all

We can now also group commands, as seen here with quests:

lua-dev-quests

Signatures and docstrings are implemented as a bit of a hack:

> inspect(dev.quests)
{
  __doc_activate = "Activates the given quest.",
  __doc_activateAll = "Activates all available quests.",
  __doc_all = "Information on all available quest.",
  __doc_info = "Information on the given quest.",
  __sig_activate = "(id: number)",
  __sig_activateAll = "()",
  __sig_all = "()",
  __sig_info = "(id: number)",
  activate = <function 1>,
  activateAll = <function 2>,
  all = <function 3>,
  info = <function 4>
}

We simply put them on the same table as the functions. Autocomplete doesn't show the keys starting with __ unless the query starts with __.

@glebm glebm enabled auto-merge (rebase) November 4, 2023 11:19
Introduces a new `devilutionx.dev` Lua module, automatically loaded in
the console prelude.

Arguments and basic help are shown in autocompletion.
@glebm glebm merged commit 8bffbed into diasurgical:master Nov 4, 2023
19 checks passed
@AJenbo
Copy link
Member

AJenbo commented Nov 4, 2023

dev.quets.all()
shift+up gives me some asan errors:

=================================================================
==203105==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f9a329793a8 at pc 0x5560d974eabd bp 0x7ffe0b58c990 sp 0x7ffe0b58c980
WRITE of size 1 at 0x7f9a329793a8 thread T0
    #0 0x5560d974eabc in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:67
    #1 0x5560d974eabc in devilution::BlitWithMap::operator()(devilution::BlitCommand, unsigned char*, unsigned char const*) const /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:122
    #2 0x5560d974eabc in DoRenderBackwardsClipY<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:117
    #3 0x5560d974eabc in DoRenderBackwards<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:204
    #4 0x5560d974eabc in devilution::ClxDrawTRN(devilution::Surface const&, devilution::PointOf<int>, devilution::ClxSprite, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:791
    #5 0x5560d986524e in devilution::RenderClxSpriteWithTRN(devilution::Surface const&, devilution::ClxSprite, devilution::PointOf<int>, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.hpp:80
    #6 0x5560d986524e in DrawFont /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:232
    #7 0x5560d988f716 in DoDrawString /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:472
    #8 0x5560d9891dd9 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::RectangleOf<int, int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:722
    #9 0x5560d8b33460 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::PointOf<int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.hpp:240
    #10 0x5560d9b3ff84 in DrawInputText /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:222
    #11 0x5560d9b46e9e in devilution::DrawConsole(devilution::Surface const&) /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:583
    #12 0x5560d9853038 in devilution::DrawAndBlit() /home/ajenbo/code/diablo/devilutionX/Source/engine/render/scrollrt.cpp:1665
    #13 0x5560d8c26109 in RunGameLoop /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:850
    #14 0x5560d8c51cd7 in devilution::StartGame(bool, bool) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2413
    #15 0x5560d8f05aea in InitMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:59
    #16 0x5560d8f05b51 in InitSinglePlayerMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:69
    #17 0x5560d8f06767 in devilution::mainmenu_loop() /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:162
    #18 0x5560d8c51f2f in devilution::DiabloMain(int, char**) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2482
    #19 0x5560d8ab032d in main /home/ajenbo/code/diablo/devilutionX/Source/main.cpp:52
    #20 0x7f9a4ce280cf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #21 0x7f9a4ce28188 in __libc_start_main_impl ../csu/libc-start.c:360
    #22 0x5560d8ab0234 in _start (/home/ajenbo/code/diablo/devilutionX/build/devilutionx+0x2f31234) (BuildId: 67cbd3bdbcf27f70d69c5670f97147adc38f2049)

0x7f9a329793a8 is located 1112 bytes before 551080-byte region [0x7f9a32979800,0x7f9a32a000a8)
allocated by thread T0 here:
    #0 0x7f9a4e0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f9a4dd98029  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x44029) (BuildId: 29cb054ab7c4d5d773d8d75905971d416d2b8033)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:67 in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*)
Shadow bytes around the buggy address:
  0x7f9a32979100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x7f9a32979380: fa fa fa fa fa[fa]fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979600: 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
=================================================================
==203105==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f9a329793aa at pc 0x7f9a4e05b912 bp 0x7ffe0b58c990 sp 0x7ffe0b58c138
WRITE of size 2 at 0x7f9a329793aa thread T0
    #0 0x7f9a4e05b911 in __interceptor_memset ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:871
    #1 0x5560d974d140 in memset /usr/include/x86_64-linux-gnu/bits/string_fortified.h:59
    #2 0x5560d974d140 in devilution::BlitFillWithMap(unsigned char*, unsigned int, unsigned char, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:53
    #3 0x5560d974d140 in devilution::BlitWithMap::operator()(devilution::BlitCommand, unsigned char*, unsigned char const*) const /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:119
    #4 0x5560d974d140 in DoRenderBackwardsClipY<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:117
    #5 0x5560d974d140 in DoRenderBackwards<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:204
    #6 0x5560d974d140 in devilution::ClxDrawTRN(devilution::Surface const&, devilution::PointOf<int>, devilution::ClxSprite, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:791
    #7 0x5560d986524e in devilution::RenderClxSpriteWithTRN(devilution::Surface const&, devilution::ClxSprite, devilution::PointOf<int>, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.hpp:80
    #8 0x5560d986524e in DrawFont /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:232
    #9 0x5560d988f716 in DoDrawString /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:472
    #10 0x5560d9891dd9 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::RectangleOf<int, int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:722
    #11 0x5560d8b33460 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::PointOf<int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.hpp:240
    #12 0x5560d9b3ff84 in DrawInputText /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:222
    #13 0x5560d9b46e9e in devilution::DrawConsole(devilution::Surface const&) /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:583
    #14 0x5560d9853038 in devilution::DrawAndBlit() /home/ajenbo/code/diablo/devilutionX/Source/engine/render/scrollrt.cpp:1665
    #15 0x5560d8c26109 in RunGameLoop /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:850
    #16 0x5560d8c51cd7 in devilution::StartGame(bool, bool) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2413
    #17 0x5560d8f05aea in InitMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:59
    #18 0x5560d8f05b51 in InitSinglePlayerMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:69
    #19 0x5560d8f06767 in devilution::mainmenu_loop() /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:162
    #20 0x5560d8c51f2f in devilution::DiabloMain(int, char**) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2482
    #21 0x5560d8ab032d in main /home/ajenbo/code/diablo/devilutionX/Source/main.cpp:52
    #22 0x7f9a4ce280cf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #23 0x7f9a4ce28188 in __libc_start_main_impl ../csu/libc-start.c:360
    #24 0x5560d8ab0234 in _start (/home/ajenbo/code/diablo/devilutionX/build/devilutionx+0x2f31234) (BuildId: 67cbd3bdbcf27f70d69c5670f97147adc38f2049)

0x7f9a329793aa is located 1110 bytes before 551080-byte region [0x7f9a32979800,0x7f9a32a000a8)
allocated by thread T0 here:
    #0 0x7f9a4e0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f9a4dd98029  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x44029) (BuildId: 29cb054ab7c4d5d773d8d75905971d416d2b8033)

SUMMARY: AddressSanitizer: heap-buffer-overflow ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:871 in __interceptor_memset
Shadow bytes around the buggy address:
  0x7f9a32979100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x7f9a32979380: fa fa fa fa fa[fa]fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979600: 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
=================================================================
==203105==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f9a329793c4 at pc 0x5560d974e55d bp 0x7ffe0b58c990 sp 0x7ffe0b58c980
WRITE of size 1 at 0x7f9a329793c4 thread T0
    #0 0x5560d974e55c in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:61
    #1 0x5560d974e55c in devilution::BlitWithMap::operator()(devilution::BlitCommand, unsigned char*, unsigned char const*) const /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:122
    #2 0x5560d974e55c in DoRenderBackwardsClipY<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:117
    #3 0x5560d974e55c in DoRenderBackwards<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:204
    #4 0x5560d974e55c in devilution::ClxDrawTRN(devilution::Surface const&, devilution::PointOf<int>, devilution::ClxSprite, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:791
    #5 0x5560d986524e in devilution::RenderClxSpriteWithTRN(devilution::Surface const&, devilution::ClxSprite, devilution::PointOf<int>, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.hpp:80
    #6 0x5560d986524e in DrawFont /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:232
    #7 0x5560d988f716 in DoDrawString /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:472
    #8 0x5560d9891dd9 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::RectangleOf<int, int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:722
    #9 0x5560d8b33460 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::PointOf<int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.hpp:240
    #10 0x5560d9b3ff84 in DrawInputText /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:222
    #11 0x5560d9b46e9e in devilution::DrawConsole(devilution::Surface const&) /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:583
    #12 0x5560d9853038 in devilution::DrawAndBlit() /home/ajenbo/code/diablo/devilutionX/Source/engine/render/scrollrt.cpp:1665
    #13 0x5560d8c26109 in RunGameLoop /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:850
    #14 0x5560d8c51cd7 in devilution::StartGame(bool, bool) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2413
    #15 0x5560d8f05aea in InitMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:59
    #16 0x5560d8f05b51 in InitSinglePlayerMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:69
    #17 0x5560d8f06767 in devilution::mainmenu_loop() /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:162
    #18 0x5560d8c51f2f in devilution::DiabloMain(int, char**) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2482
    #19 0x5560d8ab032d in main /home/ajenbo/code/diablo/devilutionX/Source/main.cpp:52
    #20 0x7f9a4ce280cf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #21 0x7f9a4ce28188 in __libc_start_main_impl ../csu/libc-start.c:360
    #22 0x5560d8ab0234 in _start (/home/ajenbo/code/diablo/devilutionX/build/devilutionx+0x2f31234) (BuildId: 67cbd3bdbcf27f70d69c5670f97147adc38f2049)

0x7f9a329793c4 is located 1084 bytes before 551080-byte region [0x7f9a32979800,0x7f9a32a000a8)
allocated by thread T0 here:
    #0 0x7f9a4e0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f9a4dd98029  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x44029) (BuildId: 29cb054ab7c4d5d773d8d75905971d416d2b8033)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:61 in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*)
Shadow bytes around the buggy address:
  0x7f9a32979100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x7f9a32979380: fa fa fa fa fa fa fa fa[fa]fa fa fa fa fa fa fa
  0x7f9a32979400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979600: 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
=================================================================
==203105==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f9a329793c5 at pc 0x5560d974e272 bp 0x7ffe0b58c990 sp 0x7ffe0b58c980
WRITE of size 1 at 0x7f9a329793c5 thread T0
    #0 0x5560d974e271 in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:62
    #1 0x5560d974e271 in devilution::BlitWithMap::operator()(devilution::BlitCommand, unsigned char*, unsigned char const*) const /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:122
    #2 0x5560d974e271 in DoRenderBackwardsClipY<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:117
    #3 0x5560d974e271 in DoRenderBackwards<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:204
    #4 0x5560d974e271 in devilution::ClxDrawTRN(devilution::Surface const&, devilution::PointOf<int>, devilution::ClxSprite, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:791
    #5 0x5560d986524e in devilution::RenderClxSpriteWithTRN(devilution::Surface const&, devilution::ClxSprite, devilution::PointOf<int>, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.hpp:80
    #6 0x5560d986524e in DrawFont /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:232
    #7 0x5560d988f716 in DoDrawString /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:472
    #8 0x5560d9891dd9 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::RectangleOf<int, int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:722
    #9 0x5560d8b33460 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::PointOf<int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.hpp:240
    #10 0x5560d9b3ff84 in DrawInputText /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:222
    #11 0x5560d9b46e9e in devilution::DrawConsole(devilution::Surface const&) /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:583
    #12 0x5560d9853038 in devilution::DrawAndBlit() /home/ajenbo/code/diablo/devilutionX/Source/engine/render/scrollrt.cpp:1665
    #13 0x5560d8c26109 in RunGameLoop /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:850
    #14 0x5560d8c51cd7 in devilution::StartGame(bool, bool) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2413
    #15 0x5560d8f05aea in InitMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:59
    #16 0x5560d8f05b51 in InitSinglePlayerMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:69
    #17 0x5560d8f06767 in devilution::mainmenu_loop() /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:162
    #18 0x5560d8c51f2f in devilution::DiabloMain(int, char**) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2482
    #19 0x5560d8ab032d in main /home/ajenbo/code/diablo/devilutionX/Source/main.cpp:52
    #20 0x7f9a4ce280cf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #21 0x7f9a4ce28188 in __libc_start_main_impl ../csu/libc-start.c:360
    #22 0x5560d8ab0234 in _start (/home/ajenbo/code/diablo/devilutionX/build/devilutionx+0x2f31234) (BuildId: 67cbd3bdbcf27f70d69c5670f97147adc38f2049)

0x7f9a329793c5 is located 1083 bytes before 551080-byte region [0x7f9a32979800,0x7f9a32a000a8)
allocated by thread T0 here:
    #0 0x7f9a4e0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f9a4dd98029  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x44029) (BuildId: 29cb054ab7c4d5d773d8d75905971d416d2b8033)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:62 in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*)
Shadow bytes around the buggy address:
  0x7f9a32979100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x7f9a32979380: fa fa fa fa fa fa fa fa[fa]fa fa fa fa fa fa fa
  0x7f9a32979400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979600: 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
=================================================================
==203105==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f9a329793c6 at pc 0x5560d974df87 bp 0x7ffe0b58c990 sp 0x7ffe0b58c980
WRITE of size 1 at 0x7f9a329793c6 thread T0
    #0 0x5560d974df86 in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:63
    #1 0x5560d974df86 in devilution::BlitWithMap::operator()(devilution::BlitCommand, unsigned char*, unsigned char const*) const /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:122
    #2 0x5560d974df86 in DoRenderBackwardsClipY<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:117
    #3 0x5560d974df86 in DoRenderBackwards<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:204
    #4 0x5560d974df86 in devilution::ClxDrawTRN(devilution::Surface const&, devilution::PointOf<int>, devilution::ClxSprite, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:791
    #5 0x5560d986524e in devilution::RenderClxSpriteWithTRN(devilution::Surface const&, devilution::ClxSprite, devilution::PointOf<int>, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.hpp:80
    #6 0x5560d986524e in DrawFont /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:232
    #7 0x5560d988f716 in DoDrawString /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:472
    #8 0x5560d9891dd9 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::RectangleOf<int, int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:722
    #9 0x5560d8b33460 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::PointOf<int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.hpp:240
    #10 0x5560d9b3ff84 in DrawInputText /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:222
    #11 0x5560d9b46e9e in devilution::DrawConsole(devilution::Surface const&) /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:583
    #12 0x5560d9853038 in devilution::DrawAndBlit() /home/ajenbo/code/diablo/devilutionX/Source/engine/render/scrollrt.cpp:1665
    #13 0x5560d8c26109 in RunGameLoop /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:850
    #14 0x5560d8c51cd7 in devilution::StartGame(bool, bool) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2413
    #15 0x5560d8f05aea in InitMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:59
    #16 0x5560d8f05b51 in InitSinglePlayerMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:69
    #17 0x5560d8f06767 in devilution::mainmenu_loop() /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:162
    #18 0x5560d8c51f2f in devilution::DiabloMain(int, char**) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2482
    #19 0x5560d8ab032d in main /home/ajenbo/code/diablo/devilutionX/Source/main.cpp:52
    #20 0x7f9a4ce280cf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #21 0x7f9a4ce28188 in __libc_start_main_impl ../csu/libc-start.c:360
    #22 0x5560d8ab0234 in _start (/home/ajenbo/code/diablo/devilutionX/build/devilutionx+0x2f31234) (BuildId: 67cbd3bdbcf27f70d69c5670f97147adc38f2049)

0x7f9a329793c6 is located 1082 bytes before 551080-byte region [0x7f9a32979800,0x7f9a32a000a8)
allocated by thread T0 here:
    #0 0x7f9a4e0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f9a4dd98029  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x44029) (BuildId: 29cb054ab7c4d5d773d8d75905971d416d2b8033)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:63 in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*)
Shadow bytes around the buggy address:
  0x7f9a32979100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x7f9a32979380: fa fa fa fa fa fa fa fa[fa]fa fa fa fa fa fa fa
  0x7f9a32979400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979600: 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
=================================================================
==203105==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f9a329793c7 at pc 0x5560d974dc9c bp 0x7ffe0b58c990 sp 0x7ffe0b58c980
WRITE of size 1 at 0x7f9a329793c7 thread T0
    #0 0x5560d974dc9b in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:64
    #1 0x5560d974dc9b in devilution::BlitWithMap::operator()(devilution::BlitCommand, unsigned char*, unsigned char const*) const /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:122
    #2 0x5560d974dc9b in DoRenderBackwardsClipY<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:117
    #3 0x5560d974dc9b in DoRenderBackwards<devilution::BlitWithMap> /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:204
    #4 0x5560d974dc9b in devilution::ClxDrawTRN(devilution::Surface const&, devilution::PointOf<int>, devilution::ClxSprite, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.cpp:791
    #5 0x5560d986524e in devilution::RenderClxSpriteWithTRN(devilution::Surface const&, devilution::ClxSprite, devilution::PointOf<int>, unsigned char const*) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/clx_render.hpp:80
    #6 0x5560d986524e in DrawFont /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:232
    #7 0x5560d988f716 in DoDrawString /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:472
    #8 0x5560d9891dd9 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::RectangleOf<int, int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.cpp:722
    #9 0x5560d8b33460 in devilution::DrawString(devilution::Surface const&, std::basic_string_view<char, std::char_traits<char> >, devilution::PointOf<int> const&, devilution::TextRenderOptions) /home/ajenbo/code/diablo/devilutionX/Source/engine/render/text_render.hpp:240
    #10 0x5560d9b3ff84 in DrawInputText /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:222
    #11 0x5560d9b46e9e in devilution::DrawConsole(devilution::Surface const&) /home/ajenbo/code/diablo/devilutionX/Source/panels/console.cpp:583
    #12 0x5560d9853038 in devilution::DrawAndBlit() /home/ajenbo/code/diablo/devilutionX/Source/engine/render/scrollrt.cpp:1665
    #13 0x5560d8c26109 in RunGameLoop /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:850
    #14 0x5560d8c51cd7 in devilution::StartGame(bool, bool) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2413
    #15 0x5560d8f05aea in InitMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:59
    #16 0x5560d8f05b51 in InitSinglePlayerMenu /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:69
    #17 0x5560d8f06767 in devilution::mainmenu_loop() /home/ajenbo/code/diablo/devilutionX/Source/menu.cpp:162
    #18 0x5560d8c51f2f in devilution::DiabloMain(int, char**) /home/ajenbo/code/diablo/devilutionX/Source/diablo.cpp:2482
    #19 0x5560d8ab032d in main /home/ajenbo/code/diablo/devilutionX/Source/main.cpp:52
    #20 0x7f9a4ce280cf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #21 0x7f9a4ce28188 in __libc_start_main_impl ../csu/libc-start.c:360
    #22 0x5560d8ab0234 in _start (/home/ajenbo/code/diablo/devilutionX/build/devilutionx+0x2f31234) (BuildId: 67cbd3bdbcf27f70d69c5670f97147adc38f2049)

0x7f9a329793c7 is located 1081 bytes before 551080-byte region [0x7f9a32979800,0x7f9a32a000a8)
allocated by thread T0 here:
    #0 0x7f9a4e0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f9a4dd98029  (/lib/x86_64-linux-gnu/libSDL2-2.0.so.0+0x44029) (BuildId: 29cb054ab7c4d5d773d8d75905971d416d2b8033)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/ajenbo/code/diablo/devilutionX/Source/engine/render/blit_impl.hpp:64 in devilution::BlitPixelsWithMap(unsigned char*, unsigned char const*, unsigned int, unsigned char const*)
Shadow bytes around the buggy address:
  0x7f9a32979100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x7f9a32979380: fa fa fa fa fa fa fa fa[fa]fa fa fa fa fa fa fa
  0x7f9a32979400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979500: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979580: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x7f9a32979600: 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

@glebm glebm deleted the lua-debug branch November 4, 2023 21:05
@StephenCWills
Copy link
Member

dev.quets.all()
shift+up gives me some asan errors:

@AJenbo I'm unable to reproduce. Are you able to reproduce? And if so, what is your game's resolution?

@AJenbo
Copy link
Member

AJenbo commented Nov 5, 2023

I belive it was fixed here: 4f23762

@StephenCWills
Copy link
Member

Oh, good. Didn't even see that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants