Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault #10

Closed
pastinepolenta opened this issue Jan 21, 2014 · 15 comments
Closed

Segmentation fault #10

pastinepolenta opened this issue Jan 21, 2014 · 15 comments

Comments

@pastinepolenta
Copy link

I am trying to test Mosquitto with TLS but I get a segmentation fault error.

This is the code:

define('BROKER', '10.11.25.36');
define('PORT', 8883);
define('SECURE', TRUE);

$client = new Mosquitto\Client();
$client->onConnect('connect');
$client->onDisconnect('disconnect');
$client->onSubscribe('subscribe');
$client->onMessage('message');

if(SECURE){
$client->setTlsOptions($certReqs = Mosquitto\Client::SSL_VERIFY_PEER, $tlsVersion = 'tlsv1.2', $cipers=NULL);
$client->setTlsCertificates($caPath = 'path/to/my/ca.crt');
}

try {
$client->connect(BROKER, PORT, 60);
$client->onLog('logger');
$client->subscribe('/api/send/#', 1);
$client->loopForever();
}
catch (Exception $e){
echo "ERROR " . $e->getMessage();
}

What am I missing?

@mgdm
Copy link
Owner

mgdm commented Jan 21, 2014

Are you able to get a backtrace? (This might be helpful: https://bugs.php.net/bugs-generating-backtrace.php)

I'll attempt to reproduce that myself. Can you tell me what OS and Mosquitto versions you're using?

@pastinepolenta
Copy link
Author

Ubuntu 12.04 with mosquitto version 1.2.3 (build date 2013-12-04 21:24:29+0000)
I will try to backtrace now but I am not expert in that

@pastinepolenta
Copy link
Author

BTW, on setTlsOptions is it cipers or ciphers ?

@mgdm
Copy link
Owner

mgdm commented Jan 21, 2014

It’s ciphers.

On 21 Jan 2014, at 11:04, stilllife00 [email protected] wrote:

BTW, on setTlsOptions is it cipers or ciphers ?


Reply to this email directly or view it on GitHub.

@pastinepolenta
Copy link
Author

This is what I was able to get, I don't know if it is useful:

$ gdb php ~/core-php.6913
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http:https://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
http:https://bugs.launchpad.net/gdb-linaro/...
Reading symbols from /usr/bin/php...Reading symbols from /usr/lib/debug/usr/bin/php5...done.
done.
[New LWP 6913]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

warning: the debug information found in "/usr/lib/debug//usr/lib/php5/20090626/mysql.so" does not match "/usr/lib/php5/20090626/mysql.so" (CRC mismatch).

warning: the debug information found in "/usr/lib/debug/usr/lib/php5/20090626/mysql.so" does not match "/usr/lib/php5/20090626/mysql.so" (CRC mismatch).

warning: the debug information found in "/usr/lib/debug//usr/lib/php5/20090626/mysqli.so" does not match "/usr/lib/php5/20090626/mysqli.so" (CRC mismatch).

warning: the debug information found in "/usr/lib/debug/usr/lib/php5/20090626/mysqli.so" does not match "/usr/lib/php5/20090626/mysqli.so" (CRC mismatch).

warning: the debug information found in "/usr/lib/debug//usr/lib/php5/20090626/pdo_mysql.so" does not match "/usr/lib/php5/20090626/pdo_mysql.so" (CRC mismatch).

warning: the debug information found in "/usr/lib/debug/usr/lib/php5/20090626/pdo_mysql.so" does not match "/usr/lib/php5/20090626/pdo_mysql.so" (CRC mismatch).

Core was generated by `php server.php'.
Program terminated with signal 11, Segmentation fault.
#0 0x00000000005e08a1 in php_stat (filename=0x1 <Address 0x1 out of bounds>, filename_length=14385888, type=13, return_value=0x0)
at /build/buildd/php5-5.3.10/ext/standard/filestat.c:957
957 /build/buildd/php5-5.3.10/ext/standard/filestat.c: No such file or directory.

@mgdm
Copy link
Owner

mgdm commented Jan 21, 2014

Could you get into gdb again, and after the prompt appears, type 'bt' and paste what you get back?

@pastinepolenta
Copy link
Author

#0 0x000000000068d6f0 in zend_call_function (fci=0x2be2d70, fci_cache=0x2be2db8) at /build/buildd/php5-5.3.10/Zend/zend_execute_API.c:859
#1 0x00007ffa6b1f593a in php_mosquitto_log_callback (mosq=, obj=0x2be2b20, level=, str=)
at /tmp/pear/temp/Mosquitto/mosquitto.c:955
#2 0x00007ffa6afe853e in ?? () from /usr/lib/libmosquitto.so.1
#3 0x00007ffa6afeb8d0 in ?? () from /usr/lib/libmosquitto.so.1
#4 0x00007ffa6b1f52cd in mosquitto_client_object_destroy (object=0x2be2b20) at /tmp/pear/temp/Mosquitto/mosquitto.c:795
#5 0x00000000006bf64f in zend_objects_store_free_object_storage (objects=0xdd52d8) at /build/buildd/php5-5.3.10/Zend/zend_objects_API.c:92
#6 0x000000000068c603 in shutdown_executor () at /build/buildd/php5-5.3.10/Zend/zend_execute_API.c:304
#7 0x000000000069a6d5 in zend_deactivate () at /build/buildd/php5-5.3.10/Zend/zend.c:963
#8 0x0000000000647420 in php_request_shutdown (dummy=0x1) at /build/buildd/php5-5.3.10/main/main.c:1664
#9 0x000000000042baa5 in main (argc=32767, argv=0x7fff2f63a810) at /build/buildd/php5-5.3.10/sapi/cli/php_cli.c:1367

@pastinepolenta
Copy link
Author

Do you know if it is a bug or if I am doing something wrong?

@mgdm
Copy link
Owner

mgdm commented Jan 24, 2014

It's a bug, definitely :-) you shouldn't be able to crash PHP by doing that. I'm looking at it, but I'm at PHP Benelux just now, which is distracting me!

On 24 Jan 2014, at 13:02, stilllife00 [email protected] wrote:

Do you know if it is a bug or if I am doing something wrong?


Reply to this email directly or view it on GitHub.

@mgdm
Copy link
Owner

mgdm commented Jan 24, 2014

I can't crash it on this OSX system, I'll try again on an Ubuntu VM as soon as I can.

@mgdm
Copy link
Owner

mgdm commented Jan 25, 2014

Right - two things. First off, having the names of the parameters in the methods like that is a little odd (though works). I'd just change it to
$client->setTlsOptions(Mosquitto\Client::SSL_VERIFY_PEER, 'tlsv1.2', NULL);

Also, I've found a problem with loopForever(). If you replace it with

while (true) { $client->loop(); }

it should continue to work.

@pastinepolenta
Copy link
Author

The segmentation fault remains. It fails on that setTlsOptions method, no matter which loop I use

@pastinepolenta
Copy link
Author

Any idea?

@pastinepolenta
Copy link
Author

I tried the same code in a Max OSX Mavericks machine and the segmentation fault remains. Maybe there are some problems in the way I created the ca.crt file (plus the bug).

@MattiasAlsNix
Copy link

Hi,
I had the exactly same error and bt. When I disabled the xdebug extension the segmentation fault was gone.

@mgdm mgdm closed this as completed Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants