#4 √ resolved
John Croisant

Segfault on x86_64 in extract_rgba_u8_as_u8()

Reported by John Croisant | June 18th, 2008 @ 01:08 AM | in Surface & Rect

Reported by: Elio Cuevas Gomez - elcugo

-----

Using drawing funcions in Rubygame causes a crash (SIGSEGV) on Linux x86_64 when using drawing funcions. I provide a backtrace for Surface.fill():

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x2aff68cb9b00 (LWP 30444)]
0x00002aff67fc18a5 in rb_ary_entry () from /usr/lib64/libruby18.so.1.8
(gdb) bt
#0 0x00002aff67fc18a5 in rb_ary_entry () from /usr/lib64/libruby18.so.1.8
#1 0x00002aff6b5dc24e in extract_rgba_u8_as_u8 (color=1834185448,
r=0x7fff42d1b317 "", g=0x7fff42d1b316 "", b=0x7fff42d1b315 "",
a=0x7fff42d1b314 "") at ext/rubygame/rubygame_shared.c:160
#2 0x00002aff6b5e0fec in rbgm_surface_fill (argc=1, argv=0x7fff42d1b600,
self=47276539213000) at ext/rubygame/rubygame_surface.c:510

I tested it on 2.1.0 and the crash doesn't occur. The crash seem to have been introduced on 2.2.0 and it's still present on 2.3.0.

Comments and changes to this ticket

  • John Croisant

    John Croisant June 18th, 2008 @ 01:30 AM

    • no changes were found...
  • James Jeffers

    James Jeffers July 9th, 2008 @ 04:40 PM

    • → Tag changed from “” to “!highpriority @bug color segfault”

    John, do you have a sample program that will reproduce this problem?

  • James Jeffers

    James Jeffers July 9th, 2008 @ 08:18 PM

    I'm looking at the differences between 2.1.0 and 2.2.0.

    I see that there were changes made to the ext/rubygame/rubygame_surface.c file, like this:

    @@ -508,20 +506,9 @@ VALUE rbgm_surface_fill( int argc, VALUE *argv, VALUE self )

    ...

    • vcolor = convert_to_array(vcolor);

    ...

    • vcolor = convert_color(vcolor);
    • extract_rgba_u8_as_u8(vcolor, &r, &g, &b, &a);

    It looks as if the conversion to an array is failing, because the next call at line 160

    (gdb) frame 1

    #1 0x00002b891810c243 in extract_rgba_u8_as_u8 (color=420100720, r=0x7fff9576d9f7 "", g=0x7fff9576d9f6 "",

    b=0x7fff9576d9f5 "", a=0x7fff9576d9f4 "") at ext/rubygame/rubygame_shared.c:160

    160 *r = NUM2UINT(rb_ary_entry(color, 0));

    (gdb) l

    155 *b = NUM2UINT(rb_ary_entry(color, 2));

    156 }

    157

    158 void extract_rgba_u8_as_u8(VALUE color, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)

    159 {

    160 *r = NUM2UINT(rb_ary_entry(color, 0));

    that extracts the element from the array (at index 0) causes the segmentation error.

    Of course, I'm fairly inexperienced with rubygame, so this may not be acurate.

  • James Jeffers

    James Jeffers July 9th, 2008 @ 08:18 PM

    Wow! That formatting was terrible.

  • James Jeffers

    James Jeffers July 9th, 2008 @ 08:20 PM

    ...and needless to say, simply running one of the demos exposes this bug.

  • ElCuGo

    ElCuGo July 25th, 2008 @ 01:02 AM

    Hi! Just for the Rubygame contest I fixed this bug. See atached patch.

  • James Jeffers

    James Jeffers July 25th, 2008 @ 08:16 AM

    ElCuGo, you beat me to it. I'm new to Lighthouse - where would I find the attachement?

  • ElCuGo

    ElCuGo July 25th, 2008 @ 11:43 AM

    Hi James. Look at the right column, above "PEOPLE WATCHING THIS TICKET". The file is bug4.patch.

  • John Croisant

    John Croisant July 31st, 2008 @ 09:41 PM

    • → State changed from “new” to “resolved”

    The patch has been applied and is now in the master branch. It will ship with Rubygame 2.4. Thanks for the report and the patch, ElCuGo!

  • James Jeffers

    James Jeffers May 2nd, 2009 @ 05:14 PM

    I've tested the "chimp.rb", and others, and I still experience this bug. rubygame 2.5.0 ruby: 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]

    
    ******
    CONVERT_COLOR
    RESPONDS TO TO_ARY
    
    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x7f0a482756e0 (LWP 14359)]
    0x00007f0a47d92435 in rb_ary_entry () from /usr/lib/libruby1.8.so.1.8
    (gdb) bt
    #0  0x00007f0a47d92435 in rb_ary_entry () from /usr/lib/libruby1.8.so.1.8
    #1  0x00007f0a45128293 in extract_rgba_u8_as_u8 (color=1162454688, r=0x7fff50297877 "", g=0x7fff50297876 "", b=0x7fff50297875 "", a=0x7fff50297874 "")
        at ext/rubygame/rubygame_shared.c:167
    #2  0x00007f0a4512d113 in rbgm_surface_fill (argc=1, argv=0x7fff50297e50, self=139682088855240) at ext/rubygame/rubygame_surface.c:510
    #3  0x00007f0a47db6c40 in ?? () from /usr/lib/libruby1.8.so.1.8
    #4  0x00007f0a47db6dfa in ?? () from /usr/lib/libruby1.8.so.1.8
    #5  0x00007f0a47db0cf0 in ?? () from /usr/lib/libruby1.8.so.1.8
    #6  0x00007f0a47db3fce in ?? () from /usr/lib/libruby1.8.so.1.8
    #7  0x00007f0a47db6b43 in ?? () from /usr/lib/libruby1.8.so.1.8
    #8  0x00007f0a47db6dfa in ?? () from /usr/lib/libruby1.8.so.1.8
    #9  0x00007f0a47db0e22 in ?? () from /usr/lib/libruby1.8.so.1.8
    #10 0x00007f0a47dc3dbb in ?? () from /usr/lib/libruby1.8.so.1.8
    #11 0x00007f0a47dc3e05 in ruby_exec () from /usr/lib/libruby1.8.so.1.8
    #12 0x00007f0a47dc3e32 in ruby_run () from /usr/lib/libruby1.8.so.1.8
    #13 0x00000000004008e3 in main ()
    *****
    
  • James Jeffers

    James Jeffers May 2nd, 2009 @ 05:14 PM

    (I've got to learn how to format this tickets better.)

  • James Jeffers

    James Jeffers May 3rd, 2009 @ 03:25 PM

    As it turns out my gem installation was not up to date. It's working find, so please disregard.

  • John Croisant

    John Croisant May 3rd, 2009 @ 04:39 PM

    Glad to hear that, James. I was quite puzzled as to why it would still be causing problems.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Flexible library for making games with the Ruby language.

rubygame.sourceforge.net

Shared Ticket Bins

People watching this ticket

Attachments

You can update this ticket by sending an email to from your email client. (help)