lgi-devs / lgi-devs/lgi

no strack trace in callback errors

Open
#124 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
491
Forks
81
PR merge metrics
No merged PRs in 30d

Description

Currently when an error occurs inside a callback, it displays the error message via a gtk warning, but it doesn't display a proper stack trace like a normal Lua error. This makes debugging problems inside callbacks hard.

Example code:

local lgi = require "lgi"
local Gtk = lgi.Gtk

local function evil_code(w)
    w:add(nil)
end

local function some_stuff(w)
    evil_code(w)
end

local window = Gtk.Window{
    on_destroy = Gtk.main_quit,
    Gtk.Button{
        label = "Click to crash",
        margin = 10,
        on_clicked = function(w)
            some_stuff(w)
        end
    }
}

window:show_all()
Gtk.main()

example output after causing an error:

(lua:4090): Lgi-WARNING **: Error raised while calling 'lgi.cbk (function: 0x1001410): GObject': /usr/local/share/lua/5.1/lgi/override/Gtk.lua:139: bad argument #3 to 'add' (Gtk.Widget expected, got nil)

expected output: a full stack trace similar to this

lua: ./error_test.lua:6: attempt to index local 'w' (a nil value)
stack traceback:
    ./error_test.lua:6: in function 'evil_code'
    ./error_test.lua:10: in function 'some_stuff'
    ./error_test.lua:14: in function <./error_test.lua:13>
    ./error_test.lua:15: in main chunk

Using lgi 0.9.0 under Gentoo Linux x86_64, with Gtk 3.16.7

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the callback failure using the Lua/Gtk example and the stated lgi 0.9.0 environment, then trace how callback errors are reported. Done means the warning includes a full Lua stack traceback showing the callback's calling functions, rather than only the error message.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.