php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57190 extension causes "BUS ERROR"/malloc in php 5.1.5
Submitted: 2006-08-20 19:52 UTC Modified: 2006-08-21 00:23 UTC
From: michaelw at darkhorse dot com Assigned: pajoye (profile)
Status: Closed Package: mnogosearch (PECL)
PHP Version: 5.1.4 OS: OS X
Private report: No CVE-ID: None
 [2006-08-20 19:52 UTC] michaelw at darkhorse dot com
Description:
------------
As far as I can tell, PHP 5.1.5 no longer supports --with-mnogosearch in the configure file, forcing me to switch to the PECL extension and the addition of "extension=mnogosearch.so" in the php.ini file.

Once I do that, however, apache will not restart.  I get a "BUS ERROR".  Removing the call to mnogo allows apache to restart correctly.

In addition, when I have mnogo enabled and I call a script from the CLI, I get the following error when it hits a command like udm_alloc_agent():
php(27466) malloc: ***  Deallocation of a pointer not malloced: 0x1; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
php(27466) malloc: ***  Deallocation of a pointer not malloced: 0x100; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
php(27466) malloc: ***  Deallocation of a pointer not malloced: 0x2809ae4; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug


Reproduce code:
---------------
From the command line:
php -r 'Udm_Alloc_Agent("mysql://");' // dsn is irrelevent



Expected result:
----------------
Nothing.

Actual result:
--------------
php(27466) malloc: ***  Deallocation of a pointer not malloced: 0x1; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
php(27466) malloc: ***  Deallocation of a pointer not malloced: 0x100; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
php(27466) malloc: ***  Deallocation of a pointer not malloced: 0x2809ae4; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug

And when restarting apache:
/usr/sbin/apachectl: line 193: 27479 Bus error               $HTTPD


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-20 20:03 UTC] pierre dot php at gmail dot com
This extension has been moved to the PECL repository and is no longer bundled with PHP as of PHP 5.1.0.

I cannot reproduce this problem with 3.2.33.

Which Mnogosearch version do you use?
 [2006-08-20 21:20 UTC] michaelw at darkhorse dot com
I'm using the latest 3.2.39 but I've also tried it on a second machine with 3.2.35.

3.2.33 gives me no error from my CLI test but apache still refuses to start unless I remove it from the php.ini file (i returns:
/usr/sbin/apachectl: line 193: 17077 Bus error               $HTTPD
).

Is there some special debug log or tool I could use to help track down the cause of the error?

Also, I realized that the mnogo extension isn't included as of 5.1.10 but 5.1.14's config script still supported --with-mnogosearch, so I could download the extension from mnogo.com and put it in the "ext" folder.  Not possible with 5.1.15.
 [2006-08-20 21:29 UTC] pierre dot php at gmail dot com
"Also, I realized that the mnogo extension isn't included as of 5.1.10 but 5.1.14's config script still supported --with-mnogosearch"

There is no 5.1.10 or 5.1.14, or do you mean 5.1.0 and 5.1.4? Both versions (and 5.1.5) do not have the mnogosearch configuration option.

"Is there some special debug log or tool I could use to help  track down the cause of the error?"

Compile PHP in debug mode (configure --enable-debug) and run through valgrind or gdb.

Valgrind:
valgrind php -r 'Udm_Alloc_Agent("mysql://");'


GDB (enter at the end of each line > ...<enter>):
gdb php
> set args -r 'Udm_Alloc_Agent("mysql://");'
> run
> bt

and copy the outputs here (one of them or both).
 [2006-08-20 23:11 UTC] michaelw at darkhorse dot com
Yeah, I meant 5.1.5.  Sorry.

I recompiled with --enable-debug, reinstaled the mnogo pecl extension, changed the php.ini file to point to the new, debug extension folder and ran GDB.  I got a very disappointing:
(gdb) set args -r 'Udm_Alloc_Agent("mysql://");'
(gdb) run
Starting program: /usr/local/bin/php -r 'Udm_Alloc_Agent("mysql://");'
Reading symbols for shared libraries ..+....+++ done
Reading symbols for shared libraries ... done

Program exited normally.
(gdb) bt
No stack.
(gdb) quit


Valgrind doesn't seem to be available on OS X.

And now things are more confusing.  Now I can't get an error with the CLI test, even if I switch back to non-debug mode.  And apache will still not start.
 [2006-08-21 00:23 UTC] michaelw at darkhorse dot com
Fixed it.

When installing PHP 5 on OS X (I can't speak for other platforms), the PHP4 module, if still active, causes some weird conflict that wouldn't allow the mnogosearch module to get compiled in.  Disabling the php4 module makes it all work.

I can't explain the earlier CLI problems...

Thanks for all of your quick responses on this.
 [2008-02-21 15:04 UTC] adam dot prall at thinkingman dot com
This appears to be a problem with the Entropy PHP installation 
- pear uses the php binary of the folder it's located in, 
which happens to be /usr/local/php5/bin/php in the Entropy 
installation, whose CLI is broken as of the version mentioned 
above. Using plain "php" from the CLI results in invocation of 
the Mac OS php, whose CLI is *not* broken, thus the Bus Error 
when using PEAR.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 11:01:30 2024 UTC