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

Segmentation fault when drawing on canvas created with chafa_canvas_new_similar #123

Closed
GuardKenzie opened this issue Jan 3, 2023 · 4 comments

Comments

@GuardKenzie
Copy link
Contributor

GuardKenzie commented Jan 3, 2023

What am I doing?

When trying to draw using chafa_canvas_draw_all_pixels to a canvas created with chafa_canvas_new_similar I get a segmentation fault.

I might be doing something wrong since I don't have a lot of experience with C but I have provided a minimum working example that demonstrates the issue.

Some things to note:

  • I get no segmentation fault if I change the pixel mode to kitty.
  • The issue persists whether using symbol tags CHAFA_SYMBOL_TAG_HALF or CHAFA_SYMBOL_TAG_ALL.
  • There is no segmentation fault when drawing to the original canvas.
  • The issue persists if I create a proper canvas config and initiate the canvas with that.

To reproduce

  1. Create a ChafaCanvas canvas using chafa_canvas_new
  2. Create another ChafaCanvas using chafa_canvas_new_similar(canvas)
  3. Draw to the second canvas using chafa_canvas_draw_all_pixels

Minimum working example

#include <chafa.h>

#define PIX_WIDTH  3
#define PIX_HEIGHT 3
#define N_CHANNELS 4

int
main (int argc, char *argv [])
{
    const guint8 pixels [PIX_WIDTH * PIX_HEIGHT * N_CHANNELS] =
    {
        0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
        0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
        0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff
    };

    ChafaCanvas *canvas, *canvas2;

    canvas  = chafa_canvas_new(NULL);
    canvas2 = chafa_canvas_new_similar(canvas);

    chafa_canvas_draw_all_pixels (canvas2,
                                  CHAFA_PIXEL_RGBA8_UNASSOCIATED,
                                  pixels,
                                  PIX_WIDTH,
                                  PIX_HEIGHT,
                                  PIX_WIDTH * N_CHANNELS);

    return 0;
}

Backtrace

(gdb) bt full
#0  0x00007ffff7f6a560 in ?? () from /usr/lib/libchafa.so.0
No symbol table info available.
#1  0x00007ffff7f51b2e in ?? () from /usr/lib/libchafa.so.0
No symbol table info available.
#2  0x00007ffff7f52015 in ?? () from /usr/lib/libchafa.so.0
No symbol table info available.
#3  0x00007ffff7f53130 in ?? () from /usr/lib/libchafa.so.0
No symbol table info available.
#4  0x00007ffff7e87673 in g_thread_pool_thread_proxy (data=<optimized out>)
    at ../glib/glib/gthreadpool.c:352
        task = 0x5555555a6f70
        pool = 0x55555559cfa0
#5  0x00007ffff7e81e05 in g_thread_proxy (data=0x55555555ab00)
    at ../glib/glib/gthread.c:831
        thread = 0x55555555ab00
        __func__ = "g_thread_proxy"
#6  0x00007ffff7c9e8fd in start_thread (arg=<optimized out>)
    at pthread_create.c:442
        ret = <optimized out>
        pd = <optimized out>
        out = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140737297594048, 
                -8044589460357361681, -128, 11, 140737488345696, 
                140737289203712, 8044565556210978799, 8044571403542220783}, 
              mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#7  0x00007ffff7d20a60 in clone3 ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
No locals.

System info

os: arch linux
kernel: 5.15.85-1-lts
chafa version: 1.12.4

@hpjansson
Copy link
Owner

Thanks for reporting this! The fix will be in the next tarball release, hopefully later this month.

@GuardKenzie
Copy link
Contributor Author

Awesome! Thank you!

hpjansson added a commit that referenced this issue May 21, 2023
@hpjansson
Copy link
Owner

1.14 is taking longer than expected, so I made 1.12.5 as a bugfix release in the meantime. Sorry for the delay!

@GuardKenzie
Copy link
Contributor Author

Hey no worries! Thanks for the release! 🧡

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

2 participants