Donate Share

SDL extension for PHP

Tracker: Bugs

7 SDL_FreeSurface() Segfault on Linux - ID: 1797502
Last Update: Comment added ( slizardo )

I am running PHPSDL from SVN on PHP 4.4.7 under Slackware Linux 12.0
(kernel 2.6.21.5) with SDL 1.2.11, and any trying to free an allocated
surface (created from a BMP) causes a segmentation fault.

Sample Code:
<?php
if(!extension_loaded("sdl")) dl("sdl.so");
register_shutdown_function("SDL_Quit");
echo "SDL_Init...";
if (SDL_Init(SDL_INIT_VIDEO) < 0) die("Unable to initialize SDL");
echo "Done\n";

echo "SDL_SetVideoMode...";
$video = SDL_SetVideoMode(512, 384, 0, SDL_HWSURFACE);
if(!$video) die("Unable to initialize SDL Video");
echo "Done\n";

echo "SDL_LoadBMP...";
$bmp = SDL_LoadBMP("image.bmp");
echo "Done\n";

echo "SDL_FreeSurface...";
SDL_FreeSurface($bmp);
echo "Done\n";

?>

Output:
SDL_Init...Done
SDL_SetVideoMode...Done
SDL_LoadBMP...Done
SDL_FreeSurface...Segmentation fault

Output when run via GDB:

Starting program: /root/phpsdl/bin/php-sdl freesurface.php
[Thread debugging using libthread_db enabled]
[New Thread -1212336448 (LWP 22469)]
SDL_Init...Done
SDL_SetVideoMode...Done
SDL_LoadBMP...Done
SDL_FreeSurface...
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1212336448 (LWP 22469)]
0x0814ac21 in zend_hash_find (ht=0x81d6820, arKey=0xb7fd22ab "format",
nKeyLength=7, pData=0xbfccd000)
at /usr/local/src/php-4.4.7/Zend/zend_hash.c:900
900 p = ht->arBuckets[nIndex];
(gdb) where
#0 0x0814ac21 in zend_hash_find (ht=0x81d6820, arKey=0xb7fd22ab "format",
nKeyLength=7, pData=0xbfccd000)
at /usr/local/src/php-4.4.7/Zend/zend_hash.c:900
#1 0xb7fcb753 in zif_sdl_freesurface (ht=1, return_value=0x824b23c,
this_ptr=0x0, return_value_used=0, tsrm_ls=0x81d70a8)
at /usr/local/src/svn/phpsdl/source/sdl.c:2029
#2 0x081600f7 in execute (op_array=0x82392a4, tsrm_ls=0x81d70a8) at
/usr/local/src/php-4.4.7/Zend/zend_execute.c:1681
#3 0x08145cb6 in zend_execute_scripts (type=8, tsrm_ls=0x81d70a8,
retval=0x0, file_count=3)
at /usr/local/src/php-4.4.7/Zend/zend.c:939
#4 0x08116aba in php_execute_script (primary_file=0xbfccf820,
tsrm_ls=0x81d70a8)
at /usr/local/src/php-4.4.7/main/main.c:1757
#5 0x0816354a in main (argc=2, argv=0xbfccf8e4) at
/usr/local/src/php-4.4.7/sapi/cli/php_cli.c:838


T.J. ( t.j. ) - 2007-09-18 22:04

7

Closed

Out of Date

Nobody/Anonymous

None

None

Public


Comment ( 1 )

Date: 2009-09-02 14:28
Sender: slizardoProject AdminAccepting Donations

Hello again T.J.!
Due to the time of the report of this bug and the evolution in our code
and tests, consider it solved.
Thank you for warning us.


Attached File

No Files Currently Attached

Changes ( 5 )

Field Old Value Date By
close_date - 2009-09-02 14:28 slizardo
allow_comments 1 2009-09-02 14:28 slizardo
resolution_id None 2009-09-02 14:28 slizardo
status_id Open 2009-09-02 14:28 slizardo
priority 5 2007-09-18 22:05 t.j.