# segfault when running header?

- Thread: https://externals.io/message/27889
- Original archive: https://news-web.php.net/php.internals/27889
- Started by Chris Malton on 2007-02-07T19:18:19+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #27889 — Chris Malton — 2007-02-07T19:18:19+00:00

URL: https://externals.io/message/27889#27889

The `header()` function currently causes a segfault with CVS head sources.

Here's a backtrace.

#0  _zend_mm_free_int (heap=0xb302f0, p=0xb88b11b)
    at /root/php6/Zend/zend_alloc.c:1522
#1  0x00000000006a5d4f in destroy_op_array (op_array=0x2ae269e4d410)
    at /root/php6/Zend/zend_opcode.c:265
#2  0x00000000006e0085 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (
    execute_data=0x7fff40c85d10) at /root/php6/Zend/zend_vm_execute.h:2039
#3  0x00000000006d7bbc in execute (op_array=0x2ae269e4ce30)
    at /root/php6/Zend/zend_vm_execute.h:92
#4  0x00000000006b0663 in zend_execute_scripts (type=8, retval=0xb88b11b,
    file_count=3) at /root/php6/Zend/zend.c:1630
#5  0x0000000000662883 in php_execute_script (primary_file=0x7fff40c883e0)
    at /root/php6/main/main.c:1951
#6  0x000000000073d394 in main (argc=2, argv=0x7fff40c8a648)
    at /root/php6/sapi/cgi/cgi_main.c:1660

I'll leave this up to a dev team person to sort.  I am merely testing
out php6 before a migration.

Need any more info? Give me a buzz.

Chris

---

## #27892 — Antony Dovgal — 2007-02-07T19:34:11+00:00

URL: https://externals.io/message/27889#27892 · In reply to: #27889

> The `header()` function currently causes a segfault with CVS head sources.
> 
> I'll leave this up to a dev team person to sort.  I am merely testing
> out php6 before a migration.

Migration to PHP6?

> Need any more info? Give me a buzz.

A reproduce case?

-- 
Wbr, 
Antony Dovgal

---

## #27893 — Chris Malton — 2007-02-07T19:42:29+00:00

URL: https://externals.io/message/27889#27893 · In reply to: #27892

Antony Dovgal wrote:
> > […]
sources.
> > […]

When it is released... of course!

This is testing server, and I'm seeing what gets broken by PHP6!

> > […]

WHOOPS - Turns out it isn't header that breaks it!

The following code breaks php6 at the cmd line.

<?php
if($_GET["ffcheck"]==""){
$ua=$_SERVER['HTTP_USER_AGENT'];
if(strpos($ua,"MSIE")!==false){ *segfaults HERE*
  //USER AGENT = MSIE!
  header("Location: http://shared.cjsoftuk.dyndns.org/Firefox.php?URL="
. urlencode("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]
. "?" . $_SERVER["QUERY_STRING"]));
  `exit()`;
}
}
?>

In php5, it works fine.  PHP 6 seems to segfault on empty strings!

Chris

---

## #27894 — Antony Dovgal — 2007-02-07T19:57:44+00:00

URL: https://externals.io/message/27889#27894

> > […]
> 
> WHOOPS - Turns out it isn't header that breaks it!
> 
> The following code breaks php6 at the cmd line.
> 
> <?php
> if($_GET["ffcheck"]==""){
> $ua=$_SERVER['HTTP_USER_AGENT'];
> if(strpos($ua,"MSIE")!==false){ *segfaults HERE*
>   //USER AGENT = MSIE!
>   header("Location: http://shared.cjsoftuk.dyndns.org/Firefox.php?URL="
> . urlencode("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]
> . "?" . $_SERVER["QUERY_STRING"]));
>   `exit()`;
> }
> }
> ?>

Could you please provide a short but complete reproduce case, so I can just copy/paste it and reproduce the problem.
With this code I can see only "Notice: Undefined index: ffcheck in ..", but no segfault.

Thank you.

-- 
Wbr, 
Antony Dovgal

---

## #27895 — Chris Malton — 2007-02-07T20:16:48+00:00

URL: https://externals.io/message/27889#27895 · In reply to: #27894

Antony Dovgal wrote:
> 
> > […]
> 
> Could you please provide a short but complete reproduce case, so I can
> just copy/paste it and reproduce the problem.
> With this code I can see only "Notice: Undefined index: ffcheck in ..",
> but no segfault.
> 
> Thank you.
> 

Please see below for a term session:

root@SERVER:~/php6# cat /srv/www/include/firefox.inc
<?php
//if($_GET["ffcheck"]==""){
//$ua=$_SERVER['HTTP_USER_AGENT'];
if(strpos($ua,"MSIE")!==false){
  //USER AGENT = MSIE!
  header("Location: http://shared.cjsoftuk.dyndns.org/Firefox.php?URL="
. urlencode("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]
. "?" . $_SERVER["QUERY_STRING"]));
  `exit()`;
}
//}
?>
root@SERVER:~/php6# php6 /srv/www/include/firefox.inc
Segmentation fault

(I know I shouldn't be root, but anyway it's over LAN).

See my point?

Chris

---

## #27896 — Antony Dovgal — 2007-02-07T20:33:38+00:00

URL: https://externals.io/message/27889#27896 · In reply to: #27895

> Please see below for a term session:
> 
> root@SERVER:~/php6# cat /srv/www/include/firefox.inc
> <?php
> //if($_GET["ffcheck"]==""){
> //$ua=$_SERVER['HTTP_USER_AGENT'];
> if(strpos($ua,"MSIE")!==false){
>   //USER AGENT = MSIE!
>   header("Location: http://shared.cjsoftuk.dyndns.org/Firefox.php?URL="
> . urlencode("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]
> . "?" . $_SERVER["QUERY_STRING"]));
>   `exit()`;
> }
> //}
> ?>
> root@SERVER:~/php6# php6 /srv/www/include/firefox.inc
> Segmentation fault
> 
> (I know I shouldn't be root, but anyway it's over LAN).
> 
> See my point?

Still no segfault. Valgrind says "0 errors from 0 contexts".
Try clean build using fresh CVS snapshot/checkout?

-- 
Wbr, 
Antony Dovgal

---

## #27897 — Stanislav Malyshev — 2007-02-07T20:46:11+00:00

URL: https://externals.io/message/27889#27897 · In reply to: #27889

Chris Malton wrote:
> The `header()` function currently causes a segfault with CVS head sources.
> 
> Here's a backtrace.
> 
> #0  _zend_mm_free_int (heap=0xb302f0, p=0xb88b11b)
>     at /root/php6/Zend/zend_alloc.c:1522
> #1  0x00000000006a5d4f in destroy_op_array (op_array=0x2ae269e4d410)
>     at /root/php6/Zend/zend_opcode.c:265

Doesn't seem to be in `header()` - `header()` doesn't do that.

-- 
Stanislav Malyshev, Zend Products Engineer
stas@zend.com  http://www.zend.com/

---

## #27898 — Chris Malton — 2007-02-07T21:03:16+00:00

URL: https://externals.io/message/27889#27898 · In reply to: #27896

Antony Dovgal wrote:
> 
> > […]
> 
> Still no segfault. Valgrind says "0 errors from 0 contexts".
> Try clean build using fresh CVS snapshot/checkout?
> 

You're right,  I'm using my bad practises again (cvs update && make)!

Seems to work with a reconfigure etc.

Looks like something OTHER than the C code changed.  I did get a lot of
warnings during compiling this time though.

Seems to work well otherwise.

Chris
