hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

HHVM is segfaulting as soon as nginx passes a request to it

Open BenjaminNolan opened this issue 12 years ago • 4 comments

I'm moving a bunch of sites over from an old apache server to nginx and HHVM on a nice shiny new Debian 7.6 Linode and I'm having issues with HHVM which I don't see elsewhere that I'm using it.

As soon as nginx dispatches my request to HHVM, it segfaults and dies, spitting out a /tmp/stacktrace.blah.log. One of the guys in the IRC channel pointed me at a few things yesterday, but now it seems to be happening with different functions (yesterday, it seemed to be session_start() that was causing the segfault, but now it looks like it's date-related).

The latest stack traces from this morning are as follows, and the ones from last night are here: https://gist.github.com/TwoWholeWorms/b429aa3fddfc1b53c6a6

Stack trace 1 (standard HHVM):

Host: pinky
ProcessID: 17286
ThreadID: 7ff7a87ff700
ThreadPID: 17294
Name: unknown program
Type: Segmentation fault
Runtime: hhvm
Version: tags/HHVM-3.3.0-0-g0a3cfb87b8a353fc7e1d15374f4adc413e37aba9
DebuggerCount: 0

ThreadType: Web Request
Server_SERVER_NAME: www.modpackmaker.com
Server: modpackmaker.com
URL: /

#0  HPHP::Variant::Variant(HPHP::Variant const&) at /usr/bin/hhvm:0
#1  HPHP::createBacktrace(HPHP::BacktraceArgs const&) at /usr/bin/hhvm:0
#2  HPHP::ExtendedException::ExtendedException(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /usr/bin/hhvm:0
#3  HPHP::ExecutionContext::handleError(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool, HPHP::ExecutionContext::ErrorThrowMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) at /usr/bin/hhvm:0
#4  HPHP::raise_strict_warning(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /usr/bin/hhvm:0
#5  HPHP::TimeZone::Current() at /usr/bin/hhvm:0
#6  HPHP::DateTime::fromTimeStamp(long, bool) at /usr/bin/hhvm:0
#7  HPHP::DateTime::DateTime(long, bool) at /usr/bin/hhvm:0
#8  HPHP::f_date(HPHP::String const&, long) at /usr/bin/hhvm:0
#9  HPHP::fg_date(HPHP::ActRec*) at /usr/bin/hhvm:0
#10 void HPHP::ExecutionContext::dispatchImpl<false>() at /usr/bin/hhvm:0
#11 HPHP::ExecutionContext::enterVM(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState, HPHP::Resumable*, HPHP::ObjectData*) at /usr/bin/hhvm:0
#12 HPHP::ExecutionContext::invokeFunc(HPHP::TypedValue*, HPHP::Func const*, HPHP::Variant const&, HPHP::ObjectData*, HPHP::Class*, HPHP::VarEnv*, HPHP::StringData*, HPHP::ExecutionContext::InvokeFlags) at /usr/bin/hhvm:0
#13 HPHP::vm_call_user_func(HPHP::Variant const&, HPHP::Variant const&, bool) at /usr/bin/hhvm:0
#14 HPHP::f_call_user_func(int, HPHP::Variant const&, HPHP::Array const&) at /usr/bin/hhvm:0
#15 HPHP::fg_call_user_func(HPHP::ActRec*) at /usr/bin/hhvm:0
#16 void HPHP::ExecutionContext::dispatchImpl<false>() at /usr/bin/hhvm:0
#17 HPHP::ExecutionContext::enterVM(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState, HPHP::Resumable*, HPHP::ObjectData*) at /usr/bin/hhvm:0
#18 HPHP::ExecutionContext::invokeFunc(HPHP::TypedValue*, HPHP::Func const*, HPHP::Variant const&, HPHP::ObjectData*, HPHP::Class*, HPHP::VarEnv*, HPHP::StringData*, HPHP::ExecutionContext::InvokeFlags) at /usr/bin/hhvm:0
#19 HPHP::ExecutionContext::invokeUnit(HPHP::TypedValue*, HPHP::Unit const*) at /usr/bin/hhvm:0
#20 HPHP::invoke_file(HPHP::String const&, bool, char const*) at builtin-functions.cpp:0
#21 HPHP::include_impl_invoke(HPHP::String const&, bool, char const*) at /usr/bin/hhvm:0
#22 HPHP::hphp_invoke(HPHP::ExecutionContext*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, HPHP::Array const&, HPHP::VRefParamValue const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, bool, bool, bool) at /usr/bin/hhvm:0
#23 HPHP::HttpRequestHandler::executePHPRequest(HPHP::Transport*, HPHP::RequestURI&, HPHP::SourceRootInfo&, bool) at /usr/bin/hhvm:0
#24 HPHP::HttpRequestHandler::handleRequestImpl(HPHP::Transport*) at /usr/bin/hhvm:0
#25 HPHP::HttpRequestHandler::handleRequest(HPHP::Transport*) at /usr/bin/hhvm:0
#26 HPHP::ServerWorker<std::shared_ptr<HPHP::FastCGIJob>, HPHP::FastCGITransportTraits>::doJobImpl(std::shared_ptr<HPHP::FastCGIJob>, bool) at /usr/bin/hhvm:0
#27 HPHP::ServerWorker<std::shared_ptr<HPHP::FastCGIJob>, HPHP::FastCGITransportTraits>::doJob(std::shared_ptr<HPHP::FastCGIJob>) at /usr/bin/hhvm:0
#28 HPHP::JobQueueWorker<std::shared_ptr<HPHP::FastCGIJob>, HPHP::Server*, true, false, HPHP::JobQueueDropVMStack>::start() at /usr/bin/hhvm:0
#29 HPHP::AsyncFuncImpl::ThreadFunc(void*) at /usr/bin/hhvm:0
#30 start_thread at /lib/x86_64-linux-gnu/libpthread.so.0:0
#31 __clone at /lib/x86_64-linux-gnu/libc.so.6:0

Stack trace 2 (HHVM-dbg):

Host: pinky
ProcessID: 17444
ThreadID: 7f7ea73ff700
ThreadPID: 17452
Name: unknown program
Type: Segmentation fault
Runtime: hhvm
Version: tags/HHVM-3.3.0-0-g0a3cfb87b8a353fc7e1d15374f4adc413e37aba9
DebuggerCount: 0

ThreadType: Web Request
Server_SERVER_NAME: www.modpackmaker.com
Server: modpackmaker.com
URL: /

#0  HPHP::Variant::Variant(HPHP::Variant const&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/type-variant.h:890
#1  HPHP::createBacktrace(HPHP::BacktraceArgs const&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/backtrace.cpp:240
#2  HPHP::ExtendedException::computeBacktrace(bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/exceptions.cpp:72
#3  HPHP::ExtendedException::ExtendedException(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/exceptions.cpp:35
#4  HPHP::ExecutionContext::handleError(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool, HPHP::ExecutionContext::ErrorThrowMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/execution-context.cpp:671
#5  HPHP::raise_message(HPHP::ErrorConstants::ErrorModes, bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/runtime-error.cpp:287
#6  HPHP::raise_strict_warning(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/runtime-error.cpp:99
#7  HPHP::TimeZone::CurrentName() at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/timezone.cpp:141
#8  HPHP::TimeZone::Current() at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/timezone.cpp:145
#9  HPHP::DateTime::fromTimeStamp(long, bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/datetime.cpp:286
#10 HPHP::DateTime::DateTime(long, bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/datetime.cpp:275
#11 HPHP::f_date(HPHP::String const&, long) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/ext/ext_datetime.cpp:575
#12 HPHP::fg_date(HPHP::ActRec*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/ext_hhvm/../ext/CMakeFiles/hphp_runtime_ext.dir/ext_datetime.cpp.o.ext_hhvm.cpp:1492
#13 HPHP::ExecutionContext::iopNativeImpl(unsigned char const*&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:6883
#14 void HPHP::ExecutionContext::dispatchImpl<false>() at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:7518
#15 HPHP::ExecutionContext::dispatch() at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:7525
#16 HPHP::ExecutionContext::enterVMAtFunc(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:1873
#17 HPHP::ExecutionContext::enterVM(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState, HPHP::Resumable*, HPHP::ObjectData*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:1927
#18 HPHP::ExecutionContext::invokeFunc(HPHP::TypedValue*, HPHP::Func const*, HPHP::Variant const&, HPHP::ObjectData*, HPHP::Class*, HPHP::VarEnv*, HPHP::StringData*, HPHP::ExecutionContext::InvokeFlags) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:2094
#19 HPHP::vm_call_user_func(HPHP::Variant const&, HPHP::Variant const&, bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/builtin-functions.cpp:358
#20 HPHP::f_call_user_func(int, HPHP::Variant const&, HPHP::Array const&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/ext/ext_function.cpp:137
#21 HPHP::fg_call_user_func(HPHP::ActRec*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/ext_hhvm/../ext/CMakeFiles/hphp_runtime_ext.dir/ext_function.cpp.o.ext_hhvm.cpp:167
#22 HPHP::ExecutionContext::iopNativeImpl(unsigned char const*&) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:6883
#23 void HPHP::ExecutionContext::dispatchImpl<false>() at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:7518
#24 HPHP::ExecutionContext::dispatch() at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:7525
#25 HPHP::ExecutionContext::enterVMAtFunc(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:1873
#26 HPHP::ExecutionContext::enterVM(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState, HPHP::Resumable*, HPHP::ObjectData*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:1927
#27 HPHP::ExecutionContext::invokeFunc(HPHP::TypedValue*, HPHP::Func const*, HPHP::Variant const&, HPHP::ObjectData*, HPHP::Class*, HPHP::VarEnv*, HPHP::StringData*, HPHP::ExecutionContext::InvokeFlags) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:2094
#28 HPHP::ExecutionContext::invokeUnit(HPHP::TypedValue*, HPHP::Unit const*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/vm/bytecode.cpp:2275
#29 HPHP::invoke_file_impl(HPHP::Variant&, HPHP::String const&, bool, char const*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/builtin-functions.cpp:723
#30 HPHP::invoke_file(HPHP::String const&, bool, char const*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/builtin-functions.cpp:734
#31 HPHP::include_impl_invoke(HPHP::String const&, bool, char const*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/builtin-functions.cpp:745
#32 HPHP::hphp_invoke(HPHP::ExecutionContext*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, HPHP::Array const&, HPHP::VRefParamValue const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, bool, bool, bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/base/program-functions.cpp:1792
#33 HPHP::HttpRequestHandler::executePHPRequest(HPHP::Transport*, HPHP::RequestURI&, HPHP::SourceRootInfo&, bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/server/http-request-handler.cpp:399
#34 HPHP::HttpRequestHandler::handleRequestImpl(HPHP::Transport*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/server/http-request-handler.cpp:292
#35 HPHP::HttpRequestHandler::handleRequest(HPHP::Transport*) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/server/http-request-handler.cpp:338
#36 HPHP::ServerWorker<std::shared_ptr<HPHP::FastCGIJob>, HPHP::FastCGITransportTraits>::doJobImpl(std::shared_ptr<HPHP::FastCGIJob>, bool) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/server/server-worker.h:104
#37 HPHP::ServerWorker<std::shared_ptr<HPHP::FastCGIJob>, HPHP::FastCGITransportTraits>::doJob(std::shared_ptr<HPHP::FastCGIJob>) at /tmp/tmp.QFEsUSa1Xe/hphp/runtime/server/server-worker.h:57
#38 HPHP::JobQueueWorker<std::shared_ptr<HPHP::FastCGIJob>, HPHP::Server*, true, false, HPHP::JobQueueDropVMStack>::start() at /tmp/tmp.QFEsUSa1Xe/hphp/util/job-queue.h:461
#39 HPHP::AsyncFunc<HPHP::ServerWorker<std::shared_ptr<HPHP::FastCGIJob>, HPHP::FastCGITransportTraits> >::run_(void*) at /tmp/tmp.QFEsUSa1Xe/hphp/util/async-func.h:206
#40 HPHP::AsyncFuncImpl::threadFuncImpl() at /tmp/tmp.QFEsUSa1Xe/hphp/util/async-func.cpp:140
#41 HPHP::AsyncFuncImpl::ThreadFunc(void*) at /tmp/tmp.QFEsUSa1Xe/hphp/util/async-func.cpp:52
#42 start_thread at /lib/x86_64-linux-gnu/libpthread.so.0:0
#43 __clone at /lib/x86_64-linux-gnu/libc.so.6:0

Lemme know if you need any more info (I'd be surprised if you don't… o.o)

BenjaminNolan avatar Sep 30 '14 07:09 BenjaminNolan

If you could find a small example that consistently crashes that would be helpful, but I'll see if I can dig into this.

paulbiss avatar Sep 30 '14 19:09 paulbiss

Don't know if this is related, but I just got a seemingly random segfault on a production server running HHVM at work (the crashes I reported above were on one of my own web servers).

Host: cumberbatch.domain.com
ProcessID: 9356
ThreadID: 7f8192fff700
ThreadPID: 11094
Name: unknown program
Type: Segmentation fault
Runtime: hhvm
Version: tags/HHVM-3.3.0-0-g0a3cfb87b8a353fc7e1d15374f4adc413e37aba9
DebuggerCount: 0

ThreadType: Web Request
Server_SERVER_NAME: api.CLIENT.domain.com
Server: api.CLIENT.domain.com
URL: /api/1.0/auth

# 0  HPHP::init_closure(HPHP::ActRec*, HPHP::TypedValue*) at /usr/bin/hhvm:0
# 1  HPHP::ExecutionContext::prepareFuncEntry(HPHP::ActRec*, unsigned char const*&, HPHP::ExecutionContext::StackArgsState) at /usr/bin/hhvm:0
# 2  HPHP::ExecutionContext::enterVMAtFunc(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState) at /usr/bin/hhvm:0
# 3  HPHP::ExecutionContext::enterVM(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState, HPHP::Resumable*, HPHP::ObjectData*) at /usr/bin/hhvm:0
# 4  HPHP::ExecutionContext::invokeFunc(HPHP::TypedValue*, HPHP::Func const*, HPHP::Variant const&, HPHP::ObjectData*, HPHP::Class*, HPHP::VarEnv*, HPHP::StringData*, HPHP::ExecutionContext::InvokeFlags) at /usr/bin/hhvm:0
# 5  HPHP::vm_call_user_func(HPHP::Variant const&, HPHP::Variant const&, bool) at /usr/bin/hhvm:0
# 6  HPHP::f_call_user_func(int, HPHP::Variant const&, HPHP::Array const&) at /usr/bin/hhvm:0
# 7  HPHP::fg_call_user_func(HPHP::ActRec*) at /usr/bin/hhvm:0
# 8  HPHP::jit::x64::BackEnd::enterTCHelper(unsigned char*, HPHP::jit::TReqInfo&) at /usr/bin/hhvm:0
# 9  HPHP::jit::MCGenerator::enterTC(unsigned char*, void*) at /usr/bin/hhvm:0
# 10 HPHP::ExecutionContext::enterVM(HPHP::ActRec*, HPHP::ExecutionContext::StackArgsState, HPHP::Resumable*, HPHP::ObjectData*) at /usr/bin/hhvm:0
# 11 HPHP::ExecutionContext::invokeFunc(HPHP::TypedValue*, HPHP::Func const*, HPHP::Variant const&, HPHP::ObjectData*, HPHP::Class*, HPHP::VarEnv*, HPHP::StringData*, HPHP::ExecutionContext::InvokeFlags) at /usr/bin/hhvm:0
# 12 HPHP::vm_call_user_func(HPHP::Variant const&, HPHP::Variant const&, bool) at /usr/bin/hhvm:0
# 13 HPHP::f_call_user_func(int, HPHP::Variant const&, HPHP::Array const&) at /usr/bin/hhvm:0
# 14 HPHP::fg_call_user_func(HPHP::ActRec*) at /usr/bin/hhvm:0

PHP Stacktrace:

#0  call_user_func(, ) called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:478]
#1  Zend\EventManager\EventManager->triggerListeners(renderer, , ) called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207]
#2  Zend\EventManager\EventManager->trigger(renderer, , ) called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/View/View.php:175]
#3  Zend\View\View->render() called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/Mvc/View/Http/DefaultRenderingStrategy.php:102]
#4  Zend\Mvc\View\Http\DefaultRenderingStrategy->render()
#5  call_user_func(Array, ) called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468]
#6  Zend\EventManager\EventManager->triggerListeners(render, , Array) called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207]
#7  Zend\EventManager\EventManager->trigger(render, ) called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:352]
#8  Zend\Mvc\Application->completeRequest() called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:327]
#9  Zend\Mvc\Application->run() called at [/www/vhosts/api.CLIENT.domain.com/api/1.0/public/index.php:21]

Unfortunately, as it's a production server, I can't switch to hhvm-dbg to see if it does it again with a more useful stack trace as this would impact performance too much. :/

BenjaminNolan avatar Oct 15 '14 11:10 BenjaminNolan

I believe this is fixed by 9f9bd15e8deb486a2bf503305ea4b0d3aa91a6d1. The two stack traces in the original post as well as the gist that was added all have the same/similar top of the stack: raise_notice/raise_strict_warning indirectly calls create_backtrace. I looked around the code at the point of the seg fault looking for how maybe a null pointer got in there, and I discovered @AlphaStream just committed a check for null.

@TwoWholeWorms, please try hhvm-nightly-dbg and hopefully you can no longer reproduce the problem. Also, I believe the stacktrace you posted most recently is a different problem. The top of the stack is different.

aingram avatar Nov 01 '14 20:11 aingram

@TwoWholeWorms please try @aingram's suggestion and re-open if the issue persists. I'm closing for now as there has been no activity.

paulbiss avatar Nov 21 '14 21:11 paulbiss