php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19275 socket_create causes seg fault / unaligned trap
Submitted: 2002-09-07 06:46 UTC Modified: 2002-09-24 14:31 UTC
From: info at proustmedia dot de Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.2.3 OS: Debian2.2r3 on Alpha, ker.2.2.19
Private report: No CVE-ID: None
 [2002-09-07 06:46 UTC] info at proustmedia dot de
I cannot use the socket_create function on my Alpha, I only get a segmentation fault. I already noticed this problem with  
PHP4.2.2.

$ cat socket_create.php 
<?php
   $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
?>

$ build/php -q socket_create.php
php(25979): unaligned trap at 00000001201c0acc: 000000011fffe354 27 10
php(25979): unaligned trap at 00000001201c0acc: 000000011fffe35c 27 10
Erreur de segmentation [segmentation fault]

$ gdb build/php
GNU gdb 19990928
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 "alphaev56-unknown-linux-gnu"...
(gdb) run -q socket_create.php
Starting program: /home/fric/make/php-standalone/build/php -q socket_create.php

Program received signal SIGSEGV, Segmentation fault.
0x1200c5478 in zif_socket_create (ht=3, return_value=0x1203cfb90, this_ptr=0x0, return_value_used=1)
    at /home/fric/make/php-standalone/php-4.2.3/ext/sockets/sockets.c:888
888             php_sock->bsd_socket = socket(arg1, arg2, arg3);
(gdb) bt
#0  0x1200c5478 in zif_socket_create (ht=3, return_value=0x1203cfb90, this_ptr=0x0, return_value_used=1)
    at /home/fric/make/php-standalone/php-4.2.3/ext/sockets/sockets.c:888
#1  0x1201ffcd4 in execute (op_array=0x1203cfcc0) at ../../php-4.2.3/Zend/zend_execute.c:1598
#2  0x1201bf9a0 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at ../../php-4.2.3/Zend/zend.c:812
#3  0x12002a524 in php_execute_script (primary_file=0x11ffff8a8) at /home/fric/make/php-standalone/php-4.2.3/main/main.c:1383
#4  0x120025838 in main (argc=3, argv=0x11ffffaf8) at /home/fric/make/php-standalone/php-4.2.3/sapi/cgi/cgi_main.c:778
(gdb)

My configuration was:

  ../php-4.2.3/configure            \
     --with-zlib                    \
     --enable-calendar              \
     --enable-dbase                 \
     --enable-ftp                   \
     --with-gd=/usr                 \
     --with-jpeg-dir=/usr           \
     --with-png-dir=/usr            \
     --enable-gd-native-ttf         \
     --with-freetype-dir=/usr/local \
     --with-mysql=/usr              \
     --with-pdflib                  \
     --enable-exif                  \
     --enable-sockets               \
     --enable-pcntl                 \
     --enable-debug

My system is a SX 164 Alpha running GNU/Linux Debian 2.2r3 with a 2.2.19 patched kernel for ext fs 3 support.

$ uname -a
Linux alpha 2.2.19ext3 #5 Sat May 25 16:33:30 CEST 2002 alpha unknown

Please let me know if I can do something to help fix this problem.

With best regards,

Fabrice Haberer-Proust

Proust Media
Kerngasse 3/1
79576 Weil am Rhein
Germany

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-07 21:03 UTC] kalowsky@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip

The sockets code in CVS is much different than what you've got.  With a 4.3.0 coming soon, it would be good to see if this continues to be a problem for you.
 [2002-09-08 08:34 UTC] info at proustmedia dot de
>  ID:               19275
>  Updated by:       kalowsky@php.net
>  Reported By:      info@proustmedia.de
> -Status:           Open
> +Status:           Feedback
>  Bug Type:         Sockets related
>  Operating System: Debian2.2r3 on Alpha, ker.2.2.19
>  PHP Version:      4.2.3
>  New Comment:
> 
> Please try using this CVS snapshot:
> 
>   http://snaps.php.net/php4-latest.tar.gz
>  
> For Windows:
>  
>   http://snaps.php.net/win32/php4-win32-latest.zip
> 
> The sockets code in CVS is much different than what you've got.  With a
> 4.3.0 coming soon, it would be good to see if this continues to be a
> problem for you.

I just tried, unfortunaly, the problem remain the same. Here are the details.

The version I used: php4-200209080300

$ ./php -v
php(14837): unaligned trap at 0000000120295990: 000000012043653c 2d 1
php(14837): unaligned trap at 0000000120295990: 000000012043503c 2d 1
PHP 4.3.0-dev (cgi), Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies

(note the unaligned trap, that do no exist with the stable versions)

My config is quite the same, I just removed MySQL support because it causes a
compilation problem which has probably nothing to do with our problem)

$ cat configure-php4-200209080300-1.sh
#!/bin/sh

  ../php4-200209080300/configure    \
     --with-zlib                    \
     --enable-calendar              \
     --enable-dbase                 \
     --enable-ftp                   \
     --with-gd=/usr                 \
     --with-jpeg-dir=/usr           \
     --with-png-dir=/usr            \
     --enable-gd-native-ttf         \
     --with-freetype-dir=/usr/local \
     --with-pdflib                  \
     --enable-exif                  \
     --enable-sockets               \
     --enable-pcntl                 \
     --enable-debug

$ cat ../socket_create.php
<?php
   $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
?>

$ ./php -q ../socket_create.php
php(14840): unaligned trap at 0000000120295990: 000000012043653c 2d 1
php(14840): unaligned trap at 0000000120295990: 000000012043503c 2d 1
Erreur de segmentation [segmentation fault]

(gdb) run -q ../socket_create.php
Starting program: /home/fric/make/php-standalone/build/./php -q ../socket_create.php
php(14844): unaligned trap at 0000000120295990: 000000012043653c 2d 1
php(14844): unaligned trap at 0000000120295990: 000000012043503c 2d 1

Program received signal SIGSEGV, Segmentation fault.
0x1201325e0 in zif_socket_create (ht=3, return_value=0x1204b58c0,
    this_ptr=0x0, return_value_used=1)
    at /home/fric/make/php-standalone/php4-200209080300/ext/sockets/sockets.c:931
931             php_sock->bsd_socket = socket(arg1, arg2, arg3);

(gdb) bt
#0  0x1201325e0 in zif_socket_create (ht=3, return_value=0x1204b58c0,
    this_ptr=0x0, return_value_used=1)
    at /home/fric/make/php-standalone/php4-200209080300/ext/sockets/sockets.c:931
#1  0x12029c6a8 in execute (op_array=0x1204b5a30)
    at /home/fric/make/php-standalone/php4-200209080300/Zend/zend_execute.c:1602#2  0x12027de40 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /home/fric/make/php-standalone/php4-200209080300/Zend/zend.c:814
#3  0x12022c888 in php_execute_script (primary_file=0x11ffff998)
    at /home/fric/make/php-standalone/php4-200209080300/main/main.c:1510
#4  0x1202a53bc in main (argc=3, argv=0x11ffffbe8)
    at /home/fric/make/php-standalone/php4-200209080300/sapi/cgi/cgi_main.c:1046

With best regard

Fabrice Haberer-Proust

Proust Media
Kerngasse 3/1
79576 Weil am Rhein
Germany
 [2002-09-24 14:31 UTC] jason@php.net
I tested this on Debian 3.0 Linux 2.4.18-smp Alpha DS20, and was not able to reproduce the problem. The place at which your debugger is reporting that php is dying, should not trigger a segfault. You have a compiler or os problem.

Thanks,
-Jason

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC