Re: XForms: flimage problem revisited

From: T.C. Zhao (tc_zhao@yahoo.com)
Date: Mon Mar 25 2002 - 01:34:50 EST


# To subscribers of the xforms list from "T.C. Zhao" <tc_zhao@yahoo.com> :

thanks for the example program. It worked fine
on my systems (linux 2.0.34 and linux 0.99).
It could be that the problem has already
been fixed in the latest source.

--- Jens Thoms Toerring <Jens.Toerring@physik.fu-berlin.de> wrote:
> # To subscribers of the xforms list from Jens Thoms Toerring
> <Jens.Toerring@physik.fu-berlin.de> :
>
> Hello,
>
> I promised to write an example program as simple as possible that still
> crashes with a segmentation fault on flimage_free( ). Here it is:
>
> -----8<---- snip here ---------------------------------------------------
>
> #include <stdlib.h>
> #include <forms.h>
>
>
> typedef struct {
> FL_FORM *flimage;
> void *vdata;
> char *cdata;
> long ldata;
> FL_OBJECT *canvas;
> } FD_flimage;
>
>
> FD_flimage *create_form_flimage( void );
>
>
> int main( int argc, char *argv[ ] )
> {
> Display *d;
> FD_flimage *flimage;
> Pixmap pm;
> FL_IMAGE *fl_image;
>
>
> if ( ( d = fl_initialize( &argc, argv, "flimage", NULL, 0 ) ) == NULL )
> return EXIT_FAILURE;
>
> flimage = create_form_flimage( );
> fl_show_form( flimage->flimage, FL_PLACE_MOUSE, FL_FULLBORDER,
> "flimage" );
>
> pm = XCreatePixmap( d, FL_ObjWin( flimage->canvas ), 100, 100,
> fl_get_canvas_depth( flimage->canvas ) );
>
> if ( ( fl_image = flimage_alloc( ) ) == NULL )
> return EXIT_FAILURE;
>
> flimage_from_pixmap( fl_image, pm );
> flimage_dump( fl_image, "/tmp/xx.ppm", "PPM" );
> flimage_free( fl_image );
>
> XFreePixmap( d, pm );
> fl_hide_form( flimage->flimage );
> fl_free_form( flimage->flimage );
> return EXIT_SUCCESS;
> }
>
>
> FD_flimage *create_form_flimage( void )
> {
> FL_OBJECT *obj;
> FD_flimage *fdui = ( FD_flimage * ) fl_calloc( 1, sizeof *fdui );
>
> fdui->flimage = fl_bgn_form( FL_NO_BOX, 100, 100 );
> obj = fl_add_box( FL_UP_BOX, 0, 0, 100, 100, "" );
> fdui->canvas = obj = fl_add_canvas( FL_NORMAL_CANVAS, 0, 0, 100, 100,
> ""
> );
> fl_end_form();
>
> fdui->flimage->fdui = fdui;
>
> return fdui;
> }
>
> -----8<---- snip here ---------------------------------------------------
>
> I compile it using gcc version 2.95.3 with
>
> CFLAGS="-ggdb -Wall -W -I/usr/X11R6/include"
> LDFALGS="-L/usr/X11R6/lib -lX11 -lforms -lm"
>
> and get an executable named flimage. Running ldd on it gives:
>
> jens@dorimare:~/Programming/TESTS/flimage> ldd flimage
> libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x40023000)
> libforms.so.0.89 => /usr/X11R6/lib/libforms.so.0.89 (0x40106000)
> libm.so.6 => /lib/libm.so.6 (0x401d6000)
> libc.so.6 => /lib/libc.so.6 (0x401f8000)
> libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x4031e000)
> /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
>
> When I run it the form shortly pops up, the pixmap gets dumped into the
> file (I get: "Done Writing /tmp/xx.ppm(PPM) 100%(100 of 100)") but on
> flimage_free( ) it crashes with a segmentation fault. Here the backtrace
> I get from gdb:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x4026c96d in free () from /lib/libc.so.6
> (gdb) bt
> #0 0x4026c96d in free () from /lib/libc.so.6
> #1 0x4025e663 in fclose@@GLIBC_2.1 () from /lib/libc.so.6
> #2 0x40140d8d in flimage_close () from /usr/X11R6/lib/libforms.so.0.89
> #3 0x401416f2 in flimage_free () from /usr/X11R6/lib/libforms.so.0.89
> #4 0x08048a68 in main (argc=1, argv=0xbffff334) at flimage.c:41
> #5 0x402157ee in __libc_start_main () from /lib/libc.so.6
>
>
> As I already wrote this happens on a machine running Linux:
>
> jens@dorimare:~/Programming/TESTS/flimage> uname -a
> Linux dorimare 2.4.17 #17 Wed Feb 27 03:35:23 CET 2002 i686 unknown
>
> The libc version I have is:
>
> jens@dorimare:~/Programming/TESTS/flimage> /lib/libc.so.6
> GNU C Library stable release version 2.2.4, by Roland McGrath et al.
> Copyright (C) 1992-1999, 2000, 2001 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
> Compiled by GNU CC version 2.95.3 20010315 (SuSE).
> Compiled on a Linux 2.4.9 system on 2001-09-20.
> Available extensions:
> GNU libio by Per Bothner
> crypt add-on version 2.1 by Michael Glad and others
> Berkeley DB glibc 2.1 compat library by Thorsten Kukuk
> linuxthreads-0.9 by Xavier Leroy
> NoVersion patch for broken glibc 2.0 binaries
> BIND-8.2.3-T5B
> libthread_db work sponsored by Alpha Processor Inc
> NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
> Report bugs using the `glibcbug' script to <bugs@gnu.org>.
>
> Regards, Jens
> --
> _ _____ _____
> | ||_ _||_ _| Jens.Toerring@physik.fu-berlin.de
> _ | | | | | | AG Moebius, Institut fuer Molekuelphysik
> | |_| | | | | | Fachbereich Physik, Freie Universitaet Berlin
> \___/ens|_|homs|_|oerring Tel: ++49 (0)30 838 - 53394 / FAX: - 56046
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://world.std.com/~xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/
>

__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/



This archive was generated by hypermail 2b29 : Wed May 01 2002 - 13:54:17 EDT