Fix a bug with properties initialized to __DIR__ or __FILE__

Reported on freenode by nelt.  The deepInitHelper code
assumes the result of any deep-initialized property is reference
counted.  Since we recently changed opcodes that push static strings
to push KindOfStaticString, this means in the interpreter we'd hit an
assertion here.  (The JIT was unaffected, and neither case does
anything wrong in an opt build.)

Reviewed By: @paroski

Differential Revision: D1144110
Esse commit está contido em:
Jordan DeLong
2014-01-25 20:11:37 -08:00
commit de Sara Golemon
commit a8956cf943
3 arquivos alterados com 18 adições e 4 exclusões
+12 -4
Ver Arquivo
@@ -3505,14 +3505,22 @@ OPTBLD_INLINE void VMExecutionContext::iopFalse(IOP_ARGS) {
OPTBLD_INLINE void VMExecutionContext::iopFile(IOP_ARGS) {
NEXT();
const StringData* s = m_fp->m_func->unit()->filepath();
m_stack.pushStaticString(const_cast<StringData*>(s));
auto const s = m_fp->m_func->unit()->filepath();
assert(s->isStatic());
// iopDir and iopFile can both be used from 86pinit for deep
// property initializers. That code path assumes the result of
// property initialization is a reference counted type, so we need
// to push KindOfString instead of KindOfStaticString.
m_stack.pushStringNoRc(const_cast<StringData*>(s));
}
OPTBLD_INLINE void VMExecutionContext::iopDir(IOP_ARGS) {
NEXT();
const StringData* s = m_fp->m_func->unit()->dirpath();
m_stack.pushStaticString(const_cast<StringData*>(s));
auto const s = m_fp->m_func->unit()->dirpath();
// See iopFile for why this isn't pushStaticString.
assert(s->isStatic());
m_stack.pushStringNoRc(const_cast<StringData*>(s));
}
OPTBLD_INLINE void VMExecutionContext::iopInt(IOP_ARGS) {
@@ -0,0 +1,5 @@
<?php
class X { protected $x = __DIR__; }; new X;
class Y { protected $y = __FILE__; }; new Y;
echo "ok\n";
@@ -0,0 +1 @@
ok