From 3bb3b3df13c05121bf0113034e2c39a3de698704 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Thu, 13 Jun 2013 12:31:04 -0700 Subject: [PATCH] Fix ostensive bug in sorting debugger constants This was doing ref(foo), where foo is an Array. This will create a temporary Variant, call the ref(CVarRef) overload, which casts the temporary to a non-const RefResult, then a temporary VRefParam is implicitly constructed from this, which creates a KindOfRef and points the temporary variant at that. The sort will operate on this temporary (leading to copy on write, and storing the new ArrayData* there), so the m_constants field won't reflect the changes. --- hphp/runtime/debugger/cmd/cmd_constant.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hphp/runtime/debugger/cmd/cmd_constant.cpp b/hphp/runtime/debugger/cmd/cmd_constant.cpp index ce3b4f3e3..194af850c 100644 --- a/hphp/runtime/debugger/cmd/cmd_constant.cpp +++ b/hphp/runtime/debugger/cmd/cmd_constant.cpp @@ -65,8 +65,14 @@ void CmdConstant::onClientImpl(DebuggerClient &client) { } else { int i = 0; bool found = false; - m_constants = cmd->m_constants; - f_ksort(ref(m_constants)); + + { + Variant forSort(cmd->m_constants); + f_ksort(ref(forSort)); + assert(forSort.is(KindOfArray)); + m_constants = forSort.asCell()->m_data.parr; + } + for (ArrayIter iter(m_constants); iter; ++iter) { String name = iter.first().toString(); String value = DebuggerClient::FormatVariable(iter.second(), 200);