WheretIB / LuaDkmDebugger

Visual Studio C++ debugger extensions for Lua
MIT License
84 stars 32 forks source link

Thread lock in LuaJIT when LuaDkmDebugger is attached #11

Closed Xottab-DUTY closed 3 years ago

Xottab-DUTY commented 3 years ago

My case is

  1. You need to have S.T.A.L.K.E.R.: Call of Pripyat or S.T.A.L.K.E.R.: Clear Sky.
  2. Compile OpenXRay project from sources with Release x64 or Release Master Gold x64 configuration according to the instructions.
  3. Enable 'Attach on Launch' of LuaDkmDebugger.
  4. Launch the game from the Visual Studio.
  5. The main thread will freeze forever inside LuaJIT in lua_newstate function, on if (!lj_prng_seed_secure(&prng)) { line. image

Probably, this can be reproduced with just dummy project that calls LuaJIT's implementation of lua_newstate, but I'm not sure.

This issue doesn't require LuaJIT support like #8 :) Just a possibility to improve the interaction with unknown Lua implementations.

WheretIB commented 3 years ago

I couldn't reproduce the thread lock (thread suspend at this point is possible, but I only know of a case when debugging x64 Windows 10 UWP) I didn't have resources to correctly run the OpenXRay project, but I could get it to a point where CScriptEngine::reinit is executed and thread didn't lock for me.

After looking at the debugger code I have found a case where debugger helper process launch can throw an exception and it wasn't handled correctly. I have included a fix for that in a Beta release: https://github.com/WheretIB/LuaDkmDebugger/releases/tag/v0.9.7 If the fix helps, sadly it would mean that the helper process for breakpoint/stepping hooks will not be available and only limited call stack inspection will be available.

If you can enable Lua Debugger -> Enable Debug Logs and attach the log here, it might help identifying the issue. Those logs can contain file paths, so look over them if you feel that they might contain private information (like source file names or the name of the PC User folder)

Xottab-DUTY commented 3 years ago

It still did hang in the same place. (well, inside lj_prng_seed_secure) Just in case: it only hangs when "Attach on Launch" option is enabled. image

Xottab-DUTY commented 3 years ago

Here's the log: lua_dkm_debug_log.txt

WheretIB commented 3 years ago

Log should be next to the executable that is being debugged. Delete the old file before the launch so that only the last debugger session will be stored there.

Xottab-DUTY commented 3 years ago

Log should be next to the executable that is being debugged.

Yeah, I managed to find it immediately after I asked where I can find it :D

WheretIB commented 3 years ago

Can you show the status line from the bottom of the 'Lua Script List' panel? image

Xottab-DUTY commented 3 years ago

image

WheretIB commented 3 years ago

Thank you, I was able to identify and reproduce the problem.

WheretIB commented 3 years ago

Fix for this issue has been released in https://github.com/WheretIB/LuaDkmDebugger/releases/tag/v0.9.8 and on the Markeplace.