Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to run benchmark #1

Closed
leitao opened this issue Jun 17, 2015 · 3 comments
Closed

Failing to run benchmark #1

leitao opened this issue Jun 17, 2015 · 3 comments

Comments

@leitao
Copy link

leitao commented Jun 17, 2015

Currently hhvm for ppc64le (interpreted mode) is segfaulting to run the following benchmark:

http://www.php-benchmark-script.com/bench.zip

With the following error:

--------------------------------------
## |        PHP BENCHMARK SCRIPT        |

Start : 2015-06-17 13:12:49
Server : @
PHP version : 5.6.99-hhvm
## Platform : Linux

Core dumped: Segmentation fault
Stack trace in /tmp/stacktrace.16025.log
Segmentation fault (core dumped)
$ cat /tmp/stacktrace.16025.log

PHP Stacktrace:
#0  test_IfElse() called at [/home/ubuntu/hhvm/hhvm/hphp/hhvm/scrp/bench.php:74]
@leitao
Copy link
Author

leitao commented Jun 17, 2015

The stack trace is the following:

#0 0x000000001067b9c4 in HPHP::string_number_format(double, int, HPHP::String const&, HPHP::String const&) ()
#1 0x0000000011784da8 in HPHP::f_number_format(double, int, HPHP::Variant const&, HPHP::Variant const&) ()
#2 0x0000000012e87f84 in HPHP::Native::callFuncInt64Impl(HPHP::TypedValue* ()(HPHP::ActRec), long_, int, double_, int) ()
#3 0x0000000010c14664 in void HPHP::Native::callFunc<true, false>(HPHP::Func const_, void_, HPHP::TypedValue_, int, HPHP::TypedValue&) ()
#4 0x0000000010e04380 in unsigned char_ HPHP::dispatchImpl() ()
#5 0x0000000010e09290 in HPHP::enterVM(HPHP::ActRec_, HPHP::StackArgsState, HPHP::Resumable_, HPHP::ObjectData_, HPHP::VarEnv_) ()
#6 0x0000000012df6de4 in HPHP::ExecutionContext::invokeFunc(HPHP::TypedValue_, HPHP::Func const_, HPHP::Variant const&, HPHP::ObjectData_, HPHP::Class_, HPHP::VarEnv_, HPHP::StringData_, HPHP::ExecutionContext::InvokeFlags) ()
#7 0x0000000012e5f5a0 in HPHP::ExecutionContext::invokeUnit(HPHP::TypedValue_, HPHP::Unit const_) ()
#8 0x000000001094dbb8 in HPHP::include_impl_invoke(HPHP::String const&, bool, char const_) ()
#9 0x00000000105fa614 in HPHP::hphp_invoke(HPHP::ExecutionContext_, std::string const&, bool, HPHP::Array const&, HPHP::VRefParamValue const&, std::string const&, std::string const&, bool&, std::string&, bool, bool, bool) ()
#10 0x00000000105fae74 in HPHP::hphp_invoke_simple(std::string const&, bool) ()
#11 0x000000001061e7d8 in HPHP::execute_program_impl(int, char**) ()
#12 0x00000000106219dc in HPHP::execute_program(int, char**) ()
#13 0x00000000105b53a0 in main ()

@lbianc
Copy link

lbianc commented Jun 29, 2015

Hi @leitao!

We have identified the problem and we just sent the fix.
We have disabled the SIMD support, since the port is in the beginning and some architecture specific code will be necessary for that. This solves the Segmentation Fault issue, but we are still analysing it, since there is no archictecture specific code around it.

The problem happens on a function cast for different type of data, at hphp/runtime/vm/native-func-caller.h:839. On that line there is a function call cast objects to int64_t, what is not working for PPC64.

We are still analysing this issue, but for now, the last couple of commits solves the problem.

Fell free to check it.

Thanks!

@lbianc lbianc closed this as completed Jun 29, 2015
@leitao
Copy link
Author

leitao commented Jun 29, 2015

Nice, let me try!

On Mon, Jun 29, 2015 at 4:24 PM, lbianc notifications@github.com wrote:

Closed #1 #1.


Reply to this email directly or view it on GitHub
#1 (comment).

lbianc pushed a commit that referenced this issue Jul 28, 2015
…imezone to UTC

Summary: Without this change, the following code:

    c_dt = HPHP::Unit::lookupClass(HPHP::s_DateTime.get());
    assert(c_dt);
    HPHP::ObjectData* obj = HPHP::ObjectData::newInstance(c_dt);

    DateTimeData* data = Native::data<DateTimeData>(obj);
    data->m_dt = makeSmartPtr<DateTime>(0, false);
    data->m_dt->fromTimeStamp(milliseconds / 1000, true);

Would cause issues when var_dumping the returned object. var_dump would call
debugInfo on the object, which in turns tries to use zone_type_to_string, which
has an assertion if it can't find the type. With the above example, the zone
type would be false, and we'd get this assertion:

    Program received signal SIGABRT, Aborted.
    0x00007fffeeae5107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
    56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    (gdb) bt
    #0  0x00007fffeeae5107 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
    #1  0x00007fffeeae64e
Closes facebook#5547

Reviewed By: @sgolemon

Differential Revision: D2197285
lbianc pushed a commit that referenced this issue Jul 28, 2015
Summary: In a switch statement with a fallthrough we would use the same environemnt
for the next case we encounter. However this is incorrect. Consider the
following case.

```
$x = 0; // int
switch (0) {
  case 1:
    $x = '';
    // FALLTHROUGH
  case 2:
    $x; // <-- #1
}

$x; // <-- #2
```

Currently at position #1 we will think $x is a string, since that is what we
assigned $x to be in the above case. However we could have switched directly
into case 2 without a fallthrough at which point $x would be an int.

This bug also impacts the result outside the switch statement. Because we
believe $x is of type string in both branches we believe $x is a string at
position #2 as well.

The solution is to intersect the local environment before and after type
checking the block in case 1. This intersected local environment is what should
be passed as the environment for case 2.

Reviewed By: @jwatzman, @int3

Differential Revision: D2230208
lbianc pushed a commit that referenced this issue Dec 10, 2015
Summary:
1. Avoid putting logic into the entry point; it should just be a thin wrapper
   around the underlying function
2. Once #1 is done, there's no need to pass the entry points around as
   arguments
3. Also avoid passing around log_mode as a separate arg; it can be computed
   easily from the options record

Reviewed By: achow

Differential Revision: D2722256

fb-gh-sync-id: 4655f7049c828a605c1a50c0026e5fd42aca971f
racardoso pushed a commit that referenced this issue Mar 30, 2017
Summary:
This diff models typing for optional shape fields.

= Model

These fields are modeled as follows:

```name=typing_defs.ml,lang=ocaml
'phase shape_field_type = {
  sft_optional : bool;
  sft_ty : 'phase ty;
}
```

And integrated into the existing type structure as follows:

```name=typing_defs.ml,lang=diff
ty_ = (* ...existing types... *)
  | Tshape :
      shape_fields_known *
-     ('phase ty Nast.ShapeMap.t)
+     ('phase shape_field_type Nast.ShapeMap.t)
      -> 'phase ty_
```

= Justification

There were two reasonable ways of modeling optional shape fields:

  # `Tshape` remains unchanged, and a new toplevel type `Toptional_shape_field` is introduced.
  # `Tshape` is changed to hold `shape_field_type`s that explicitly denote whether they are optional or not.

I have opted for #2.

Choice #1 has these trade-offs:

  # (good) The shape handling code remains unchanged.
  # (ok/good) `Tshape` is symmetric in a sense, and does not need additional handling logic. Handling logic can be placed closer to where toplevel processing for `ty` appears.
  # (bad) **Everywhere** that a `ty` is processed, a new case has to be added to handle the optional shape field. In most of these cases, optional shape fields are not even logically possible!
  # (extremely bad) There is special casing logic that needs to be written for optional shape fields, and this logic must be done **in the context of a `Tshape`**. This design would break the abstraction, forcing us to push through `Tshape` information to the toplevel processing for `ty`.

Choice #2 has these trade-offs:

  # (good) An `shape_field_type` may //only// appear in the context of a `Tshape`. We will never process an `shape_field_type` in a place where it's not logically possible. Consequently, the processing always has visibility to the `Tshape` of which the `shape_field_type` is a part of.
  # (good) This design forces the developer to handle processing for `shape_field_type`s when processing a `Tshape`. It will be very hard to "forget" to handle this case, since it will be enforced by the type system.
  # (bad) It turns out there are lots of places that don't care about whether a type is optional or not. These points in the code now have to be filled with boilerplate to unwrap the `ty` from the `shape_field_type`.

= Conclusion

Whereas #1 has serious logic and maintainability concerns, #2 really just has concerns related to code cleanliness. Additionally, to handle those code cleanliness concerns, I created the `typing_helpers` library to handle patterns that occurred repeatedly in this diff.

= Other notes

There are lots of locations in this diff where I'm not completely sure what's going on. Please let me know if there are any areas that look suspect. If things do in fact look off, it might be useful for us to go through some parts of the diff in person. Since the existing typecheck tests and the new ones for the optional shape fields all pass, I'm reasonably confident that there's not a regression, but I can't be sure.

Reviewed By: dlreeves

Differential Revision: D4563246

fbshipit-source-id: da8d446429351bf804c0485335c29ab83fd049da
racardoso pushed a commit that referenced this issue Apr 17, 2017
Summary:
If a branching instruction has the same block as the next and taken target,
load-elim will always choose the next state to merge into the successor. This
can cause problems if the instruction alters the tracked state and we later
simplify away the branch instruction.

Here's a somewhat constrived example to illustrate the problem:

```
B1:
   (1) t1:Str|InitNull = LdLoc<Str|InitNull,1>
   (2) t2:Str = CheckType<Str> t1:Str|InitNull B2, B2

B2:
   (3) t3:Str|InitNull = LdLoc<Str|InitNull,1>
   (4) DecRef t3:Str|InitNull
```

Load-elim will deduce at (2) that a load from local slot #1 can be substituted
with t2 (along the next branch). When it processes (3), it will choose the next
branch's state to merge. So, it will rewrite (3) to t2 and
copy-propagate. Obtaining:

```
B1:
   (1) t1:Str|InitNull = LdLoc<Str|InitNull,1>
   (2) t2:Str = CheckType<Str> t1:Str|InitNull B2, B2

B2:
   (4) DecRef t2:Str
```

However, the simplifier and DCE now kicks in and optimizes away (2) because both
of its branches jump to the same block, leaving us with just:

```
B1:
   (4) DecRef t2:Str
```

IE, we're dec-reffing a tmp that no longer has a definition.

The fix for all this is use the taken branch's state when an instruction has the
same block for next and taken. In the above example, the taken branch's state
won't include the subsitution rule, so we won't copy propagate t2 before
eliminating it.

Reviewed By: markw65

Differential Revision: D4870758

fbshipit-source-id: 12f3311b63c1be58cb3ba36dd62228c95446ef76
lbianc pushed a commit that referenced this issue Sep 26, 2017
Summary:
Reported by UBSAN:
```lang=bash
001+ hphp/runtime/debugger/debugger_client.cpp:2515:7: runtime error: load of value 190, which is not a valid value for type 'bool'
002+     #0 0xa04d7ed in HPHP::Eval::DebuggerClient::saveConfig() hphp/runtime/debugger/debugger_client.cpp:2515
003+     #1 0xa02b046 in HPHP::Eval::DebuggerClient::setDebuggerClientSmallStep(bool const&) hphp/runtime/debugger/debugger_client.h:352
004+     #2 0xa02b046 in HPHP::Eval::DebuggerClient::loadConfig() hphp/runtime/debugger/debugger_client.cpp:2391
005+     #3 0xa02995f in HPHP::Eval::DebuggerClient::init(HPHP::Eval::DebuggerClientOptions const&) hphp/runtime/debugger/debugger_client.cpp:750
006+     #4 0xa015d01 in HPHP::Eval::DebuggerClient::start(HPHP::Eval::DebuggerClientOptions const&) hphp/runtime/debugger/debugger_client.cpp:783
007+     #5 0xa015d01 in HPHP::Eval::DebuggerClient::Start(HPHP::Eval::DebuggerClientOptions const&) hphp/runtime/debugger/debugger_client.cpp:399
008+     #6 0x9fe833b in HPHP::Eval::Debugger::StartClient(HPHP::Eval::DebuggerClientOptions const&) hphp/runtime/debugger/debugger.cpp:56
009+     #7 0x884b41f in HPHP::execute_program_impl(int, char**) hphp/runtime/base/program-functions.cpp:1929
010+     #8 0x883d586 in HPHP::execute_program(int, char**) hphp/runtime/base/program-functions.cpp:1200
011+     #9 0x72782e in main hphp/hhvm/main.cpp:85
012+     #10 0x7ffbeed1c857 in __libc_start_main /home/engshare/third-party2/glibc/2.23/src/glibc-2.23/csu/../csu/libc-start.c:289
013+     #11 0x724e28 in _start /home/engshare/third-party2/glibc/2.23/src/glibc-2.23/csu/../sysdeps/x86_64/start.S:118
015+ SUMMARY: UndefinedBehaviorSanitizer: invalid-bool-load hphp/runtime/debugger/debugger_client.cpp:2515:7 in

```

Reviewed By: markw65

Differential Revision: D5898634

fbshipit-source-id: 102f90ead9766b381a4dc722800ad6e7fb8a76be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants