nanogui: nano-X libpng : read a png image crash nano-X on a arm target (but work well on host x86)
Subject:
nano-X libpng : read a png image crash nano-X on a arm target (but
work well on host x86)
From:
BRACH Vincent ####@####.####
Date:
30 Jul 2009 10:27:55 -0000
Message-Id: <1248949678.5326.81.camel@zoul.intranet.smie.com>
Hello all,
I've a problem with nano-X (CVS sources) and GrLoadImageFromFile for PNG
type image only with the cross-compiled version of nano-X on my target
(arm - CPU PXA270) but not with the nano-X binary running on my host
(x86) : I investigate the problem (following step of investigations) and
found the line code that generate a SEGFAULT in nano-X in this
situation :
1/ To support PNG I've build the libpng (version 1.2.38 sources from
http://www.libpng.org) and zlib (version 1.2.3 sources from
http://www.zlib.org) for my target architecture (with arm-linux-gnueabi
tool chain), install them in the cross-chain location, and rebuild
nano-X with same cross-chain and use this previous libs.
some config of nano-X are :
ARCH = LINUX-ARM
HAVE_PNG_SUPPORT = Y
INCPNG = /usr/local/arm-linux/arm-linux/include/
LIBPNG
= /usr/local/arm/oe/arm-linux-gnueabi/lib/libpng.a
INCZ = /usr/local/arm-linux/arm-linux/include/
LIBZ
= /usr/local/arm/oe/arm-linux-gnueabi/lib/libz.a
Everything compiled with success (nano-X + demos) and copy into the
target.
2/ On the target when I run ./nano-X & ./nxview image.png , nano-X crash
with a Segmentation fault.
Note that running ./nano-X & ./nvxiew image.png on my host (x86) (with
nano-X and demos compiled for x86 architecture) work perfectly !
3/ I've rebuild nano-X and demos with DEBUG=Y and OPTFLAGS += -ggdb -O0
to be able to run nano-X with gdbserver on the target and watch with gdb
exactly the problem
After this step (and some long time to compil and crosscompil
gdb/gdbserver ;)) I check the followings :
Program received signal SIGSEGV, Segmentation fault.
0x00017f6c in GdImageBufferRead (buffer=0x0, dest=0xbe82a4f4,
size=8) at /home/vincent/microwindows-cvs/src/engine/devimage.c:78
In fact, a NULL pointer for buffer for the call of int
GdImageBufferRead(buffer_t *buffer, void *dest, unsigned long size) (in
devimage.c) called by the png_read_buffer function (in image_png.c), and
the first line of GdImageBufferRead that is buffer->offset generate a
SEGFAULT
With add of if (buffer==0 || dest==0) return -1; at the begenning of the
GdImageBufferRead function and same procedure, nano-X doesn't crash,
nvxiew display 'Can't load image file' and both terminate normaly.
4/ Continuing my investigations with step by step on ddd (on host side)
and gdbserver (on target side) I notice that in GdDecodePNG
(image_png.c) png_structp state always contain 0 for all fields BUT
during step execution of png_init_io(state, src); (into this function,
into the lib) the contents of the structure seems to be good, but not
after leaving and return in the GdDecodePNG function. (strange)
I note that when compiling nano-X I've got this warning: passing
argument 2 of 'png_init_io' from incompatible pointer type. Argument 2
if the src pointer (buffer_t *) and png_init_io require a png_FILE_p
type, but even when casting (png_FILE_p)src for the png_init_io call (no
more warning) but same result...
Now I can't continue some investigations and require some helps...
Does anybody try and reach to cross compil nano-X with libpng for arm
architecture and display some PNG image with ??
Is there's some particular options for the libpng or/and zlib build to
work with nano-X ?
Sorry for this long mail but need to be clear.
Can anybody help me please ?
Regards,
Vincent BRACH