php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8463 Using internal function in usort call segfaults
Submitted: 2000-12-28 13:13 UTC Modified: 2001-01-03 10:16 UTC
From: greg at darkphoton dot com Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 4.0.4 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: greg at darkphoton dot com
New email:
PHP Version: OS:

 

 [2000-12-28 13:13 UTC] greg at darkphoton dot com
Using usort() with an internal function segfaults, for example using strcasecmp() in the usort call will fail, but making a function in php called testcmp() which then calls strcasecmp() works fine.

This worked in 4.0.3 and below

In the following code snipit, the script will print 1 and 2 but crash before 3.

$mblist[0] = "Drafts";
$mblist[1] = "LRP";
$mblist[2] = "Sent Items";
$mblist[3] = "INBOX";
$mblist[4] = "Apache";
$mblist[5] = "Internet";
$mblist[6] = "Lists";
$mblist[7] = "People";
$mblist[8] = "Personal";

Function testcmp( $a, $b )
	{
	return strcasecmp( $a, $b );
	}

echo "1<BR>";
flush();
usort( $mblist, testcmp );
echo "2";
flush();
usort( $mblist, strcasecmp );
echo "3";
flush();

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-29 07:04 UTC] sniper@php.net
1. your test script is buggy, it should be like this:
usort( $mblist, "testcmp" );
(notice the "'s)

2. I tried this with the latest CVS and it doesn't crash.

Please try the latest snapshot from http://snaps.php.net/

--Jani
 [2001-01-02 13:45 UTC] greg at darkphoton dot com
1. 4.0.4 crashes with either, 4.0.3 works with either

2. snaps.php.net seems to be down and has been for several days


 [2001-01-02 18:54 UTC] sniper@php.net
snaps.php.net is up now.

--Jani
 [2001-01-03 10:14 UTC] greg at darkphoton dot com
Current CVS snapshot (php4-200101030645) works
 [2001-01-03 10:16 UTC] sniper@php.net
Fixed -> Closed. This fix should be in upcoming PHP 4.0.4pl1
or at least in PHP 4.0.5

--Jani
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 15:01:36 2025 UTC