luagdbluajit

How do I debug a segfaulting lua program that imports .so files?


I recently published an application development toolkit written in lua. Here's a link to it: https://github.com/chris-montero/terra

This library was architected from the beginning to support high performance animations. This lua library has some C code that compiles to a few .so files which get imported by the lua code.

When you create a window, and keep resizing it for a while, at a certain point the whole program just segfaults. I get a coredump, but I am unsure how to use gdb (or anything else) to debug this kind of issue. I can't just do gdb -c core.12345 executable because there is no executable.

How can I go about debugging a lua program that imports .so files that segfault at some point?

Here's a link to the github issue, if you want more details: https://github.com/chris-montero/terra/issues/1


Solution

  • I found out how to solve my own issue.

    1. compile your .so files with debug symbols by passing the -g option to gcc (or whatever compiler you use)
    2. open up gdb.
    3. In gdb:
    (gdb) set debug jit 1
    (gdb) target exec /usr/bin/luajit
    (gdb) run ./your_program_name.lua