| [ Return to Bugs & Features | SVN ⇄ GIT ]
STR #3401
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 4 - High, e.g. key functionality not working |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Image Support |
Summary: | pixmap_browser crashes on invalid xpm images |
Version: | 1.4.0 |
Created By: | chris |
Assigned To: | manolo |
Fix Version: | 1.4.0 (SVN: v12806) |
Update Notification: | |
Trouble Report Files:
Trouble Report Comments:
|
#1 | chris 08:06 Sep 10, 2017 |
| Just filling a STR, as I have no time now to investigate further. Observed with latest SVN under Ubuntu (14.04 and 17.04): test/pixmap_browser crashes when selecting pixmaps/porsche1.xpm, which is an invalid image. Under 1.3 (and older versions of 1.4 - presumably before the scaling patch - this shows a big 'X' in the fileselector and nothing in the main window). Backtrace below. Also I observe, that xpm files are shown scaled to the canvas size in the main window, unlike as it was in 1.3. Is this intentional or a regression?
Thread 1 "pixmap_browser" received signal SIGSEGV, Segmentation fault. 0x0806c329 in Fl_Pixmap::copy (this=0x81e4790, W=380, H=380) at Fl_Pixmap.cxx:181 181 sscanf(data()[0],"%*d%*d%d%d", &ncolors, &chars_per_pixel); (gdb) br Haltepunkt 1 at 0x806c329: file Fl_Pixmap.cxx, line 181. (gdb) bt #0 0x0806c329 in Fl_Pixmap::copy(int, int) (this=0x81e4790, W=380, H=380) at Fl_Pixmap.cxx:181 #1 0x08064a8b in Fl_Graphics_Driver::draw(Fl_Shared_Image*, int, int) (this=0x8142b50, shared=0x81b0858, X=10, Y=45) at Fl_Graphics_Driver.cxx:207 #2 0x08065f5b in Fl_Scalable_Graphics_Driver::draw(Fl_Shared_Image*, int, int) (this=0x8142b50, shared=0x81b0858, X=10, Y=45) at Fl_Graphics_Driver.cxx:389 #3 0x08073592 in Fl_Shared_Image::draw(int, int, int, int, int, int) (this=0x81b0858, X=10, Y=45, W=380, H=380, cx=0, cy=0) at Fl_Shared_Image.cxx:371 #4 0x0807a213 in Fl_Image::draw(int, int) (this=0x81b0858, X=10, Y=45) at ../FL/Fl_Image.H:183 #5 0x0807c27c in fl_draw(char const*, int, int, int, int, unsigned int, void (*)(char const*, int, int, int), Fl_Image*, int) (str=0x0, x=11, y=46, w=378, h=378, align=80, callthis= 0x807b867 <fl_draw(char const*, int, int, int)>, img=0x81b0858, draw_symbols=1) at fl_draw.cxx:225 #6 0x0807cbb5 in fl_draw(char const*, int, int, int, int, unsigned int, Fl_Image*, int) (str=0x0, x=11, y=46, w=378, h=378, align=80, img=0x81b0858, draw_symbols=1) at fl_draw.cxx:336 #7 0x0807fdec in fl_normal_label(Fl_Label const*, int, int, int, int, unsigned int) (o=0xbfffe3ac, X=11, Y=46, W=378, H=378, align=80) at fl_labeltype.cxx:37 #8 0x0807ff25 in Fl_Label::draw(int, int, int, int, unsigned int) const (this=0xbfffe3ac, X=11, Y=46, W=378, H=378, align=80) at fl_labeltype.cxx:87 #9 0x080801a8 in Fl_Widget::draw_label(int, int, int, int, unsigned int) const (this=0xbfffee40, X=11, Y=46, W=378, H=378, a=80) at fl_labeltype.cxx:133 #10 0x080800e4 in Fl_Widget::draw_label(int, int, int, int) const (this=0xbfffee40, X=11, Y=46, W=378, H=378) at fl_labeltype.cxx:120 #11 0x08080072 in Fl_Widget::draw_label() const (this=0xbfffee40) at fl_labeltype.cxx:111 #12 0x08062d1f in Fl_Box::draw() (this=0xbfffee40) at Fl_Box.cxx:36 #13 0x080690d7 in Fl_Group::update_child(Fl_Widget&) const (this=0xbfffef4c, widget=...) at Fl_Group.cxx:814 #14 0x08068fa3 in Fl_Group::draw_children() (this=0xbfffef4c) at Fl_Group.cxx:789 #15 0x080766c7 in Fl_Window::draw() (this=0xbfffef4c) at Fl_Window.cxx:507 #16 0x08076e51 in Fl_Window_Driver::draw() (this=0x81432b0) at Fl_Window_Driver.cxx:65 #17 0x0808a0fe in Fl_X11_Window_Driver::flush_double_dbe(int) (this=0x81432b0, erase_overlay=0) at drivers/X11/Fl_X11_Window_Driver.cxx:98 #18 0x0808a72d in Fl_X11_Window_Driver::flush_double() (this=0x81432b0) at drivers/X11/Fl_X11_Window_Driver.cxx:219 #19 0x08063d10 in Fl_Double_Window::flush() (this=0xbfffef4c) at Fl_Double_Window.cxx:74 #20 0x08077279 in Fl_Window_Driver::flush() (this=0x81432b0) at Fl_Window_Driver.cxx:231 #21 0x080606e7 in Fl::flush() () at Fl.cxx:675 #22 0x0808ce1f in Fl_X11_Screen_Driver::wait(double) (this=0x81432f8, time_to_wait=0.99924099999999982) at drivers/X11/Fl_X11_Screen_Driver.cxx:487 #23 0x08060413 in Fl::wait(double) (time_to_wait=1e+20) at Fl.cxx:501 #24 0x08060475 in Fl::wait() () at Fl.cxx:544 #25 0x0807d87e in popup(Fl_File_Chooser*) (fc=0x81ad3f8) at fl_file_dir.cxx:45 #26 0x0807db6b in fl_file_chooser(char const*, char const*, char const*, int) (message=0x80fcb63 "Image file?", pat=0x80fcb34 "*.{bm,bmp,gif,jpg,pbm,pgm,png,ppm,xbm,xpm,svg}", fname=0x8138d60 <n---Type <return> to continue, or q <return> to quit--- ame> "/home/chris/Dokumente/programming/fltk-1.4/test/pixmaps/porsche1.xpm", relative=0) at fl_file_dir.cxx:149 #27 0x0804cf69 in button_cb(Fl_Widget*, void*) () at pixmap_browser.cxx:83 #28 0x08075303 in Fl_Widget::do_callback(Fl_Widget*, void*) (this=0xbfffee94, widget=0xbfffee94, arg=0x0) at Fl_Widget.cxx:329 #29 0x0805fe77 in Fl_Widget::do_callback() (this=0xbfffee94) at ../FL/Fl_Widget.H:871 #30 0x080634a0 in Fl_Button::handle(int) (this=0xbfffee94, event=2) at Fl_Button.cxx:125 #31 0x0806100b in send_event(int, Fl_Widget*, Fl_Window*) (event=2, to=0xbfffee94, window=0xbfffef4c) at Fl.cxx:1075 #32 0x08061394 in Fl::handle_(int, Fl_Window*) (e=2, window=0xbfffef4c) at Fl.cxx:1258 #33 0x08061078 in Fl::handle(int, Fl_Window*) (e=2, window=0xbfffef4c) at Fl.cxx:1155 #34 0x08098938 in fl_handle(_XEvent const&) (thisevent=...) at Fl_x.cxx:2104 #35 0x08093b48 in do_queued_events() () at Fl_x.cxx:214 #36 0x08094095 in fd_callback(int, void*) () at Fl_x.cxx:379 #37 0x08093eef in Fl_X11_Screen_Driver::poll_or_select_with_delay(double) (this=0x81432f8, time_to_wait=1e+20) at Fl_x.cxx:280 #38 0x0808ce49 in Fl_X11_Screen_Driver::wait(double) (this=0x81432f8, time_to_wait=1e+20) at drivers/X11/Fl_X11_Screen_Driver.cxx:490 #39 0x08060413 in Fl::wait(double) (time_to_wait=1e+20) at Fl.cxx:501 #40 0x0806043c in Fl::run() () at Fl.cxx:514 #41 0x0804d322 in main(int, char**) (argc=1, argv=0xbffff0c4) at pixmap_browser.cxx:128 | |
|
#2 | chris 08:09 Sep 10, 2017 |
| Correction: Its .xbm files that show scaled now, not .xpm! | |
|
#3 | chris 08:52 Sep 11, 2017 |
| Had a look at it now. There seem to be several issues here.
Lets start with why XBM images get drawn scaled to the box size in the pixmap_browser main window. There is a
img->scale(b->w(), b->h())
call at line 65. So this one is scaling XBM's? But why not all other image types?
The answer is, that it scales XBM's because there is a bug in Fl_Image::fail(), which gets called in Fl_Shared_Image::scale(): It return failure for XBM's because of the d_<=0 comparison. XBM's have d=0, so this is no failure.
After fixing Fl_Image::fail(), *no* images get scaled in the pixmap_browser.
Thats because Fl_Shared_Image::scale() has two more parameters 'proportional' (default 1) and 'can_expand' (default 0).
So the call in pixmap_browser line 65 perhaps should be img->scale(b->w(), b->h(), 1, 1) ?
The crash with porsche1.xpm occurs, because there is no check for a fail()'ed image when trying to draw the image.
Please take a look at my changes in trying to fix all of these. Take it as 'prototype' only to get started and please double check it (because I didn't ;) | |
|
#4 | chris 09:10 Sep 11, 2017 |
| I already seen an unwanted effect, namely that the preview in the fileselector also gets scales now.. As said, take is as prototype... | |
|
#5 | manolo 08:33 Mar 27, 2018 |
| Fixed in Subversion repository.
FLTK no longer crashes when attempting to draw invalid xpm images | |
[ Return to Bugs & Features ]
|
| |