Date: Wed, 03 Jul 2002 08:28:05 +0300 From: Angelin Lazarov Lalev <alalev@uni-svishtov.bg> To: questions@freebsd.org Subject: Where did I go wrong with gdb52 Message-ID: <3D228B65.7040708@uni-svishtov.bg>
next in thread | raw e-mail | index | archive | help
(The gdb52 was compiled from yesterday's ports. My system is FreeBSD 4.6 Stable, 21 Jun, compiled with "make buildworld CFLAGS=-g") (I was debuging a mail filter for sendmail with libmilter.) bash-2.05a# cd /usr/home/lalev/gapd/ bash-2.05a# make clean && make && make install rm -r gapd.o gcc -c -g gapd.c gapd.c: In function `gapd_envfrom': gapd.c:33: warning: assignment makes pointer from integer without a cast gapd.c:34: warning: comparison between pointer and integer gapd.c: In function `main': gapd.c:96: warning: assignment from incompatible pointer type gapd.c:97: warning: assignment from incompatible pointer type gcc -g -o gapd gapd.o -lmilter -pthread mkdir -p /usr/local/bin mkdir -p /var/spool/gapd chown root.wheel /var/spool/gapd install -o root -g wheel -m 755 gapd /usr/local/bin bash-2.05a# /usr/local/bin/gapd bash-2.05a# ps -ax|grep gapd 281 ?? Ss 0:00.00 /usr/local/bin/gapd 283 p0 S+ 0:00.01 grep gapd 232 v7 I+ 0:03.45 emacs gapd.c bash-2.05a# gdb52 /usr/local/bin/gapd 281 GNU gdb 5.2 (FreeBSD) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-portbld-freebsd4.6"... Attaching to program: /usr/local/bin/gapd, process 281 Reading symbols from /usr/lib/libmilter.so.2...done. Loaded symbols for /usr/lib/libmilter.so.2 Reading symbols from /usr/lib/libc_r.so.4...done. Loaded symbols for /usr/lib/libc_r.so.4 Reading symbols from /usr/libexec/ld-elf.so.1...done. Loaded symbols for /usr/libexec/ld-elf.so.1 [Switching to Process 281, Thread 1] 0x280e3c38 in _thread_sys_poll () from /usr/lib/libc_r.so.4 (gdb) b gapd_envfrom Breakpoint 1 at 0x8048833: file gapd.c, line 28. (gdb) l gapd_envfrom 19 /* 20 * gapd_envfrom - When this function is called from libmilter, it creates a 21 * file with unique name in which is stored the message, received further on. 22 */ 23 24 sfsistat gapd_envfrom (SMFICTX *ctx, char ** argv[]) { 25 char *tempstr; 26 char *filename; 27 28 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "gapd_envfrom was just called!"); (gdb) l 29 filename=(char*)malloc(strlen(FILENAME_TEMPLATE)+strlen(SPOOL_DIR)+1); 30 strcpy(filename, SPOOL_DIR); 31 strcat(filename, FILENAME_TEMPLATE); 32 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "The temporary file is %s.", filename); 33 TEMPFILE=mkstemp(filename); 34 if (TEMPFILE==-1) { 35 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "Error creating the temporary file!"); 36 exit(201); 37 } else { 38 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "Temporary file is created successfully!"); (gdb) l 39 fprintf(TEMPFILE, "%s: %s", "X-Probe", "successful"); 40 } 41 return SMFIS_CONTINUE; 42 } 43 44 sfsistat gapd_envrcpt (SMFICTX *ctx, char ** argv[]) { 45 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "gapd_envrcpt was just called!"); 46 return SMFIS_CONTINUE; 47 } 48 (gdb) b gapd_envfrom (gdb) c Continuing. [Switching to Process 281, Thread 4] Breakpoint 1, gapd_envfrom (ctx=0x805e300, argv=0x8060050) at gapd.c:28 28 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "gapd_envfrom was just called!"); (gdb) s 29 filename=(char*)malloc(strlen(FILENAME_TEMPLATE)+strlen(SPOOL_DIR)+1); (gdb) s Program received signal SIGSEGV, Segmentation fault. 0x280e4f56 in _flockfile_debug () from /usr/lib/libc_r.so.4 (gdb) bt #0 0x280e4f56 in _flockfile_debug () from /usr/lib/libc_r.so.4 #1 0x280e51f1 in flockfile () from /usr/lib/libc_r.so.4 #2 0x28124ebd in vfprintf () from /usr/lib/libc_r.so.4 #3 0x28124945 in fprintf () from /usr/lib/libc_r.so.4 #4 0x0804892c in gapd_envfrom (ctx=0x805e300, argv=0x8060050) at gapd.c:39 #5 0x28071827 in mi_clr_macros () from /usr/lib/libmilter.so.2 #6 0x28070ba1 in mi_engine () from /usr/lib/libmilter.so.2 #7 0x28070738 in mi_handle_session () from /usr/lib/libmilter.so.2 #8 0x2806fbd7 in mi_thread_handle_wrapper () from /usr/lib/libmilter.so.2 #9 0x280924f3 in _thread_start () from /usr/lib/libc_r.so.4 (strange, I did not called fprintf on that row where the SIGSEGV was received). (gdb) kill Kill the program being debugged? (y or n) y (gdb) quit bash-2.05a# rm /var/run/gapd.sock bash-2.05a# /usr/local/bin/gapd bash-2.05a# ps -ax|grep gapd 289 ?? Ss 0:00.00 /usr/local/bin/gapd 232 v7 I+ 0:03.45 emacs gapd.c bash-2.05a# gdb /usr/local/bin/gapd 289 GNU gdb 4.18 (FreeBSD) Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-unknown-freebsd"... /usr/home/lalev/gapd/289: No such file or directory. Attaching to program: /usr/local/bin/gapd, process 289 Reading symbols from /usr/lib/libmilter.so.2...done. Reading symbols from /usr/lib/libc_r.so.4...done. Reading symbols from /usr/libexec/ld-elf.so.1...done. 0x280e3c38 in _thread_sys_poll () from /usr/lib/libc_r.so.4 (gdb) b gapd_h envfrom Breakpoint 1 at 0x8048833: file gapd.c, line 28. (gdb) c Continuing. [Switching to process 289, thread 4] Breakpoint 1, gapd_envfrom (ctx=0x805e300, argv=0x8060050) at gapd.c:28 28 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "gapd_envfrom was just called!"); (gdb) s 29 filename=(char*)malloc(strlen(FILENAME_TEMPLATE)+strlen(SPOOL_DIR)+1); (gdb) s 30 strcpy(filename, SPOOL_DIR); (gdb) s 31 strcat(filename, FILENAME_TEMPLATE); (gdb) s 32 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "The temporary file is %s.", filename); (gdb) s 33 TEMPFILE=mkstemp(filename); (gdb) s 34 if (TEMPFILE==-1) { (gdb) s 38 syslog(LOG_MAKEPRI(LOG_MAIL, LOG_INFO), "Temporary file is created successfully!"); (gdb) s 39 fprintf(TEMPFILE, "%s: %s", "X-Probe", "successful"); (gdb) s Program received signal SIGSEGV, Segmentation fault. 0x280e4f56 in _flockfile_debug () from /usr/lib/libc_r.so.4 (gdb) bt #0 0x280e4f56 in _flockfile_debug () from /usr/lib/libc_r.so.4 #1 0x280e51f1 in flockfile () from /usr/lib/libc_r.so.4 #2 0x28124ebd in vfprintf () from /usr/lib/libc_r.so.4 #3 0x28124945 in fprintf () from /usr/lib/libc_r.so.4 #4 0x804892c in gapd_envfrom (ctx=0x805e300, argv=0x8060050) at gapd.c:39 #5 0x28071827 in mi_clr_macros () from /usr/lib/libmilter.so.2 #6 0x28070ba1 in mi_engine () from /usr/lib/libmilter.so.2 #7 0x28070738 in mi_handle_session () from /usr/lib/libmilter.so.2 #8 0x2806fbd7 in mi_thread_handle_wrapper () from /usr/lib/libmilter.so.2 #9 0x280924f3 in _thread_start () from /usr/lib/libc_r.so.4 #10 0x0 in ?? () (gdb) kill Kill the program being debugged? (y or n) y (gdb) quit bash-2.05a# To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D228B65.7040708>