[PHP-DEV] PHP 4.0 Bug #6176: apache+php+pdflib crash with pdf_end_page($pdf) From: panu.kalliokoski <email protected>
Date: 08/15/00

From: panu.kalliokoski <email protected>
Operating system: Linux 2.2.14
PHP version: 4.0 Latest CVS (15/08/2000)
PHP Bug Type: Reproduceable crash
Bug description: apache+php+pdflib crash with pdf_end_page($pdf)

The bug is quite hard to reproduce. We have a script that crashes every time, which uses database, session variables and other such stuff, so it is of no use to you. Then we built another script which issues the same pdflib calls, and this script crashes _part of the time_. Thus I suppose the crash is somehow dependent on php's internal state; how, I don't know. And the cgi version of php does not crash on either of the scripts.

Here is the backtrace:
(note that the innermost frame has been many different things on distinct runs, so that would suggest the execution jumps to a random location)

Program received signal SIGSEGV, Segmentation fault.
0x400f0883 in fwrite () from /lib/libc.so.6
(gdb) bt
#0 0x400f0883 in fwrite () from /lib/libc.so.6
#1 0x4032b9c6 in PDF_setrgbcolor_fill (p=0x817214c, red=4.56706555e-34,
    green=9.8511282e-43, blue=2.8047595) at p_color.c:135
#2 0x40338161 in pdf_open_TIFF_data (p=0x817214c, imageslot=1077139815,
    filename=0x5 <Address 0x5 out of bounds>,
    stringparam=0x4032c93a "[\201AnU\001", intparam=1076835252) at p_tiff.c:338
#3 0x4032cd05 in pdf_outbyte (p=0x817214c, c=-1) at p_filter.c:43
#4 0x4026b5d9 in php_if_pdf_set_transition (ht=1, return_value=0x81130e4,
    this_ptr=0x0, return_value_used=0) at pdf.c:2196
#5 0x40229609 in execute (op_array=0x8156d30) at ./zend_execute.c:2229
#6 0x4022985c in execute (op_array=0x81704a8) at ./zend_execute.c:2269
#7 0x4022985c in execute (op_array=0x81142c4) at ./zend_execute.c:2269
#8 0x402362be in zend_hash_do_resize (ht=0x8) at zend_hash.c:461
#9 0x40245b35 in php_fopen_primary_script () at fopen-wrappers.c:356
#10 0x402424f3 in php_hash_environment () at main.c:935
#11 0x40242e66 in cfgerror (str=0x8105c7c "T\\\020\b,,\020\b\004£\t\b")
    at /home/panu/tmp/try/php4/main/configuration-parser.y:134
#12 0x40242ea6 in pvalue_config_destructor ()
    at /home/panu/tmp/try/php4/main/configuration-parser.y:142
#13 0x8053f04 in ap_invoke_handler ()
#14 0x806286c in ap_some_auth_required ()
#15 0x80628c8 in ap_process_request ()
#16 0x805c5e9 in ap_child_terminate ()
#17 0x805c77c in ap_child_terminate ()
#18 0x805c899 in ap_child_terminate ()
#19 0x805cd4b in ap_child_terminate ()
#20 0x805d40d in main ()
#21 0x400c0a42 in __libc_start_main () from /lib/libc.so.6

Here is the ripped-down script:

<?php
$fp = fopen( "test.pdf", "wb" );
$pdf = PDF_open ( $fp );
pdf_set_info($pdf, "Author", "Giro");
pdf_set_info($pdf, "Title", "report-test");
pdf_set_info($pdf, "Creator", "See Author");
pdf_begin_page ($pdf,595, 842);
pdf_set_font($pdf,"Helvetica", 9, "winansi");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"Hasan & Partners");
pdf_show_boxed($pdf,"Hasan & Partners",50,816,71.028,13,"left");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"Ranking");
pdf_show_boxed($pdf,"Ranking",283.494,816,33.012,13,"center");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"Sivu 1");
pdf_show_boxed($pdf,"Sivu 1",519.989,816,25.011,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"");
pdf_show_boxed($pdf,"",50,23,0,13,"left");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"ProjectCast");
pdf_show_boxed($pdf,"ProjectCast",276.744,23,46.512,13,"center");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"15.08.2000");
pdf_show_boxed($pdf,"15.08.2000",499.964,23,45.036,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"Ajalta -");
pdf_show_boxed($pdf,"Ajalta -",285.996,803,28.008,13,"center");
pdf_setgray($pdf,0);
pdf_setlinewidth($pdf,0.25);
pdf_moveto ($pdf,45 , 842 - ($pdf * 13) + 0.25);
pdf_lineto ($pdf,550 , 842 - ($pdf * 13) + 0.25);
pdf_stroke($pdf);
pdf_setgray($pdf,0.90);
pdf_rect($pdf,9*5 , 842 - (6 * 13), 101*5, 1 * 13);
pdf_fill($pdf);
pdf_setgray($pdf,0);
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",57.486,764,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,764,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",222.486,764,17.514,13,"right");
pdf_setgray($pdf,0);
pdf_setlinewidth($pdf,0.25);
pdf_moveto ($pdf,45 , 842 - (7 * 13) + 13.25);
pdf_lineto ($pdf,550 , 842 - (7 * 13) + 13.25);
pdf_stroke($pdf);
pdf_setgray($pdf,0.90);
pdf_rect($pdf,9*5 , 842 - (9 * 13), 101*5, 1 * 13);
pdf_fill($pdf);
pdf_setgray($pdf,0);
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0,00");
pdf_show_boxed($pdf,"0,00",57.486,725,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0,00");
pdf_show_boxed($pdf,"0,00",167.486,725,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"");
pdf_show_boxed($pdf,"",240,725,0,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2030.00");
pdf_show_boxed($pdf,"2030.00",42.474,712,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,712,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,712,22.518,13,"right");
pdf_setgray($pdf,0.90);
pdf_rect($pdf,9*5 , 842 - (11 * 13), 101*5, 1 * 13);
pdf_fill($pdf);
pdf_setgray($pdf,0);
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2090.00");
pdf_show_boxed($pdf,"2090.00",42.474,699,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,699,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,699,22.518,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2070.00");
pdf_show_boxed($pdf,"2070.00",42.474,686,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,686,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,686,22.518,13,"right");
pdf_setgray($pdf,0.90);
pdf_rect($pdf,9*5 , 842 - (13 * 13), 101*5, 1 * 13);
pdf_fill($pdf);
pdf_setgray($pdf,0);
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2012.00");
pdf_show_boxed($pdf,"2012.00",42.474,673,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,673,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,673,22.518,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2080.00");
pdf_show_boxed($pdf,"2080.00",42.474,660,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,660,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,660,22.518,13,"right");
pdf_setgray($pdf,0.90);
pdf_rect($pdf,9*5 , 842 - (15 * 13), 101*5, 1 * 13);
pdf_fill($pdf);
pdf_setgray($pdf,0);
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2010.00");
pdf_show_boxed($pdf,"2010.00",42.474,647,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,647,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,647,22.518,13,"right");
Pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2060.00");
pdf_show_boxed($pdf,"2060.00",42.474,634,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,634,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,634,22.518,13,"right");
pdf_setgray($pdf,0.90);
pdf_rect($pdf,9*5 , 842 - (17 * 13), 101*5, 1 * 13);
pdf_fill($pdf);
pdf_setgray($pdf,0);
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2050.00");
pdf_show_boxed($pdf,"2050.00",42.474,621,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,621,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,621,22.518,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2100.00");
pdf_show_boxed($pdf,"2100.00",42.474,608,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,608,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,608,22.518,13,"right");
pdf_setgray($pdf,0.90);
pdf_rect($pdf,9*5 , 842 - (19 * 13), 101*5, 1 * 13);
pdf_fill($pdf);
pdf_setgray($pdf,0);
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2072.00");
pdf_show_boxed($pdf,"2072.00",42.474,595,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",167.486,595,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"10.00");
pdf_show_boxed($pdf,"10.00",217.482,595,22.518,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"0.00");
pdf_show_boxed($pdf,"0.00",57.486,582,17.514,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2030.00");
pdf_show_boxed($pdf,"2030.00",97.474,582,32.526,13,"right");
pdf_set_font($pdf,"Helvetica",9,"winansi");
PDF_stringwidth($pdf,"2030.00");
pdf_show_boxed($pdf,"2030.00",152.474,582,32.526,13,"right");
pdf_setgray($pdf,0);
pdf_setlinewidth($pdf,0.25);
pdf_moveto ($pdf,45 , 842 - (21 * 13) + 13.25);
pdf_lineto ($pdf,550 , 842 - (21 * 13) + 13.25);
pdf_stroke($pdf);
pdf_end_page($pdf);
pdf_close($pdf);
fclose($fp);

Build parameters:

  PHP Version 4.0.2-dev
  System Linux ws23 2.2.14 #1 Wed Mar 22 15:27:14 EST 2000 i686
                 unknown
  Build Date Aug 15 2000
  Configure './configure' '--with-apxs' '--with-ndbm=/usr' '--with-gd=/
  Command usr' '--with-zlib=/usr' '--with-jpeg-dir=/usr'
                 '--with-png-dir=/usr' '--with-mysql=/usr' '--with-pdflib=/
                 usr/local' '--with-tiff-dir=/usr' '--enable-dba' '-with-mm=/
                 usr' '--enable-trans-sid' '--enable-shared-pdflib'
                                                                               

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>