RfidResearchGroup / proxmark3

Iceman Fork - Proxmark3
http://www.icedev.se
GNU General Public License v3.0
4.03k stars 1.06k forks source link

Segfault when calling pm3 from Lua (experimental_lib) #2594

Closed doegox closed 3 weeks ago

doegox commented 3 weeks ago

Quick notes not to forget:

$ cd client/experimental_lib
$ ./01make_lib.sh
$ cd example_lua
$ ./01link_lib.sh
$ ./02run_test.sh
[=] Session log /home/phil/.proxmark3/logs/log_20241027110937.txt
[+] Using UART port /dev/ttyACM0
[+] Communicating with PM3 over USB-CDC
Segmentation fault

Problem appeared somewhere when Lua got migrated from 5.2 to 5.4: image

but to test these old commits, one has to add the missing line ${PM3_ROOT}/client/src/lua_bitlib.c in client/experimental_lib/CMakeLists.txt as done later with 50d9042a5cd5415dce0c54ad077529f12cbee108

doegox commented 3 weeks ago

@jmichelp could you have a look please?

jmichelp commented 3 weeks ago

Just had a go at testing. Works for me after a few tweaks due to OSX:

No segfault.

Will test on a Linux next.

jmichelp commented 3 weeks ago

Same behavior on Linux after an extra ln -sf ../../lualibs/dkjson.lua . to run the tests until the end

jmichelp commented 3 weeks ago

Considering that the example relies on the system lua binary, my current assumption would be that client and libraries were compiled against the bundled lua5.4 library but you're trying to run the script using your system lua.5.2 interpreter.

I could confirm this behavior on my Linux machine by running:

$ sudo apt remove lua5.4
$ sudo apt install lua5.2
$ ./02run_test.sh
[...]
[+] Communicating with PM3 over USB-CDC
./02run_test.sh: line 8: 2957012 Segmentation fault      ./test.lua
doegox commented 3 weeks ago

😮🤦‍♂️ that makes totally sense, thanks! I pushed a fix to call lua5.4 in the shebang and added the dkjson symlink