Skip to content

Custom destructors don't kill proxies #170

@nbuwe

Description

@nbuwe

CC_delete macro in vm/src/any/prims/glueDefs.hh passes bx hook of

  if (s_arg_receiver->is_proxy())
      proxyOop(s_arg_receiver)->kill();

so a proxy object is killed by delete. E.g. for the primitive template

  XVisualInfo delete = void delete

you get:

owner@[Unknown hostName] 1> xlib xVisualInfo new delete
a xlib xVisualInfo(dead)
owner@[Unknown hostName] 2> xlib xVisualInfo new delete delete
To debug in ui2, type:      selfProcessModel debugProcess: 0 as
to debug in console, type:  attach: 0
to dump stack, type:        0 as printError.
[Sun Dec 28 01:44:10 2025] error -- Error: delete failed: deadProxyError: s_arg_receiver, (XVisualInfo*,XVisualInfo_seal). Receiver is: a xlib xVisualInfo.

but if a custom delete wrapper is used, there seems to be no way to arrange for that, and the proxy stays alive. So for XSizeHints that has:

  void new = XSizeHints {xlib xSizeHints deadCopy} call XAllocSizeHints
  XSizeHints delete = void call XFree_XSizeHints_wrap canAWS

the call to delete leaves the proxy alive but holding a dangling pointer:

owner@[Unknown hostName] 3> xlib xSizeHints new delete
a xlib xSizeHints(live)
owner@[Unknown hostName] 4> xlib xSizeHints new delete delete
free(): double free detected in tcache 2

Program received signal SIGABRT, Aborted.
0xf7fc4579 in __kernel_vsyscall ()
(gdb) bt
#0  0xf7fc4579 in __kernel_vsyscall ()
#1  0xf7897aa7 in ?? () from /lib/i386-linux-gnu/libc.so.6
#2  0xf7846685 in raise () from /lib/i386-linux-gnu/libc.so.6
#3  0xf782f3ac in abort () from /lib/i386-linux-gnu/libc.so.6
#4  0xf788a3fc in ?? () from /lib/i386-linux-gnu/libc.so.6
#5  0xf78a342f in ?? () from /lib/i386-linux-gnu/libc.so.6
#6  0xf78a577c in ?? () from /lib/i386-linux-gnu/libc.so.6
#7  0xf78a7c27 in free () from /lib/i386-linux-gnu/libc.so.6
#8  0xf7e8f82c in XFree () from /lib/i386-linux-gnu/libX11.so.6
#9  0x082b7b12 in XFree_XSizeHints_wrap (p=0x8ce0dd0)
    at /home/uwe/work/self/self/objects/glue/xlib_glue.cpp:562
#10 0x082aa803 in XFree_XSizeHints_wrap_Delete_glue (s_arg_0=0x410ad99)
    at /home/uwe/work/self/self/objects/glue/xlib_glue.cpp:852
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions