php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31433 PHP CGI Core Dumps W/O TERMCAP Assignment
Submitted: 2005-01-06 21:04 UTC Modified: 2005-02-01 19:47 UTC
From: dgrimes at scvl dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4CVS, 5CVS (2005-01-22) OS: SCO OpenServer 5
Private report: No CVE-ID: None
 [2005-01-06 21:04 UTC] dgrimes at scvl dot com
Description:
------------
I am attempting to upgrade from 4.0.6 to 4.3.10. Everything compiled without warning or errors and installed fine. I eliminated everything from configure: 

configure --disable-all
make
make install

I want a CGI version from this compile. When I execute php from the command line, it coredumps with a memory fault. All I have to do is type php at the command line and it coredumps. I finally figured out it has something to do with the TERMCAP environment variable. When I set it to a valid TERMCAP value php will run fine.

TERMCAP Assignment:

TERMCAP='sa|scoansi|scoansi80x25|SCO ANSI Color Console:        :       :km:mm=\
E[=10L:mo=\E[=11L:rp=\E[%d;%db:vi=\E[=0c:ve=\E[=1c:vs=\E[=2c:   :am:be:eo:mi:xo:
:       :LE=\E[%dD:RI=\E[%dC:DO=\E[%dD:UP=\E[%dA:cm=\E[%i%d;%dH:DC=\E[%dP:      
:DL=\E[%dM:IC=\E[%d@:AL=\E[%dL:S1=\E[=%dg:cd=\E[J:cb=\E[1K:ce=\E[K:     :ho=\E[H
:RA=\E[?7l:SA=\E[?7h:@1=\E[H:@7=\E[F:kh=\E[H:   :kD=^_:kI=\E[L:kN=\E[G:%5=\E[G:k
P=\E[I:%8=\E[I:kB=\E[Z:kl=\E[D: :kd=\E[B:kr=\E[C:ku=\E[A:k1=\E[M:k2=\E[N:k3=\E[O
:k4=\E[P:k5=\E[Q:       :k6=\E[R:k7=\E[S:k8=\E[T:k9=\E[U:k;=\E[V:F1=\E[W:F2=\E[X
:       :mb=\E[5m:md=\E[1m:mr=\E[7m:mk=\E[8m:so=\E[7m:se=\E[27m:me=\E[m:        
:ac=0[a1fxgqh2jYk?lZm@nEqDtCu4vAwBx3+/.\231-\230,.`\204~\207i\150y\163z\162{\143
};;IIHH<<JJKKMM::LL99NN88UUTT>>OOQQFF55XX77VVSS==PPRRGG66WW:    :as=\E[12m:ae=\E
[10m:cs=\E[%i%d;%dr:wi=\E[%i%d;%d;%i%d;%dr:MC=\E[=r:    :oc=\E[51m:Co#8:pa#64:AB
=\E[4%dm:Sb=\E[4%dm:AF=\E[3%dm:Sf=\E[3%dm:op=\E[0;37;40m:'

Once TERMCAP is assigned, php runs OK. I am installing on SCO OperServer 5 Version 5.0.6. If you need any additional information please let me know.

Dean


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-14 03:49 UTC] dgrimes at scvl dot com
OK... Sorry for the delay... Here is the output from gdb:

GNU gdb 4.18
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 "i486-unknown-sco3.2v5.0.0elf"...
Core was generated by `php'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libsocket.so.2...done.
Reading symbols from /usr/lib/libc.so.1...done.
Reading symbols from /usr/lib/libresolv.so.1...done.
#0  0x80021bb2 in getcwd () from /usr/lib/libc.so.1
(gdb) bt
#0  0x80021bb2 in getcwd () from /usr/lib/libc.so.1
#1  0x80073cf0 in pathcanon () from /usr/lib/libsocket.so.2
#2  0x80073fd0 in realpath () from /usr/lib/libsocket.so.2
#3  0x80ccc70 in php_execute_script (primary_file=0x8047b3c)
    at /d/cdev/php-4.3.10/main/main.c:1703
#4  0x811c460 in main (argc=1, argv=0x8047b84)
    at /d/cdev/php-4.3.10/sapi/cgi/cgi_main.c:1592
(gdb) 


I hope this is more in line with what you're looking for.

Thanks,

Dean
 [2005-01-22 21:34 UTC] sniper@php.net
Please try using this CVS snapshot:

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

The compile failure should at least be fixed now.

 [2005-01-24 22:59 UTC] dgrimes at scvl dot com
That version compiled just fine but I still have the original problem. PHP 4.0.6 compiles and doesn't have this issue. It's the version were using now. I can open an issue with SCO if you think it's a bad libc. Can you give me more information that supports that conclusion?

Dean
 [2005-01-26 05:49 UTC] sniper@php.net
Can you provide the above backtrace but using the snapshot?

 [2005-01-26 06:14 UTC] sniper@php.net
You could ask SCO support why the realpath() function is called from libsocket.so.2 and not from libc.so.1..



 [2005-01-26 06:18 UTC] sniper@php.net
See also bug #23665

 [2005-01-26 17:36 UTC] dgrimes at scvl dot com
SCO sent this to me:

Dean, Please have a look at this TA and let me know if you think this will help your situation. It appears that this is applicable to OSr5.0.0 to 5.0.6.

Thanks,
Todd

*********************** TA # 100815 **********************************

Calling realpath(S) from within my program causes a core dump.

KEYWORDS: v5 5.0.0 osr5 openserver dev sys development system ds getcwd realpath memory fault coredump core dump ENGREF LTD-246-807

RELEASE:  SCO OpenServer Development System Release 5.0.0

PROBLEM:  If I make a call to realpath(S) from within my source I find 
          that, when compiled, the resulting binary will terminate with 
          the error:

                Memory fault(coredump)

CAUSE:    The character buffer passed to realpath(S) is being passed to
          a function called pathcanon().  This function is calling getcwd(S) 
          with a buffer size of 4096 bytes.  getcwd(S) clears this buffer 
          and overruns the stack causing the core dump.

SOLUTION: This problem has been reported to SCO Engineering.

          To work around this problem, make sure that the character 
          buffer passed to realpath(S) is 4096 bytes in size:

                char buff[4096];

                realpath(filename, buff);

          where 'filename' is the name of the file whose path you wish 
          to resolve.
--------------------------------------

Thanks,
Dean
 [2005-01-28 05:06 UTC] dgrimes at scvl dot com
Here is the fix:

main/php.h

set MAXPATHLEN from 256 to 1024


diff -c php.h.org php.h    
*** php.h.org   Thu Jan 27 20:54:04 2005
--- php.h       Thu Jan 27 20:56:13 2005
***************
*** 250,256 ****
  # ifdef PATH_MAX
  #  define MAXPATHLEN PATH_MAX
  # else
! #  define MAXPATHLEN 256    /* Should be safe for any weird systems that do no
t define it */
  # endif
  #endif
  
--- 250,256 ----
  # ifdef PATH_MAX
  #  define MAXPATHLEN PATH_MAX
  # else
! #  define MAXPATHLEN 1024    /* Should be safe for any weird systems that do n
ot define it */
  # endif
  #endif
 [2005-01-29 14:27 UTC] dgrimes at scvl dot com
After additional testing I found that MAXPATHLEN needs to be increased to 4096. Although 1024 kept PHP from core dumpping, certain functions like shell_exec would not execute properly.

Dean
 [2005-02-01 19:47 UTC] dgrimes at scvl dot com
I have opted to close this issue. After applying the change to MAXPATHLEN, the problem no longer exists.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Aug 24 04:01:27 2024 UTC