Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 186851 - media-libs/netpbm-10.39.0 bmptopnm floating point exception when used on certain bmps
Summary: media-libs/netpbm-10.39.0 bmptopnm floating point exception when used on cert...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Graphics Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-27 23:47 UTC by Heath Caldwell (RETIRED)
Modified: 2008-03-29 16:09 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Test bmp that causes the problem. (broken.bmp,65.55 KB, image/bmp)
2007-07-27 23:48 UTC, Heath Caldwell (RETIRED)
Details
Fixes dealing with 16-bit color depth bmp's (bmptopnm-16bitcolorfix.patch,1.36 KB, patch)
2007-10-10 23:00 UTC, Heath Caldwell (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Heath Caldwell (RETIRED) gentoo-dev 2007-07-27 23:47:32 UTC
The bmptopnm that results from emerging media-libs/netpbm-10.39.0 gives a floating point exception when used on certain bmps.  When I built netpbm-10.39.0 from scratch, the resulting bmptopnm did not have the problem on the same test bmp.

Reproducible: Always

Steps to Reproduce:
1. Emerge media-libs/netpbm-10.39.0
2. bmptopnm broken.bmp

Actual Results:  
bmptopnm: Windows BMP, 262x128x16
bmptopnm: WRITING PPM IMAGE
P6
262 128
255
Floating point exception

Expected Results:  
A correct pnm on stdout.

On the one I built from scratch, I only set "CFLAGS_SHLIB = -fPIC" in Makefile.config, after running config with all default answers.
Comment 1 Heath Caldwell (RETIRED) gentoo-dev 2007-07-27 23:48:45 UTC
Created attachment 126198 [details]
Test bmp that causes the problem.
Comment 2 Heath Caldwell (RETIRED) gentoo-dev 2007-10-10 23:00:06 UTC
Created attachment 133100 [details, diff]
Fixes dealing with 16-bit color depth bmp's

The problem occurs when extractBitFields is called with a pixelformat that has a trn.mask of zero (it divides by the masks without checking them first).  This seems like it will always happen when extractBitFields is called since trn.mask is defaulted to zero for pixelformat's, but it is only called for non-16-bit depths when the bitmap doesn't use conventional BGR format, which I guess is rare.  It is always called for 16-bit depth bitmaps, though, so it looks like 16-bit bitmaps will always break.

This patch fixes the problem by adding some checks so that extractBitFields won't do the divide by zero and also fixes the default rgb shifts and masks to what I think they should be for 16-bit color depth.
Comment 3 Heath Caldwell (RETIRED) gentoo-dev 2007-10-12 00:15:22 UTC
I found the difference between building from scratch and emerging: the default config when building from scratch used -O3 while I have -O2 in my make.conf.  Any thoughts on why compiling with a higher optimization level would cause it to avoid a divide by zero?  I am having trouble debugging it with optimizations so it is tough for me to see whether it might be no longer calling extractBitFields after compiling with -O3 for some reason.
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2007-12-28 23:00:23 UTC
(In reply to comment #3)
> I found the difference between building from scratch and emerging: the default
> config when building from scratch used -O3 while I have -O2 in my make.conf. 
> Any thoughts on why compiling with a higher optimization level would cause it
> to avoid a divide by zero?

NFC; CCing toolchain. Reproducible here w/ gcc-4.2.2.

Comment 5 SpanKY gentoo-dev 2007-12-29 07:12:42 UTC
before or after the proposed patch ... i'm not going to bother looking at a divide by 0 bug when it's already been fixed.  whether or not it crashes based on compiling doesnt really matter -- it's dividing by 0 and it shouldnt be doing that.
Comment 6 SpanKY gentoo-dev 2008-03-29 16:09:46 UTC
latest ebuild is fixed