Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory error during "new Gtk.RGBA" #290

Open
ghost opened this issue Apr 30, 2021 · 4 comments
Open

Memory error during "new Gtk.RGBA" #290

ghost opened this issue Apr 30, 2021 · 4 comments

Comments

@ghost
Copy link

ghost commented Apr 30, 2021

When I run the code below, I get an error about 70000 iterations.

const GNode = require('node-gtk')
const Gdk = GNode.require('Gdk', '3.0')

let i = 0;
for(let i = 0; ; i++) {
    console.log(i)
    new Gdk.RGBA({red: 255/255, green: 235/255, blue: 51/255, alpha: 1})
}

Output 1:
....
76352
76353
76354
76355
76356
76357
Segmentation fault
$

Output 2:
....
71441
71442
71443
71444
71445
71446
71447
71448

MEMORY-ERROR: [16117]: GSlice: assertion failed: sinfo->n_allocated > 0
Aborted
$

@romgrk
Copy link
Owner

romgrk commented Apr 30, 2021

Thanks for the report, I had already seen a few of these errors but wasn't sure where they were coming from. I'll investigate what's going on.

@ghost
Copy link
Author

ghost commented May 4, 2021

https://github.com/romgrk/node-gtk/issues/213

The error does not occur as a result of trying "G_SLICE=always-malloc", the solution in the above article.

@romgrk
Copy link
Owner

romgrk commented May 4, 2021

Got it. We can probably skip the issue by using malloc directly rather than g_slice_alloc.

@romgrk
Copy link
Owner

romgrk commented May 12, 2021

Update on this, it seems that we had already migrated away from g_slice_alloc to malloc.

void *boxedCopy = malloc(size);

This is bad news because it means the bug is upstream. After some debugging, it appears that GLib's slice allocator is choking at various points in this method, usually when handling the SlabInfo struct:

https://github.com/GNOME/glib/blob/c0b339372cf3cf29cc8fee212a2debc41ea93cd2/glib/gslice.c#L1386

Here is one place where it aborts:

https://github.com/GNOME/glib/blob/c0b339372cf3cf29cc8fee212a2debc41ea93cd2/glib/gslice.c#L1398

I'll see if I can get some feedback from GLib or I'll open an issue with them soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant