Confusing segfault when trying to use mojo from a test suite that doesn't initialize EDK |
||||
Issue description1. Create a new unit test that uses mojo in a test binary that didn't already have any unit tests. 2. Spend a lot of time trying to figure out why you get a segfault like this: Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () (gdb) bt #0 0x0000000000000000 in ?? () #1 0x00000000004ba407 in mojo::CreateMessagePipe(MojoCreateMessagePipeOptions const*, mojo::ScopedHandleBase<mojo::MessagePipeHandle>*, mojo::ScopedHandleBase<mojo::MessagePipeHandle>*) () #2 0x00000000004ba177 in mojo::MessagePipe::MessagePipe() () #3 0x00000000004ba00c in mojo::Binding<ui::mojom::UserActivityMonitor, mojo::RawPtrImplRefTraits<ui::mojom::UserActivityMonitor> >::Bind(mojo::InterfacePtr<ui::mojom::UserActivityMonitor>*, scoped_refptr<base::SingleThreadTaskRunner>) () #4 0x00000000004b93a3 in aura::UserActivityForwarderTest::SetUp() () #5 0x000000000057a828 in testing::Test::Run() () #6 0x000000000057b5b0 in testing::TestInfo::Run() () #7 0x000000000057ba47 in testing::TestCase::Run() () #8 0x0000000000582a87 in testing::internal::UnitTestImpl::RunAllTests() () #9 0x000000000058269a in testing::UnitTest::Run() () #10 0x000000000055e9f1 in base::TestSuite::Run() () #11 0x000000000055fd9e in base::(anonymous namespace)::LaunchUnitTestsInternal(base::Callback<int (), (base::internal::CopyMode)1, (base::internal::RepeatMode)1> const&, int, int, bool, base::Callback<void (), (base::internal::CopyMode)1, (base::internal::RepeatMode)1> con st&) () #12 0x000000000055fc24 in base::LaunchUnitTests(int, char**, base::Callback<int (), (base::internal::CopyMode)1, (base::internal::RepeatMode)1> const&) () #13 0x00000000004dddaa in main () 3. Finally realize that you need to make the test target depend on "//mojo/edk/system" and add a call to mojo::edk::Init() just before base::LaunchUnitTests() in the test binary's main() function. --- Is there some way we can make the cause of this failure (the mojo EDK being uninitialized, presumably) more obvious? I spent a lot of time digging through various CreateMessagePipe functions, thunks, etc. before I finally realized what was going on. The strategic addition of a debug-only call to a function named something like CheckEdkInitialized() would've been a huge help.
,
Jan 19 2017
> 3. Finally realize that you need to make the test target depend on > "//mojo/edk/system" and add a call to mojo::edk::Init() just before > base::LaunchUnitTests() in the test binary's main() function. Alternatively, add dependency on //mojo/edk/test:run_all_unittests to use the test-runner that already initializes mojo as needed.
,
Jan 19 2017
> Alternatively, add dependency on //mojo/edk/test:run_all_unittests > to use the test-runner that already initializes mojo as needed. That only works if the existing test suite isn't already doing any initialization of its own, right? mojo/edk/test/run_all_unittests.cc looks like it provides main().
,
Jan 19 2017
That is correct, yes.
,
Oct 17
,
Nov 15
Random triage, low-hanging fruit
,
Nov 15
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/04708acfc91c7572318793a878d8954b2237c9aa commit 04708acfc91c7572318793a878d8954b2237c9aa Author: Ken Rockot <rockot@google.com> Date: Thu Nov 15 21:19:59 2018 [mojo] Make failure to init more obvious Currently when you try using Mojo without first initializing it properly, you get an error message about the function not being supported in "this version" of Mojo Core. This is marginally better than a cryptic crash stack, but still misleading. This CL detects when a missing function is due to a lack of Mojo initialization and reports it as such. Bug: 682732 Change-Id: Ia3f057171f2387a0387a7547a1a55fcc413cf7c0 Reviewed-on: https://chromium-review.googlesource.com/c/1337813 Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org> Commit-Queue: Ken Rockot <rockot@google.com> Cr-Commit-Position: refs/heads/master@{#608503} [modify] https://crrev.com/04708acfc91c7572318793a878d8954b2237c9aa/mojo/public/c/system/thunks.cc
,
Nov 15
|
||||
►
Sign in to add a comment |
||||
Comment 1 by jamescook@chromium.org
, Jan 19 2017