Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 1999 12:26:30 -0500
From:      Matthew Hagerty <matthew@venux.net>
To:        freebsd-hackers@freebsd.org
Subject:   Program can't get pointer-to-function, gdb can...
Message-ID:  <4.1.19990315121447.009ae700@mail.venux.net>

next in thread | raw e-mail | index | archive | help
Greetings,

I'm running 2.2.7-RELEASE (I know, I know), and I am trying to use a pdf
lib inside php3.  The program crashes when I try to call the function
PDF_get_info.  I ran the program in gdb, it fails when trying to get the
address of the pdf_default_error_handler function (listing 1).  However, if
I step up to that point in the program, set the value by hand, then skip
over the program assignment, it works (listing 2)!!  Any insight would be
greatly appreciated.

Thanks,
Matthew


bash-2.02# gdb php
GDB is free software and you are welcome to 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.
GDB 4.16 (i386-unknown-freebsd), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) list p_basic.c:95
90
91      PDF_info*
92      PDF_get_info(void)
93      {
94          PDF_info *info;
95
96          info = (PDF_info *) PDF_malloc(sizeof(PDF_info), "PDF_get_info");
97
98          info->binary_mode           = false;
99          info->required_compatibility= PDF1_1;
(gdb) break 96
Breakpoint 1 at 0x590ff: file p_basic.c, line 96.
(gdb) run -f test2.php3
Starting program: /usr/local/tempphp/php-3.0.7/php -f test2.php3

Breakpoint 1, PDF_get_info () at p_basic.c:96
96          info = (PDF_info *) PDF_malloc(sizeof(PDF_info), "PDF_get_info");
(gdb) next
98          info->binary_mode           = false;
(gdb) print info
$1 = (PDF_info *) 0xe73c0
(gdb) print *info
$2 = {binary_mode = 0, required_compatibility = PDF1_0, error_handler = 0, 
  Keywords = 0x0, Subject = 0x0, ModDate = 0x0, Title = 0x0, 
  CreationDate = 0x0, Creator = 0x0, Producer = 0x0, Author = 0x0, 
  fontpath = 0x0}
(gdb) next
99          info->required_compatibility= PDF1_1;
(gdb) next
102         info->Keywords              = NULL;
(gdb) next
103         info->Subject               = NULL;
(gdb) next
104         info->ModDate               = NULL;
(gdb) next
105         info->Title                 = NULL;
(gdb) next
106         info->CreationDate          = NULL;
(gdb) next
107         info->Creator               = NULL;
(gdb) print *info
$3 = {binary_mode = 0, required_compatibility = PDF1_1, error_handler = 0, 
  Keywords = 0x0, Subject = 0x0, ModDate = 0x0, Title = 0x0, 
  CreationDate = 0x0, Creator = 0x0, Producer = 0x0, Author = 0x0, 
  fontpath = 0x0}
(gdb) next
108         info->Producer              = NULL;
(gdb) next
109         info->Author                = NULL;
(gdb) next
111         info->error_handler         = pdf_default_error_handler;
(gdb) print *info
$4 = {binary_mode = 0, required_compatibility = PDF1_1, error_handler = 0, 
  Keywords = 0x0, Subject = 0x0, ModDate = 0x0, Title = 0x0, 
  CreationDate = 0x0, Creator = 0x0, Producer = 0x0, Author = 0x0, 
  fontpath = 0x0}
(gdb) next

Program received signal SIGSEGV, Segmentation fault.
0x5917b in PDF_get_info () at p_basic.c:111
111         info->error_handler         = pdf_default_error_handler;
(gdb) print info
$5 = (PDF_info *) 0xe73c0
(gdb) print *info
$6 = {binary_mode = 0, required_compatibility = PDF1_1, error_handler = 0, 
  Keywords = 0x0, Subject = 0x0, ModDate = 0x0, Title = 0x0, 
  CreationDate = 0x0, Creator = 0x0, Producer = 0x0, Author = 0x0, 
  fontpath = 0x0}
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
bash-2.02# 


BUT, if I set the value inside gdb, it works...


bash-2.02# gdb php
GDB is free software and you are welcome to 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.
GDB 4.16 (i386-unknown-freebsd), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) list p_basic.c:110
105         info->Title                 = NULL;
106         info->CreationDate          = NULL;
107         info->Creator               = NULL;
108         info->Producer              = NULL;
109         info->Author                = NULL;
110
111         info->error_handler         = pdf_default_error_handler;
112
113         info->fontpath              = PDF_DEFAULT_FONT_PATH;
114         return info;
(gdb) break 110
Breakpoint 1 at 0x59178: file p_basic.c, line 110.
(gdb) run -f test2.php3
Starting program: /usr/local/tempphp/php-3.0.7/php -f test2.php3

Breakpoint 1, PDF_get_info () at p_basic.c:111
111         info->error_handler         = pdf_default_error_handler;
(gdb) print info                   
$1 = (PDF_info *) 0xe73c0
(gdb) print *info
$2 = {binary_mode = 0, required_compatibility = PDF1_1, error_handler = 0, 
  Keywords = 0x0, Subject = 0x0, ModDate = 0x0, Title = 0x0, 
  CreationDate = 0x0, Creator = 0x0, Producer = 0x0, Author = 0x0, 
  fontpath = 0x0}
(gdb) print pdf_default_error_handler
$3 = {void (int, char *, char *)} 0x58e44 <pdf_default_error_handler>
(gdb) set info->error_handler = pdf_default_error_handler
(gdb) print *info
$4 = {binary_mode = 0, required_compatibility = PDF1_1, 
  error_handler = 0x58e44 <pdf_default_error_handler>, Keywords = 0x0, 
  Subject = 0x0, ModDate = 0x0, Title = 0x0, CreationDate = 0x0, 
  Creator = 0x0, Producer = 0x0, Author = 0x0, fontpath = 0x0}
(gdb) jump 112
Continuing at 0x59186.

Program exited normally.
(gdb) 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.1.19990315121447.009ae700>