In theory it should not matter, but you are calling a C++ function that then goes back into Lua, and there might be something weird I don't know about going on there, when you have layers of interfaces between the two. It makes me nervous.
I tried pausing the program during execution, but it said the program was running external code, which makes me think it is stuck in the Lua library somehow. I also tried to pause from VSCode, but it could not pause. This supports the same hypothesis.
The next thing I can do is build Lua into the engine as C++ instead of a compiled library, or maybe a debug build of the Lua lib, but I don't know if being able to pause inside the Lua VM will tell me anything useful.
I don't think you will be able to recreate this problem in C++.