Saturday, October 3, 2009

Seg fault when calling php memcache::addServer

addServer('localhost', 11211);
var_dump($mc_0->get('ss'));
var_dump($mc_0->set('ss', 1, NULL, 100));
var_dump($mc_0->get('ss'));

$mc_1 = new Memcache;
$mc_1->addServer('localhost', 11211, NULL);
var_dump($mc_1->get('ss'));
var_dump($mc_1->set('ss', 2, NULL, 100));
var_dump($mc_1->get('ss'));


$mc_2 = new Memcache;
$mc_2->addServer('localhost', 11211, NULL, 1); 
var_dump($mc_2->get('ss'));
var_dump($mc_2->set('ss', 3, NULL, 100));
var_dump($mc_2->get('ss'));

$mc_4 = new Memcache;
$mc_4->addServer('localhost', 11211, NULL, 1, NULL);
var_dump($mc_4->get('ss'));
var_dump($mc_4->set('ss', 4, NULL, 100));
var_dump($mc_4->get('ss'));

$mc_5 = new Memcache;
$mc_5->addServer('localhost', 11211, NULL, 1, NULL, NULL);
var_dump($mc_5->get('ss'));
var_dump($mc_5->set('ss', 5, NULL, 100));
var_dump($mc_5->get('ss'));

$mc_6 = new Memcache;
$mc_6->addServer('localhost', 11211, NULL, 1, NULL, NULL, NULL);
var_dump($mc_6->get('ss'));
var_dump($mc_6->set('ss', 6, NULL, 100));
var_dump($mc_6->get('ss'));

$mc_7 = new Memcache;
$mc_7->addServer('localhost', 11211, NULL, 1, NULL, NULL, NULL, NULL);
var_dump($mc_7->get('ss'));
var_dump($mc_7->set('ss', 7, NULL, 100));
var_dump($mc_7->get('ss'));




Guess whatz the result :?

sskaje@newborn:~/test$ php test3.php 
string(1) "7"
bool(true)
string(1) "1"
string(1) "1"
bool(true)
string(1) "2"
string(1) "2"
bool(true)
string(1) "3"
string(1) "3"
bool(true)
string(1) "4"
string(1) "4"
bool(true)
string(1) "5"
string(1) "5"
bool(true)
string(1) "6"
string(1) "6"
bool(true)
string(1) "7"
Segmentation fault
sskaje@newborn:~/test$ 

Noticed ? Thatz a seg fault at the very end. Now look above to see where error occurs.
Hmm...
addServer('localhost', 11211, NULL, 1, NULL, NULL, NULL, NULL);

Yup, this is the line where that seg fault occurs.
Compare this line with the $mc_2 lines. Yes, you saw the difference is the forth argument when calling addServer. The $mc_2 uses 1 and $mc_7 uses NULL.

I'll check the source out to find what exactly causes this error when I'm really that free.

No comments:

Post a Comment