nanogui: Segfault in fblin32.c, line 77
Subject:
Re: [nanogui] Segfault in fblin32.c, line 77
From:
"Pascal Tritten, Railtec Systems GmbH" ####@####.####
Date:
23 Apr 2008 19:26:30 -0000
Message-Id: <480F8D54.9060603@railtec-systems.ch>
Hi Greg
Greg Haerr schrieb:
[...]
> The X11 driver keeps "savebits" by commanding X11, then
> drawing using the fb32 driver. It looks like perhaps the
> size malloced could be incorrect. This is calced in the genmem.c
> file, I think, but you'll need to look hard at the X11 driver to
> trace where it alloced the savebits fb buffer in the first place.
>
> I'm not aware of any X11 driver problems, so its a bit strange...
>
> Regards,
>
> Greg
I found the following:
The size malloced in scr_x11.c is calculated by GdCalcMemGCAlloc(..)
which returns 1228800 (= 640*480*4) for TrueColor (32bit).
savebits.addr is of type ADDR32 which is a typedef to a long*. On my
64bit system, a long is 8 bytes, so the calculation
"addr += x1 + y * psd->linelen;"
in fblin32.c adds x1+y*psd->linelen*8 bytes (instead of 4 bytes, which
were used for calculating the size for mallocing). That's the reason why
I have the segfault when calculating with y=241.
I changed in drivers/fb.h the typedefs for ADDR8, ADDR16 and ADDR32 to
the standard sized types u_int8_t, u_int16_t and u_int32_t.
Thanks for the input!
Best regards
Pascal
[Content type text/x-patch not shown. Download]