engine
engine copied to clipboard
Add Windows support for `//flutter/fml/backtrace.h`
This PR adds Windows support for //flutter/fml/backtrace.h
.
This PR fixes flutter/flutter#111614.
No changes in the flutter/tests repo.
Pre-launch Checklist
- [X] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [X] I read the Tree Hygiene wiki page, which explains my responsibilities.
- [X] I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
- [X] I listed at least one issue that this PR fixes in the description above.
- [X] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
- [ ] I updated/added relevant documentation (doc comments with
///
). - [X] I signed the CLA.
- [ ] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
@moko256 Thanks for implementing this, it looks great! ~~Have you verified that the CI output now contains a stack traces on Window? If no, perhaps consider creating a draft PR on the engine that contains these changes but then crashes in a test.~~~
EDIT: See below: https://github.com/flutter/engine/pull/36202#issuecomment-1251352816
Here's example output from CI backtrace (see https://github.com/flutter/engine/pull/36254):
[64/456] FlutterPlatformNodeDelegateTest.canGetAXNode (612 ms)
...
[----------] 1 test from FlutterPlatformNodeDelegateTest
[ RUN ] FlutterPlatformNodeDelegateTest.canGetAXNode
[ERROR:accessibility_bridge.cc(146)] Check failed: false.
[ERROR:flutter/fml/backtrace.cc(135)] Caught signal SIGABRT during program execution.
Frame 0: 0000000142DBBDB9 abort
Frame 1: 0000000142AF8819 base::KillProcess
Frame 2: 0000000142AF87EB base::LogMessage::~LogMessage
Frame 3: 000000014023935A flutter::AccessibilityBridge::OnNodeCreated
Frame 4: 0000000142A1D8D9 ui::AXTree::NotifyNodeHasBeenReparentedOrCreated
Frame 5: 0000000142A1B6CC ui::AXTree::Unserialize
Frame 6: 000000014023840D flutter::AccessibilityBridge::CommitUpdates
Frame 7: 00000001401C0669 flutter::testing::FlutterPlatformNodeDelegateTest_canGetAXNode_Test::TestBody
Frame 8: 0000000142C80080 testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,void>
Frame 9: 0000000142C62511 testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void>
Frame 10: 0000000142C4882F testing::Test::Run
Frame 11: 0000000142C49038 testing::TestInfo::Run
Frame 12: 0000000142C496AC testing::TestSuite::Run
Frame 13: 0000000142C53985 testing::internal::UnitTestImpl::RunAllTests
Frame 14: 0000000142C853C0 testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>
Frame 15: 0000000142C65171 testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>
Frame 16: 0000000142C53514 testing::UnitTest::Run
Frame 17: 000000014022CB41 RUN_ALL_TESTS
Frame 18: 000000014022C6C8 main
Frame 19: 0000000142D48FB4 invoke_main
Frame 20: 0000000142D48E9E __scrt_common_main_seh
Frame 21: 0000000142D48D5E __scrt_common_main
Frame 22: 0000000142D49049 mainCRTStartup
Frame 23: 00007FF86F127BD4 BaseThreadInitThunk
Frame 24: 00007FF86F2ECED1 RtlUserThreadStart
[64/456] FlutterPlatformNodeDelegateTest.canGetAXNode returned/aborted with exit code 3 (612 ms)
Looks great! 🎉
I am seeing the current master's behavior on host_linux_unopt, but many functions haven't symbolized.
I ran readelf -s -W out/host_debug_unopt/fml_unittests
, but it seems that only gtest and std's symbol are contained.
auto trace = BacktraceHere(0);
std::cout << trace << std::endl;
Frame 0: 0x55655013e0ec Unknown
Frame 1: 0x55655225eebb Unknown
Frame 2: 0x556552251a67 Unknown
Frame 3: 0x556552240eb3 testing::Test::Run()
Frame 4: 0x556552241574 testing::TestInfo::Run()
Frame 5: 0x556552241b7d testing::TestSuite::Run()
Frame 6: 0x55655224b321 testing::internal::UnitTestImpl::RunAllTests()
Frame 7: 0x55655226203b Unknown
Frame 8: 0x556552253457 Unknown
Frame 9: 0x55655224af1f testing::UnitTest::Run()
Frame 10: 0x5565502c61e1 Unknown
Frame 11: 0x5565502c60b2 Unknown
Frame 12: 0x7f442f1be09b __libc_start_main
Frame 13: 0x55655013ab6a _start
@moko256 can you try running with out/host_debug_unopt/exe.unstripped/fml_unittests
instead? The default Linux binaries under the build directory are stripped.
@cbracken I find it. Thanks.
I replaced signal handling with absl::InstallFailureSignalHandler
and added a death test to check it is installed. It also works on Windows.
Acoording to CI results, somehow on macOS ,the absl::GetStackTrace
writes no stacktrace and
absl::debugging_internal::StackTraceWorksForTest
returns false.
If absl::GetStackTrace
doesn't support on macOS, the absl's signal handler doesn't support as well.
It looks like the absil's source code contains the implementation using execinfo, and the ifdefs for macOS, but I can't investigate the actual reason right away. I'll revert the PR to the first commit, or defer to other people on investigation on macOS.
@cbracken @loic-sharma @chinmaygarde @dnfield From PR review triage: It looks like this PR is ready for another review pass.