S. Petrić
S. Petrić

Reputation: 90

ZeroBrane remote debugging embedded script

I work on image processing application in Embarcadero C++ Builder XE10.2 that executes Lua scripts. I use LuaJIT with FFI to share image data. Everything works fine. I've downloaded ZeroBrane studio and tried to see if I can debug scripts executed from "host" C++ application, so I've included

package.path = package.path .. ";C:/Portable_App/ZeroBraneStudio/lualibs/mobdebug/?.lua"
package.cpath = package.cpath .. ";C:/Portable_App/ZeroBraneStudio/bin/clibs/?.dll"
require("mobdebug").start()

before any function in the script is called. However, when the script is loaded and executed (on C++ side):

FResult = lua_pcall(FLs, 0, 0, 0);

host program crashes with "floating point division by zero" exception. It crashes on

require("mobdebug").start()

Without this line script works OK. Any clue?

Upvotes: 1

Views: 307

Answers (1)

Paul Kulchenko
Paul Kulchenko

Reputation: 26754

It's not possible to tell what may be going wrong based on the provided information, but you can try to get the stack trace (using this SO answers), which should provide more information about what's leading to the error.

The only division that I'm aware of is in the serialization code that uses tostring(1/0) code to generate platform-independent NaN values. Would this lead to "floating point division by zero" error in your Lua configuration?

(Update to include the solution mentioned in comments) The issue was related to BCC compiler settings on how to handle FPU exceptions. One way is to manipulate FP control: _clear87(); _control87(MCW_EM, MCW_EM); or to set arithmetic exception mask: SetExceptionMask(exAllArithmeticExceptions);.

Upvotes: 1

Related Questions