hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Segmentation fault if memcache host doesn't resolve

Open apaloma opened this issue 12 years ago • 2 comments

HHVM will crash after the object is reused or free'd after a Memcache::add call where the server being used has a hostname that doesn't resolve.

For example:

<?php

$memcache = new Memcache();
$memcache->connect( "junkhost", 123 );
$memcache->add( "foo", "bar", 0, 5 );
echo $memcache->get( "foo" ) . "\n";  // crashes
echo "Done\n";
?>
Name: /usr/bin/hhvm
Type: Segmentation fault
Runtime: hhvm
Version: tags/HHVM-3.4.0-0-g817b3a07fc4e509ce15635dbc87778e5b3496663
DebuggerCount: 0

Arguments: hhvm_memcache_bug_test.php
ThreadType: CLI

#0  ?? at hhvm:0
#1  free at /tmp/tmp.1cIyH3Bll4/jemalloc-3.6.0/src/jemalloc.c:2109
#2  freeaddrinfo at /lib/x86_64-linux-gnu/libc.so.6:0
#3  memcached_behavior_get_distribution_hash at /usr/lib/libmemcached.so.6:0
#4  memcached_flush_buffers at /usr/lib/libmemcached.so.6:0
#5  memcached_get_by_key at /usr/lib/libmemcached.so.6:0
#6  memcached_get at /usr/lib/libmemcached.so.6:0
#7  ?? at hhvm:0
#8  void HPHP::Native::callFunc<false, false>(HPHP::Func const*, void*, HPHP::TypedValue*, HPHP::TypedValue&) at hhvm:0
#9  HPHP::TypedValue* HPHP::Native::methodWrapper<false, false>(HPHP::ActRec*) at hhvm:0

PHP, for comparison, emits the following, but does not crash:

PHP Warning:  Memcache::connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/steam/hhvm_memcache_bug_test.php on line 4
PHP Notice:  Memcache::connect(): Server junkhost (tcp 123, udp 0) failed with: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution (0) in /home/steam/hhvm_memcache_bug_test.php on line 4
PHP Warning:  Memcache::connect(): Can't connect to junkhost:123, php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution (0) in /home/steam/hhvm_memcache_bug_test.php on line 4

apaloma avatar Nov 24 '14 23:11 apaloma

Seems ok now : http://3v4l.org/0kfMJ

noony avatar Aug 14 '15 09:08 noony

Closing this out since it seems fixed, feel free to reopen if you get a repro case!

jwatzman avatar Aug 14 '15 18:08 jwatzman