libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.38k stars 1.84k forks source link

libcaca segmentation fault #4367

Closed natinusala closed 5 years ago

natinusala commented 7 years ago

I wanted to try the libcaca GFX driver but it segfaults when launching RA :

Thread 1 "retroarch" received signal SIGSEGV, Segmentation fault.
0x00007ffff5800513 in ?? () from /usr/lib/x86_64-linux-gnu/libcaca.so.0
(gdb) bt full
#0  0x00007ffff5800513 in ?? () from /usr/lib/x86_64-linux-gnu/libcaca.so.0
No symbol table info available.
#1  0x00007ffff5801648 in cucul_dither_bitmap ()
   from /usr/lib/x86_64-linux-gnu/libcaca.so.0
No symbol table info available.
#2  0x00000000004e7a5b in caca_gfx_frame (data=<optimized out>, 
    frame=<optimized out>, frame_width=4, frame_height=4, 
    frame_count=<optimized out>, pitch=<optimized out>, 
    msg=0x860020 <video_driver_msg> "") at gfx/drivers/caca_gfx.c:153
        len = 0
        buffer = 0x0
        frame_to_copy = 0xb1f370
        width = 80
        height = 32
        draw = true
#3  0x000000000043aa91 in video_driver_frame (data=0x8601a0 <dummy_pixels>, 
    width=4, height=4, pitch=8) at gfx/video_driver.c:2110
        video_driver_msg = '\000' <se r\377\377\377\377\377\377\377\377p\377\377\377\377\377\377\377\377te 255 fois>
        video_frame_conv = {ident = 0x55b03b "video_frame_conv", start = 0, 
          total = 0, call_cnt = 0, registered = false}
        output_width = 0
        output_height = 0
        output_pitch = <optimized out>
        msg = 0x0
        settings = 0x7fffee195010
#4  0x0000000000438988 in video_driver_cached_frame ()
    at gfx/video_driver.c:1170
        info = {data = 0x8601a0 <dummy_pixels>, width = 4, height = 4, 
          pitch = 8}
        recording = 0x0
#5  0x00000000004bbbe6 in menu_display_libretro () at menu/menu_display.c:323
No locals.
#6  0x000000000048d5c4 in menu_driver_ctl (
    state=state@entry=RARCH_MENU_CTL_RENDER, data=data@entry=0x0)
    at menu/menu_driver.c:484
No locals.
#7  0x0000000000421bbd in runloop_check_state (
    settings=settings@entry=0x7fffee195010, 
    current_input=current_input@entry=0, old_input=old_input@entry=0, 
    trigger_input=0, sleep_ms=0x7fffffffddbc) at runloop.c:824
        action = MENU_ACTION_NOOP
        focused = true
        iter = {action = MENU_ACTION_NOOP, pointer = {x = 29, y = 0, 
            touch = 8}, mouse = {x = 0, y = 0, buttons = {left = false, 
              right = false}, wheel = {up = 13, down = false}}}
        tmp = false
        focused = true
        pause_pressed = false
        old_focus = true
        prev_overlay_restore = 0 '\000'
#8  0x00000000004223d4 in runloop_iterate (
    sleep_ms=sleep_ms@entry=0x7fffffffddbc) at runloop.c:1128
        i = <optimized out>
        current = <optimized out>
        target = <optimized out>
        to_sleep_ms = <optimized out>
        trigger_input = 0
        last_input = 0
        settings = 0x7fffee195010
        old_input = 0
        current_input = 0
#9  0x00000000004114da in rarch_main (argc=1, argv=<optimized out>, data=0x0)
    at frontend/frontend.c:130
        sleep_ms = 0
        ret = <optimized out>
        argc = 1
        argv = <optimized out>
        data = 0x0
        args = 0x0
#10 0x00007ffff466d830 in __libc_start_main (main=0x40e940 <main>, argc=1, 
    argv=0x7fffffffdee8, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffded8)
    at ../csu/libc-start.c:291
        result = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, 6876404660134354028, 
                4254032, 140737488346848, 0, 0, -6876404264753292180, 
                -6876418343434838932}, mask_was_saved = 0}}, priv = {pad = {
              0x0, 0x0, 0x52daa0 <__libc_csu_fini>, 
              0x7ffff7de78e0 <_dl_fini>}, data = {prev = 0x0, cleanup = 0x0, 
              canceltype = 5429920}}}
        not_first_call = <optimized out>
#11 0x000000000040e979 in _start ()

The main issue seems to be in the libcaca call at gfx/drivers/caca_gfx.c:153 from gfx/video_driver.c:2110.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/40649105-libcaca-segmentation-fault?utm_campaign=plugin&utm_content=tracker%2F296058&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F296058&utm_medium=issues&utm_source=github).
natinusala commented 7 years ago

Looks like the menu (rgui) is causing the crash : when launching RA without any option it crashes, but when launching RA with a core and a game (using retroarch -L core game) it works well, although inputs are not working. My eyes are bleeding too.

hizzlekizzle commented 7 years ago

I think it works with the XMB menu, oddly enough.

ghost commented 7 years ago

Yes it was only made to work with the XMB menu driver so far. The environment variables here http://caca.zoy.org/doxygen/libcaca/libcaca-env.html can also control the video driver.

natinusala commented 7 years ago

Okay, I see. I tested with XMB and the render is weird, the texts are not dithered and I don't see any icon nor any background. Having some inputs would probably help

ghost commented 7 years ago

Yes I have not yet implemented any menu graphics, and the text is rendered without dithering on purpose to make it easier to read. It is possible to simply take the existing XMB frames and dither them, but that adds the requirement of OpenGL/D3D/Vulkan to draw the initial frame first, and one goal I had with libcaca was to make it work without any hardware acceleration (think non-KMS Linux console or an old PC). However it would be possible to add a separate "glcaca" driver later that simply dithered the full XMB rendering.

natinusala commented 7 years ago

Okay, I see. And what about the inputs ? Are they not implemented yet ?

orbea commented 5 years ago

@natinusala What's the current status on this?

natinusala commented 5 years ago

It opens "caca for X" on a black screen and nothing happens after that (rgui menu driver).

orbea commented 5 years ago

I can reproduce that, loading directly to content seems to work though. Same issue with sixel, except I can toggle the menu with sixel after loading content.

natinusala commented 5 years ago

I think that it's just the current state of the caca driver, and no longer a bug. This issue doesn't have any reason to exist anymore, unless you want to keep track of that

orbea commented 5 years ago

I agree, I'll close it and consider making new issues for the remaining problems later. Thanks for the quick replies!