Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@chinmaygarde
Copy link
Member

These should only be used on host binaries for more detailed crash reports. Installing the handler on targets (iOS/Android) may cause use to break existing crash reporting mechanisms users may have installed themselves in the process.

These should only be used on host binaries for more detailed crash reports. Installing the handler on targets (iOS/Android) may cause use to break existing crash reporting mechanisms users may have installed themselves in the process.
@chinmaygarde
Copy link
Member Author

chinmaygarde commented Aug 25, 2019

This should work on Darwin & Linux. I'll work on Windows next.

Doing something like int* a = nullptr; *a = 12; or abort or tripping an assertion should print something the following before program termination. We can tweak the report further if necessary.

[ERROR:flutter/fml/backtrace.cc(110)] Caught signal SIGSEGV during program execution.
Frame 0: 0x10658342c void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)
Frame 1: 0x106555070 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)
Frame 2: 0x106554f81 testing::Test::Run()
Frame 3: 0x106555dc3 testing::TestInfo::Run()
Frame 4: 0x1065570a1 testing::TestSuite::Run()
Frame 5: 0x106562a55 testing::internal::UnitTestImpl::RunAllTests()
Frame 6: 0x10658c22c bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)
Frame 7: 0x1065625c3 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)
Frame 8: 0x106562445 testing::UnitTest::Run()
Frame 9: 0x105c8dc33 RUN_ALL_TESTS()
Frame 10: 0x105c8dbe6 main
Frame 11: 0x7fff7c2dc3d5 start

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dnfield
Copy link
Contributor

dnfield commented Aug 25, 2019

Looks like you need to add the new files to the license golden file.

@dnfield
Copy link
Contributor

dnfield commented Aug 25, 2019

/cc @jonahwilliams @zanderso this may be interesting for the tool to capture or treat specially - this will be super helpful if we see crashes in flutter_tester due to e.g. a segfault. /cc also @GaryQian

@@ -0,0 +1,132 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use 2013 for all source files in the engine - keeps the license file in better shape.


int status = 0;
size_t length = 0;
char* demangled = __cxxabiv1::__cxa_demangle(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment made me realize that backtrace printing stuff is not signal safe at all. I am closing this and reworking this to only use signal safe routines.

static void ToggleSignalHandlers(bool set);

static void SignalHandler(int signal) {
// We are a crash signal handler. This can only happen once. Since we don't
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things to think about, but which don't necessarily need to be solved in this PR:

  • What (should) happen(s) here when a SIGSEGV was caused by a stack overflow?
  • What (should) happen(s) here when a SIGABRT was caused by malloc heap corruption?

// want to catch crashes while we are generating the crash reports, disable
// all set signal handlers to their default values before reporting the crash
// and re-raising the signal.
ToggleSignalHandlers(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this disable backtrace printing for all threads or only the calling thread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printing a backtrace and the signal handling are orthogonal. We will print the backtrace that caused this specific signal and re-raise it. Presumably, this will cause process termination. So there is nothing else to do on other threads.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ToggleSignalHandlers() only affects the calling thread, and two threads crash at the same time, then the backtrace output could be interleaved.

@@ -0,0 +1,20 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019?

@@ -0,0 +1,33 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019?

@chinmaygarde
Copy link
Member Author

chinmaygarde commented Aug 26, 2019

Closing because of signal unsafe-ness of the backtrace printing. Will rework it to be safe.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants