Debugging hhvm segmentation faults - hhvm

How can I debug a segmentation fault when running php script with hhvm? When I run it, I get:
Core dumped: Segmentation fault
Segmentation fault
In stacktrace I get that it error when I call a method of the same object.
Is there any code analyzer that might tell me wrong php code or somehow to get more verbose on errors or stack trace?
When I use
$r = mysql_query($sql, $link); //crashes
$r = mysql_query($sql); //does not crash

Debug build
To get a better understanding of the crash, you need to build HHVM for debug.
This can be done by adding -DCMAKE_BUILD_TYPE=Debug to your cmake.
More info can be found here:
https://github.com/facebook/hhvm/wiki/Reporting-Crashes
Stack trace
You may also find a trace named stacktrace.[number].log in the /tmp directory.
If after inspecting the stack trace you realise that the bug is not on your side, it is best to submit a new issue here:
https://github.com/facebook/hhvm/issues
Better logging
Once the issue is not a seg fault, you can get more out of your logging.
Here is how my hhvm.hdf log section looks like.

Related

Getting Thread.callStackSymbols from release version give me weird stack trace

In my project, I send logs to my server when an error happens (not a crash, only an error). These logs are an error description and the stack trace that should give me information about where and when the error happens. I'm getting the stack trace using
Thread.callStackSymbols
And it works very well when I'm using it on my device from Xcode, but I'm receiving stack traces on my server from release versions of my app that don't make sense.
I tested it forcing an error in a class named X and sending the stack trace of this error to my server. Running locally directly from the Xcode, the stack trace shows class X as expected. But when I built my release version to use as my users, the stack trace that I received in my server doesn't mention class X (where the error happens).
I'm using the dSYM files generated and all the necessary things to symbolicate my stack trace, but it still does not work. I also saw my DEBUG_INFORMATION_FORMAT and it is DWARF with dSYM file which seems right to me.
What am I missing? I read somewhere that maybe Thread.callStackSymbols don't be reliable on the device side in the release version. Is there another way to get the stack trace to send to my server?
I think I understand the problem:
Thread.callStackSymbols symbolicates the address automatically on the device, but it probably does not work because symbols are removed from release versions. To fix this problem, I based my code on the NSProgrammer's answer
Now, I'm sending Thread.callStackReturnAddresses (you need to translate these addresses to hex values) and the load address to my server. I got the load address using _dyld_get_image_header. It's important to notice that, if you want to get the load address of a specific framework, you need to check like this
for i in 0..<_dyld_image_count() {
guard let address = _dyld_get_image_header(i),
let name = String(validatingUTF8: _dyld_get_image_name(i)) else {
continue
}
if name.contains(FRAMEWORK_NAME) {
// send address to the server
}
}
With the stack address and the load address in your server, you can get the dSYM file and use atos like
atos -arch arm64 -o <PathToDSYMFile>/Contents/Resources/DWARF/<BinaryName> -l <LoadAddress> <AddressesToSymbolicate>
Some addresses probably won't be symbolicated because they refer to other libs like system libs, but the correct addresses will work fine!

!ClrStack -a call in ASP.NET MVC application shows <NO DATA>

When attaching WinDbg to my ASP.NET MVC app and calling !ClrStack -a when an exception has occurred, I'm seeing no locals or params values. All I see is <NO DATA> appear.
Why is this happening? What settings in my project can I check?
I appreciate I can see the objects in quesiton via a !dso call and finding the objects I'm interesting in the output, but that's not a good solution for me, since I need to know exactly the objects being passed into a specific function - I don't want to spend ages picking eah object address and doing a !do on them.
The app is built in DEBUG mode. When viewing a stack, all the methods and types appear in the output, so I'm assuming there is no issue with symbols, though I'm willing to try any commands necessary to re-sync or update the symbols if required.
The CPU architecture is ANY CPU and we are running Windows Server 2008 R2 64-bit.
I tried using SOSEX's !mk !mframe and !mdv commands, to list param and locals, but they show <UNAVAILABLE>.
EDIT:
Here is an example of the type of output I'm seeing:
Why does this happen?
This happens for code optimized by the JIT compiler (your case) or release builds (by the compiler).
What settings in my project can I check?
Always check the symbol path and add Microsoft symbols if not done yet.
.symfix c:\debug\symbols
.reload
Next, check if WinDbg can find the symbols of your application using lm. It should show "private pdb symbols". If not, run
.sympath+ <path to your PDBs>
Other than that, SOSEX makes your life easier. Try the following:
!mk; *** Managed stack
!mframe <frame>; *** Switch to frame
!mdv; *** Dump values - This will at least give you the type
!mdv <frame>; *** Same as before but include !mframe
!mdso; *** Similar to !dso

ActionScript Get crash call stack on iOS

I am using Adobe Air3.4 to develop an app on iOS. However, I met a crash only on release version and this crash doesn't happen on debug version. But I cannot get any crash info such as callstack from iOS. Do you have any method to deal with this kind of problem?
You can wrap the offending code in a try/catch statement. Inside the catch code block, you get an Error object that you can use to get the stack trace:
try
{
// some code that throws an exception
}
catch (e:Error)
{
trace(e.getStackTrace())
}
If you don't know which code is causing the error, and thus where to add the try/catch statement, you might have some luck with the UncaughtErrorEvent -- refer to the examples found at the bottom of the documentation for UncaughtErrorEvent that I linked to.
In fact, if you just want a stack trace in general, create a new Error object and use its getStackTrace() method anywhere in your code.
In addition to checking for errors as above, you should check the crash logs on your device to see if that provides any additional details.

"<Program> has stopped working" explanation

Can someone explain me when Windows shows this message?
What do i have to do to stop my Program from throwing this exception?
I have a Delphi Windows Forms Program which throws this message short after doing some SQL operations.
So i do the SQL, everything seems fine at first, but at a random time after that windows is killing it by showing this message...
the intresting thing is, it only occours while debugging.
When i'm not debugging it's running perfectly stable.
EDIT: Using RAD-Studio2009
I dont want to turn off the message completely(Only hint i found by using Google)
i want to stop my program giving windows a Reason to do that.
Windows shows this message when an unhandled exception leaks out of your application. This is a fatal condition. Something very wrong has happened with your application because exceptions should all be caught.
You need to work out what is throwing the exception and why it is not being caught. The very first step is to expand the details of the error dialog and find out which module the fault is occurring in, what the fault is and so on. That should yield some high level clues at the very least.
Most likely the Delphi debugger will not be able to help you for such a fault. You need to configure your system to arrange for a crash dump to be produced by the Windows Error Reporting service. Then you can load up the error report in a tool like WinDbg and try to figure it out.

How to determining why an Erlang application is not starting?

I'm trying to start an Erlang app that is failing. All I see in the shell is:
=INFO REPORT==== 7-Jan-2010::17:37:42 ===
application: ui
exited: {shutdown,{ui_app,start,[normal,[]]}}
type: temporary
How can I get Erlang to give me more information as to why the application is not starting? There currently is no other output in the shell.
You could try launching the shell with more logging support:
erl -boot start_sasl
this might get give a bit more details.
There is a patch (tp/supervisor-pass-on-errors) that was included in release R16B. This patch makes exit reasons appear in application stop log messages, which thus become much more useful than the {shutdown,{ui_app,start,[normal,[]]}}-style messages we've had until now.
This is the entry in the README:
OTP-10490 == stdlib ==
If a child process fails in its start function, then the
error reason was earlier only reported as an error report
from the error_handler, and supervisor:start_link would only
return {error,shutdown}. This has been changed so the
supervisor will now return {error,{shutdown,Reason}}, where
Reason identifies the failing child and its error reason.
(Thanks to Tomas Pihl)
It is a pain, but the way I do it is the old fashioned way, by writing io:format's into the start function of the application (ie the code of the module with the behaviour of application) and working out which line fails :(
Sometimes brute force and ignorance is your only man...

Resources