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)
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
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?
After a talk with SevenSixTwo on IRC, seems that the problem were the .PNGs files, they are copied around on a auxiliar surface and contains the patterns that prevents the search/fill algorithm to escape from bounds. If the program used to compress those .PNGs modifies the patterns the wrong (lossy) way, then Tux Paint will crash.
I guess the real solution would be to provide data files with the patterns so Tux Paint is not affected when somebody else compresses the .PNGs to save space.
For now, the fix is just downloading the 3 .PNGs and replacing the ones Xubuntu provides, here are the 3 links
http://tuxpaint.cvs.sourceforge.net/viewvc/tuxpaint/tuxpaint/magic/icons/mosaic_shaped_hex_pattern.png?revision=1.5
http://tuxpaint.cvs.sourceforge.net/viewvc/tuxpaint/tuxpaint/magic/icons/mosaic_shaped_irregular_pattern.png?revision=1.5
http://tuxpaint.cvs.sourceforge.net/viewvc/tuxpaint/tuxpaint/magic/icons/mosaic_shaped_square_pattern.png?revision=1.5
They should go to /usr/share/tuxpaint/images/magic/
Hope this helps
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 .
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
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
i think this better than encoding data in file . I will try to code hexagon pattern .
irregular would be hardest to code .
this could possible code for hex pattern.
I have no clue how to code for irregular . seems too complicated .
could we store pixel data in header file for irregular pattern .
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.
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;
}
hex with shadows
I have changed previous code .
I have used the method that you used in irregular pattern
is this bug resolved or something else needs to be added .
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
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.
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 :)
Mended in https://sourceforge.net/p/tuxpaint/tuxpaint/ci/8facc8a4bc533cab9865611785885bc6c4290936/