lgi-devs / lgi-devs/lgi

GtkContainer.child SIGSEGVs on access

Open
#292 5 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

I've tried to create a toy program, but it looks like as soon as I try to access a container's child property, it crashes.

$ lua -e 'print(require("lgi").Gtk.Window{}.child)'
Segmentation fault

Here's a gdb backtrace:

#0  0x00007ffff7fb7213 in lgi_object_2lua (L=L@entry=0x5555555872a0, obj=0x5555557b22d0, own=own@entry=0, no_sink=no_sink@entry=0) at object.c:357
#1  0x00007ffff7fb4f27 in lgi_marshal_2lua (L=0x5555555872a0, ti=0x55555569a1e0, ai=0x0, dir=GI_DIRECTION_OUT, transfer=<optimized out>, source=0x5555557a90a0, parent=1, ci=0x5555556854f0, args=0x5555557a9020) at marshal.c:1327
#2  0x00007ffff7fb6042 in lgi_marshal_field (L=0x5555555872a0, object=0x5555557a9020, getmode=1, parent_arg=1, field_arg=<optimized out>, val_arg=3) at marshal.c:1522
#3  0x0000555555560fff in luaD_precall (L=L@entry=0x5555555872a0, func=<optimized out>, func@entry=0x55555577b170, nresults=nresults@entry=-1) at ldo.c:320
#4  0x000055555556b6ef in luaV_execute (L=L@entry=0x5555555872a0, nexeccalls=nexeccalls@entry=1) at lvm.c:612
#5  0x00005555555616e5 in luaD_call (L=L@entry=0x5555555872a0, func=0x55555577b0f0, nResults=nResults@entry=1) at ldo.c:378
#6  0x000055555555e9c5 in lua_call (L=L@entry=0x5555555872a0, nargs=nargs@entry=3, nresults=nresults@entry=1) at lapi.c:782
#7  0x00007ffff7fb6480 in lgi_marshal_access (L=0x5555555872a0, getmode=1, compound_arg=1, element_arg=2, val_arg=3) at marshal.c:1547
#8  0x0000555555560fff in luaD_precall (L=L@entry=0x5555555872a0, func=<optimized out>, func@entry=0x55555577b0b0, nresults=1) at ldo.c:320
#9  0x00005555555616b4 in luaD_call (L=L@entry=0x5555555872a0, func=0x55555577b0b0, nResults=nResults@entry=1) at ldo.c:377
#10 0x0000555555569cf8 in callTMres (L=L@entry=0x5555555872a0, res=res@entry=0x55555577b090, p1=<optimized out>, p2=<optimized out>, f=<optimized out>, f=<optimized out>) at lvm.c:88
#11 0x000055555556a26e in luaV_gettable (L=L@entry=0x5555555872a0, t=<optimized out>, key=<optimized out>, val=val@entry=0x55555577b090) at lvm.c:125
#12 0x000055555556b00f in luaV_execute (L=L@entry=0x5555555872a0, nexeccalls=nexeccalls@entry=1) at lvm.c:441
#13 0x00005555555616e5 in luaD_call (L=0x5555555872a0, func=0x5555555876a0, nResults=<optimized out>) at ldo.c:378
#14 0x000055555556080b in luaD_rawrunprotected (L=L@entry=0x5555555872a0, f=f@entry=0x55555555b8d0 <f_call>, ud=ud@entry=0x7fffffffcfa0) at ldo.c:116
#15 0x0000555555561889 in luaD_pcall (L=L@entry=0x5555555872a0, func=func@entry=0x55555555b8d0 <f_call>, u=u@entry=0x7fffffffcfa0, old_top=64, ef=<optimized out>) at ldo.c:464
#16 0x000055555555ea58 in lua_pcall (L=L@entry=0x5555555872a0, nargs=nargs@entry=0, nresults=nresults@entry=0, errfunc=errfunc@entry=2) at lapi.c:821
#17 0x000055555555a8db in docall (L=L@entry=0x5555555872a0, narg=narg@entry=0, clear=clear@entry=1) at lua.c:102
#18 0x000055555555ad2f in dostring (L=L@entry=0x5555555872a0, s=0x7fffffffd820 "print(require(\"lgi\").Gtk.Window{}.child)", name=name@entry=0x55555557a083 "=(command line)") at lua.c:141
#19 0x000055555555b370 in runargs (n=3, argv=0x7fffffffd408, L=0x5555555872a0) at lua.c:304
#20 pmain (L=0x5555555872a0) at lua.c:359
#21 0x0000555555560fff in luaD_precall (L=L@entry=0x5555555872a0, func=<optimized out>, func@entry=0x555555587670, nresults=0) at ldo.c:320
#22 0x00005555555616b4 in luaD_call (L=0x5555555872a0, func=0x555555587670, nResults=<optimized out>) at ldo.c:377
#23 0x000055555556080b in luaD_rawrunprotected (L=L@entry=0x5555555872a0, f=f@entry=0x55555555b8e0 <f_Ccall>, ud=ud@entry=0x7fffffffd290) at ldo.c:116
#24 0x0000555555561889 in luaD_pcall (L=L@entry=0x5555555872a0, func=func@entry=0x55555555b8e0 <f_Ccall>, u=u@entry=0x7fffffffd290, old_top=16, ef=ef@entry=0) at ldo.c:464
#25 0x000055555555eae7 in lua_cpcall (L=L@entry=0x5555555872a0, func=func@entry=0x55555555b150 <pmain>, ud=ud@entry=0x7fffffffd2c0) at lapi.c:856
#26 0x000055555555a6ea in main (argc=3, argv=0x7fffffffd408) at lua.c:387

In frame 1, tag is GI_TYPE_TAG_INTERFACE yet arg->v_string clearly points to the string lua, so something is not alright here, but I have no idea what's wrong.

Using lgi 0.9.2, lua 5.1.5 (but the same happens with luajit) and gtk 2.24.33.

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 crash with the provided Lua command, then inspect object.c and marshal.c around lgi_object_2lua, lgi_marshal_2lua, lgi_marshal_field, and lgi_marshal_access. Trace why GtkContainer.child reaches an interface conversion with an unexpected string value; done means accessing the property no longer causes a segmentation fault.

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.