Menu

#210 Crash if any "mosaic" magic tool used, Xubuntu 15.10

v0.9.22
closed
nobody
None
1
2018-08-10
2016-03-25
SevenSixTwo
No

Xubuntu 15.10
4.2.0-30-generic #36-Ubuntu SMP Fri Feb 26 00:57:19 UTC 2016 i686 i686 i686 GNU/Linux

Tuxpaint crashes when after using certain options in "magic" menu.
"Hexagon Mosaic", "Irregular Mosaic", and "Square Mosaic"
The following dumped to terminal while in fullscreen mode

Could not open joystick device 0: There are 0 joysticks available
Loading embedded data...
/home/user/.tuxpaint/saved/20160314172410.png
/home/user/.tuxpaint/saved/20160314172410.png
num_unknowns 2
tpLD, 9746
tpLL, 6703
Valid tpLD
Valid tpLL
Original label size 1010x145
Out of label data

Trying in windowed mode gives a different result output for crash:

Could not open joystick device 0: There are 0 joysticks available
Loading embedded data...
/home/user/.tuxpaint/saved/20160325164142.png
/home/user/.tuxpaint/saved/20160325164142.png
num_unknowns 1
tpDT, 56
Valid tpDT
template =
Segmentation fault (core dumped)

Discussion

  • SevenSixTwo

    SevenSixTwo - 2016-03-26

    I did a quick backtrace, although I didn't recompile with debug symbols. Thousands of entries on the stack it seems, with varying addresses. Here's a sample.

    3281 0xacbb4f6b in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3282 0xacbb5055 in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3283 0xacbb4f6b in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3284 0xacbb5055 in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3285 0xacbb4f6b in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3286 0xacbb5055 in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3287 0xacbb4f6b in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3288 0xacbb5055 in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3289 0xacbb4f6b in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3290 0xacbb5055 in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

    3291 0xacbb4f6b in scan_fill () from /usr/lib/tuxpaint/plugins/mosaic_shaped.so

     

    Last edit: SevenSixTwo 2016-03-26
  • Pere Pujal i Carabantes

    Could you download the files mosaic_shaped_hex_pattern.png mosaic_shaped_irregular_pattern.png mosaic_shaped_square_pattern.png
    from http://tuxpaint.cvs.sourceforge.net/viewvc/tuxpaint/tuxpaint/magic/icons/
    and replace the ones xubuntu provides in /usr/share/tuxpaint/images/magic and tell us if the crash is still there?

     
  • lokesh sharma

    lokesh sharma - 2016-08-31

    as disscused on irc . there are two possibilities either writing data to binary file and reading it in mosiac_shaped_switchin function instead of IMG_Load or reading data from
    a header file .
    which approach should i use .

     
  • Pere Pujal i Carabantes

    Thinking a little more, the patterns could be created programattically, so there will not be data around that could be corrupted, for example, the square pattern could be

    if (which == TOOL_SQUARE)
    {
      mosaic_shaped_pattern = SDL_CreateRGBSurface(SDL_SWSURFACE,
                                    16,
                                    16,
                                    canvas->format->BitsPerPixel,
                                    canvas->format->Rmask,
                                    canvas->format->Gmask,
                                    canvas->format->Bmask, amask);
      SDL_FillRect(mosaic_shaped_pattern, NULL, SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE));
      /* Shape */
      for (i = 0;i < mosaic_shaped_pattern->w; i++)
      {
    api->putpixel(mosaic_shaped_pattern, 0, i, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
    api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 1, i, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
    api->putpixel(mosaic_shaped_pattern, i, 0, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
    api->putpixel(mosaic_shaped_pattern, i, mosaic_shaped_pattern->w - 1, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
      }
      /* Shadow */
      for  (i = 1; i < mosaic_shaped_pattern->w - 1; i++)
      {
    api->putpixel(mosaic_shaped_pattern, 1, i, SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
    api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 2, i, SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
    api->putpixel(mosaic_shaped_pattern, i, 1, SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
    api->putpixel(mosaic_shaped_pattern, i, mosaic_shaped_pattern->w - 2, SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
    
      }
    }
    else
    mosaic_shaped_pattern = IMG_Load(fname);
    

    Other patterns will be harder to do, the advantage is that they don't have to be "exactly" as the current ones, being close enough will be fine

     
  • lokesh sharma

    lokesh sharma - 2016-09-13

    i think this better than encoding data in file . I will try to code hexagon pattern .
    irregular would be hardest to code .

     
  • lokesh sharma

    lokesh sharma - 2016-09-15

    this could possible code for hex pattern.

    else if(which == TOOL_HEX)
        {
            mosaic_shaped_pattern = SDL_CreateRGBSurface(SDL_SWSURFACE,
                                    48,
                                    28,
                                    canvas->format->BitsPerPixel,
                                    canvas->format->Rmask,
                                    canvas->format->Gmask,
                                    canvas->format->Bmask, amask);
            SDL_FillRect(mosaic_shaped_pattern, NULL, SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE));
            // Shape 
            float theta = M_PI/3;                          //180 - angle of hexagon
            float side_length = sqrt(7*7 + 14*14);             //each side length of hexagon
            int x_coord = 25 ;
            int y_coord_middle = 14;
            int y_coord_end = 28;
            for(i = 0 ; i<side_length ; i++)
            {
                int x = i*cos(theta);
                int y = (i+1)*sin(theta);
    
                api->putpixel(mosaic_shaped_pattern, x , y_coord_middle+y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, x+1 , y_coord_middle+y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, x+x_coord , y_coord_end-y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, x+x_coord+1 , y_coord_end-y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, x , y_coord_middle-y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, x+1 , y_coord_middle-y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, x+x_coord , y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, x+x_coord+1 , y, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            }
            for (i = 31;i < mosaic_shaped_pattern->w; i++)
            {
                api->putpixel(mosaic_shaped_pattern, i, y_coord_middle, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, i, y_coord_middle+1, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
    
            }
            for (i = 7;i < 26; i++)
            {
                api->putpixel(mosaic_shaped_pattern, i, 0, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
                api->putpixel(mosaic_shaped_pattern, i, 1, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
    
            }
        }
        else 
            mosaic_shaped_pattern = IMG_Load(fname);
    

    I have no clue how to code for irregular . seems too complicated .
    could we store pixel data in header file for irregular pattern .

     
  • Pere Pujal i Carabantes

    Nice :) , you will need to add a small shadow though
    For irregular, I've just figured out the start/end of each line, zooming with gimp into the .png, a tedious work.
    I've begin a callback that paints a point with its shadow, the funny part ;) I am still not fully happy with it but I think irregular will be doable too.

    else if (which == TOOL_IRREGULAR)
    {
      mosaic_shaped_pattern = SDL_CreateRGBSurface(SDL_SWSURFACE,
                                    64,
                                    64,
                                    canvas->format->BitsPerPixel,
                                    canvas->format->Rmask,
                                    canvas->format->Gmask,
                                    canvas->format->Bmask, amask);
      SDL_FillRect(mosaic_shaped_pattern, NULL, SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE));
    
      /* Start/end of lines taken from the original mosaic_shaped_irregular_pattern.png */
      api->line(api, which, mosaic_shaped_pattern, NULL, 0, 8, 36, 23, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 0, 43, 36, 23, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 0, 26, 28, 53, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 0, 54, 10, 63, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 55, 0, 36, 23, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 63, 43, 28, 53, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 24, 63, 28, 53, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 24, 0, 27, 19, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 63, 8, 50, 6, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 4, 10, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 25,7, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 41, 0, 26,12, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 28, 53, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 56, 58, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 63, 53, 55, 45, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 55, 63, 59, 49, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 10, 63, 20, 45, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 63, 26, 40, 18, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 4, 30, 14, 14, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 18, 33, 21, 17, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 23, 48, 29, 27, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 37, 50, 36, 23, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 44, 13, 37, 3, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 59, 24, 55, 7, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 49, 47, 54, 23, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 36, 35, 51, 37, 1, mosaic_shaped_paint);
      api->line(api, which, mosaic_shaped_pattern, NULL, 61, 44, 52, 31, 1, mosaic_shaped_paint);
    
      SDL_BlitSurface(mosaic_shaped_pattern, NULL, canvas, NULL);
    
    }
    
    the callback
    
    /* Paints a 3 pixel square with black and  shadows around 4 more pixels */
    

    static void mosaic_shaped_paint(void * ptr, int which, SDL_Surface * canvas,
    SDL_Surface * last, int x, int y)
    {
    magic_api * api = (magic_api *) ptr;
    int radius, shadow;
    int i, j, ii, jj;
    Uint8 r, g, b, a;
    Uint32 shadow_tone;

    black = SDL_MapRGBA(canvas->format, 0, 0, 0, SDL_ALPHA_OPAQUE);

    / The pixel + 1 around makes 3 pixel square /
    radius = 1;
    shadow = 4;

    for (i = -(radius + shadow); i < (radius + shadow); i++)
    for (j = -(radius + shadow); j < (radius + shadow); j++)
    {
    / Ensure effects on the edges reaches the opposite side if necessary /
    ii = x + i;
    if (ii < 0) ii += canvas->w;
    if (ii >= canvas->w) ii -= canvas->w;
    jj = y + j;
    if (jj < 0) jj += canvas->h;
    if (jj >= canvas->h) ii -= canvas->h;

      /* Shadow_tone is also used as a marker, anything already painted on black must finally be black */
      shadow_tone = api->getpixel(canvas, ii, jj);
    
      if (abs(i) <= radius && abs(j) <= radius)
    api->putpixel(canvas, ii, jj, black);
    
      else if (api->in_circle(i, j, radius + shadow) && shadow_tone != black)
      {
    SDL_GetRGBA(shadow_tone, canvas->format, &r, &g, &b, &a);
    
    /* Shadows should be shadows, not black */
    if (r > 10) r -= 9;
    if (g > 10) g -= 9;
    if (b > 10) b -= 9;
    
        api->putpixel(canvas, ii, jj, SDL_MapRGBA(canvas->format, r, g, b, SDL_ALPHA_OPAQUE));
    
      }
    
    }
    

    }

     
  • lokesh sharma

    lokesh sharma - 2016-09-16

    hex with shadows
    I have changed previous code .
    I have used the method that you used in irregular pattern

    else if(which == TOOL_HEX)
        {
            mosaic_shaped_pattern = SDL_CreateRGBSurface(SDL_SWSURFACE,
                                    48,
                                    28,
                                    canvas->format->BitsPerPixel,
                                    canvas->format->Rmask,
                                    canvas->format->Gmask,
                                    canvas->format->Bmask, amask);
            SDL_FillRect(mosaic_shaped_pattern, NULL, SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE));
    
            api->line(api, which, mosaic_shaped_pattern, NULL, 0, 16, 8, 1, 1, mosaic_shaped_paint);
            api->line(api, which, mosaic_shaped_pattern, NULL, 8, 1, 26, 1, 1, mosaic_shaped_paint);
            api->line(api, which, mosaic_shaped_pattern, NULL, 26, 1, 32, 14, 1, mosaic_shaped_paint);
            api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 26, 27, 1, mosaic_shaped_paint);
            api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 47, 14, 1, mosaic_shaped_paint);
            api->line(api, which, mosaic_shaped_pattern, NULL, 0,13 ,8, 27, 1, mosaic_shaped_paint);
    
            //make pattern more accurate
            api->putpixel(mosaic_shaped_pattern, 9 , 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 9 , 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 25 , 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 25 , 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 25 , 25, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 24 , 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
    
        }
    
     
  • lokesh sharma

    lokesh sharma - 2016-09-18

    is this bug resolved or something else needs to be added .

     
  • Pere Pujal i Carabantes

    I think it is solved, I am commiting to cvs and git right now, maybe it will need some tweaks to fit in the sdl2 branch though

     
  • lokesh sharma

    lokesh sharma - 2016-09-24

    I had a look at generated patterns . there is a problem in hexagon pattern . A vertical line
    appears at bottom right corner of hexagon . (screenshot attached)
    It was fine when I complied it on my PC . then I looked at the commit you made
    you changed the code of mosaic_shaped_paint function a bit .
    In above code
    shadows= 4;
    In commit
    shadows = 3

    As a result code for hex pattern need some tweaks in few lines.
    from line 534 to line 537 , x coordinate needs to be incremented by 1 .here is corrected code.

    //make pattern more accurate
            api->putpixel(mosaic_shaped_pattern, 9 , 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 9 , 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 26 , 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 26 , 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 26 , 25, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
            api->putpixel(mosaic_shaped_pattern, 25 , 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
    
     
  • Pere Pujal i Carabantes

    LOL, I reviewed hexagon at least a dozen of times and didn't saw the problem.
    I need to wear glasses XD
    Just committed your corrections, Thanks :)

     
  • William Kendrick

    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.