Segmentation fault from simple pub/sub - ubuntu 11.04 - PHP 5.3.5-1ubuntu7.8 #244

Closed
minitru opened this Issue Sep 2, 2012 · 5 comments

3 participants

@minitru

Hey guys... having an odd probem - using a simple pub/sub example the second published message to a subscribed client is causing a segfault. Latest redis/phpredis.. code below:

pub.php

<?php
//publish.php

$redis = new Redis();
$redis->pconnect('127.0.0.1',6379);
$redis->publish('chan-3', 'hello, world!'); // send message to channel 3.
$redis->publish('chan-3', 'hello, world2!'); // again
$redis->close();
?>

sub.php
<?php

function f($redis, $chan, $msg) { // does nothing - for testing...
}

ini_set('default_socket_timeout', -1);// it works fine

$redis = new Redis();
$redis->pconnect('127.0.0.1',6379);
$redis->subscribe(array('chan-3'),'f'); // subscribe to 1 channel
?>

@phred

Confirmed, I see the same behavior, running off current HEAD.

@michael-grunder
phpredis member

I also see this issue, and I've got a core dump! :)

I'll look into it guys. Going to clean up a couple of these bugs in phpredis this weekend.

@michael-grunder michael-grunder added a commit that referenced this issue Sep 8, 2012
@michael-grunder michael-grunder Move destruction of callback out of the loop
This fixes issue #244 where we were seeing a SIGSEGV upon the second
publish to a channel, given that the variable "z_fun" was freed
inside the loop, and then called again.
9eb217c
@michael-grunder
phpredis member

Try it now guys :)

Cheers,
Mike

@minitru

Works here - thanks for the fast fix!

@phred

Yep, working for me too, thanks! Back to implementing my little library with the locking algorithm described at http://redis.io/commands/setnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment