[xdebug-dev] Bug 0000267: CLI segfaults when trace file is not writeable

From: <noreply[@]lists.xdebug.org>
Date: Sun, 10 Jun 2007 00:00:01 +0200

The following bug has been CLOSED
======================================================================
http://bugs.xdebug.org/bug_view_page.php?bug_id=0000267
======================================================================
Reporter: flotsam
Handler: derick
======================================================================
Project: Xdebug
Bug ID: 267
Category: Usage problems
Reproducibility: always
Severity: minor
Priority: normal
Status: closed
Operating System:
PHP Version: 5.2.1
Xdebug Version: 2.0.0rc3
======================================================================
Date Submitted: 2007-05-13 20:10 CEST
Last Modified: 2007-06-10 00:00 CEST
======================================================================
Summary: CLI segfaults when trace file is not writeable
Description:
A script lets xdebug write a tracefile. Executed via Apache, xdebug sets
owner.group of the tracefile to those of Apache (www-data.www-data on
Debian) and permissions to 644.

Executing the same script via PHP CLI segfaults w/o any useful info.
Strace shows its because the tracefile is not writeable. CLI executes as
current user, which is not www-data.

It would be nice if xdebug terminates gracefully with an explanatory
message instead of crashing ;)

Here's strace's last lines:

open("/tmp/init-parenchym.php.xt", O_RDWR|O_LARGEFILE) = -1 EACCES
(Permission denied)
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
======================================================================

----------------------------------------------------------------------
 derick - 2007-05-13 20:17 CEST
----------------------------------------------------------------------
I am quite positive this has been fixed in CVS already. For instructions on
how to use the CVS version, see: http://xdebug.org/install.php#source

----------------------------------------------------------------------
 flotsam - 2007-05-13 20:19 CEST
----------------------------------------------------------------------
And as I see now, the same is true vice versa: CLI creates trace file,
Apache is denied to overwrite it, child process segfaults.

(PHP Version is 5.2.2-1+b1)

----------------------------------------------------------------------
 flotsam - 2007-05-13 20:35 CEST
----------------------------------------------------------------------
RE: derick 2007-05-13 20:17

It's not. I just compiled the sources of 2.0.0RC4-dev and had the same bug
as described above.

Besides, make test reports:
Number of tests : 87 69
Tests skipped : 18 ( 20.7%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 69 ( 79.3%) (100.0%)
Tests passed : 0 ( 0.0%) ( 0.0%)
---------------------------------------------------------------------
Time taken : 22 seconds

AHEM?

----------------------------------------------------------------------
 derick - 2007-05-22 22:46 CEST
----------------------------------------------------------------------
I can not reproduce this:

derick[@]kossu:/home/httpd/html/test/xdebug$ cat bug267.php
<?php
xdebug_start_trace("/tmp/bug267test");

strlen( join( ", ", range( 1, 10 ) ) );
?>

derick[@]kossu:/home/httpd/html/test/xdebug$ php bug267.php

derick[@]kossu:/home/httpd/html/test/xdebug$ ls -l /tmp/bug267test.xt
-rw-r--r-- 1 derick derick 328 2007-05-22 22:36 /tmp/bug267test.xt

derick[@]kossu:/home/httpd/html/test/xdebug$ sudo chown root
/tmp/bug267test.xt
Password or swipe finger:

derick[@]kossu:/home/httpd/html/test/xdebug$ ls -l /tmp/bug267test.xt
-rw-r--r-- 1 root derick 328 2007-05-22 22:36 /tmp/bug267test.xt

derick[@]kossu:/home/httpd/html/test/xdebug$ php bug267.php

derick[@]kossu:/home/httpd/html/test/xdebug$ date
Tue May 22 22:37:07 CEST 2007

derick[@]kossu:/home/httpd/html/test/xdebug$ ls -l /tmp/bug267test.*
-rw-r--r-- 1 derick derick 328 2007-05-22 22:37 /tmp/bug267test.04364d.xt
-rw-r--r-- 1 root derick 328 2007-05-22 22:36 /tmp/bug267test.xt

As you can see it did not overwrite the file, but instead saw that the
file was not writable and created a file with a random bit in it; and no
segfault.

When using autotrace:

derick[@]kossu:/home/httpd/html/test/xdebug$ php -dxdebug.auto_trace=1
bug267.php

derick[@]kossu:/home/httpd/html/test/xdebug$ php -dxdebug.auto_trace=1
bug267.php

derick[@]kossu:/home/httpd/html/test/xdebug$ ls -l /tmp/*.xt
-rw-r--r-- 1 derick derick 406 2007-05-22 22:45 /tmp/trace.1258863198.xt

derick[@]kossu:/home/httpd/html/test/xdebug$ sudo chown root
/tmp/trace.1258863198.xt

derick[@]kossu:/home/httpd/html/test/xdebug$ php -dxdebug.auto_trace=1
bug267.php

derick[@]kossu:/home/httpd/html/test/xdebug$ ls -l /tmp/*.xt
-rw-r--r-- 1 derick derick 406 2007-05-22 22:45
/tmp/trace.1258863198.042ab7.xt
-rw-r--r-- 1 root derick 406 2007-05-22 22:45 /tmp/trace.1258863198.xt

----------------------------------------------------------------------
 flotsam - 2007-06-07 20:56 CEST
----------------------------------------------------------------------
Thanks for describing that procedure. I copied that step by step and again
got that segfault. Hmm...

Checked out your latest sources, which are RC5-dev, and :) xdebug works as
you described.

Well, it seems xdebug creates a new file every time, even if it could
overwrite the last one. -- Which makes perfectly sense, 'cause that random
part in the filename is, well, random. But over time it would fill up my
tmp space...
dm[@]arawn:~/public_html$ php bug267.php
dm[@]arawn:~/public_html$ php bug267.php
dm[@]arawn:~/public_html$ php bug267.php
dm[@]arawn:~/public_html$ l /tmp/bug267test.*
-rw-r--r-- 1 dm dm 331 2007-06-07 20:50 /tmp/bug267test.02e29a.xt
-rw-r--r-- 1 dm dm 331 2007-06-07 20:50 /tmp/bug267test.03982e.xt
-rw-r--r-- 1 dm dm 331 2007-06-07 20:50 /tmp/bug267test.0c3175.xt
-rw-r--r-- 1 root dm 331 2007-06-07 20:40 /tmp/bug267test.xt

Thank you for xdebug

----------------------------------------------------------------------
 derick - 2007-06-10 00:00 CEST
----------------------------------------------------------------------
Cool, let's close it then.

Bug History
Date Modified Username Field Change
======================================================================
2007-05-13 20:10flotsam New Bug
2007-05-13 20:10flotsam Bug Monitored: flotsam
2007-05-13 20:17derick Bugnote Added: 0000612
2007-05-13 20:17derick Assigned To => derick
2007-05-13 20:17derick Resolution open => fixed
2007-05-13 20:17derick Status new => resolved
2007-05-13 20:19flotsam Bugnote Added: 0000613
2007-05-13 20:35flotsam Bugnote Added: 0000614
2007-05-13 20:35flotsam Resolution fixed => reopened
2007-05-13 20:35flotsam Status resolved => feedback
2007-05-22 22:46derick Bugnote Added: 0000626
2007-06-07 20:56flotsam Bugnote Added: 0000651
2007-06-10 00:00derick Bugnote Added: 0000653
2007-06-10 00:00derick Status feedback => closed
======================================================================
Received on Sun Jun 10 2007 - 00:00:03 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST