Page 1 of 1

plugin crash

Posted: Sat Jul 26, 2025 12:31 am
by dcaputi
ChatGPT is helping me write a lua script for my pi 5 and a PACDrive USB LED driver.
I finally got past "could not load plugin" and now get "segmentation fault"
AI has me now trying to load the cheatfind plugin to see if *any* plugins work and that's also crashing mame on startup.

This is 0.276 build from master.

I guess I'd like a real person to maybe suggest how to troubleshoot the crash
Or as a sanity check: this should work, no?

Thanks in advance for ANY ideas, suggestions, links, etc...

Re: plugin crash

Posted: Sat Jul 26, 2025 3:01 pm
by dcaputi
Tried to load cheatfind plugin with 0.265 on my Windows PC and got much more info on the crash:

Code: Select all

H:\MAME_0.265>mame -verbose -plugin cheatfind
Attempting load of mame.ini
Parsing mame.ini
Attempting load of mame.ini
Parsing mame.ini

-----------------------------------------------------
Exception at EIP=00007ffeae15d2f1 (__cxa_throw_bad_array_new_length+0x3dc2c811): ACCESS VIOLATION
While attempting to read memory at 0000000000000000
-----------------------------------------------------
RAX=0000000000000000 RBX=0000000000000006 RCX=0000000000000000 RDX=0000000000000000
RSI=0000000000000006 RDI=0000ffffffffffff RBP=0000000000000004 RSP=0000009ad399e828
 R8=7efefefefefefeff  R9=000002345946cf98 R10=0000000000000000 R11=8101010101010100
R12=0000000000000000 R13=0000000000000004 R14=000002345947e520 R15=00007ff77461133b
-----------------------------------------------------
Stack crawl:
  0000009ad399e820: 00007ffeae15d2f1 (strlen+0x0031)
  0000009ad399ed40: 00007ff76d421915 (plugin_options::load_plugin(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x0c25)
  0000009ad399edf0: 00007ff76d422e47 (plugin_options::scan_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)+0x0197)
  0000009ad399eea0: 00007ff76d422fcd (plugin_options::scan_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)+0x031d)
  0000009ad399f210: 00007ff7691585b2 (mame_machine_manager::start_luaengine()+0x05e2)
  0000009ad399f5f0: 00007ff76d3fb2e5 (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&)+0x0265)
  0000009ad399f8b0: 00007ff76d3fba5d (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> > > >&)+0x004d)
  0000009ad399f910: 00007ff769154149 (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> > > >&)+0x0029)
  0000009ad399fcd0: 00007ff76f0e2eb3 (luaopen_lfs+0xf8c9d3)
  0000009ad399fda0: 00007ff760ac13b1 (__tmainCRTStartup+0x0231)
  0000009ad399fdd0: 00007ff760ac14e6 (mainCRTStartup+0x0016)
  0000009ad399fe00: 00007ffead2c7374 (BaseThreadInitThunk+0x0014)
  0000009ad399fe80: 00007ffeaea1cc91 (RtlUserThreadStart+0x0021)
I could look in the code but sanity check: is this supposed to work? am I missing anything obvious?

Re: plugin crash

Posted: Sun Jul 27, 2025 1:16 pm
by mhoes
.

Re: plugin crash

Posted: Sun Jul 27, 2025 4:00 pm
by dcaputi
:lol: lol @ chatGPT... but thanks for the reply!

So I figured out the crash was because I was missing "type: plugin" in my plugin.json.

2 things that bother me are:
1. the load_plugin code should not crash if the json file is missing something - especially given the lack of documentation :?
2. the mainline plugin code traverses all the child folders and does not verbose print "loading plugin xyx..." until AFTER it calls the load_plugin function
(which is why I thought the cheatfind plugin was crashing)

So I guess this is another case of "garbage in / garbage out"
NUFF said - Thanks again for responding!