lgi-devs / lgi-devs/lgi

'nil' signal handler crashes the app

Open
#166 1 comment 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

(I'm using lgi 0.9.1, the package provided with Ubuntu 16.10. Maybe the bug got fixed since then.)

When you install nil as a signal handler, the app crashes when it gets invoked. Here's an example:

#! /usr/bin/env lua

local lgi = require 'lgi'
local Gtk = lgi.Gtk

local w = Gtk.Window {
  title = "If you click the button, I'll crash",
  Gtk.Button { label = "click me!", id = "btn" },
  on_destroy = Gtk.main_quit,
}

local btn = w.child.btn
btn.on_clicked = nil    -- crash when clicked!

w:show_all()
Gtk.main()

(The bug is not specific to GtkButton, nor to on_clicked.)

BTW, I know there's no sense in assigning nil to a signal, as assignment adds a handler, not removes the previous one installed. I triggered the bug when I misspelled a function name. This kind of bugs (misspellings) can be hard to find (luacheck and strict.lua cannot always help).

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

Start with the Lua signal-assignment path exercised by btn.on_clicked = nil in the provided Gtk.Button example, and reproduce the crash by running the example and clicking the button. Done means assigning nil as a signal handler no longer crashes the application, including for signals other than on_clicked.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.