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

segfault on ARM #813

Closed
cppden opened this issue Jul 16, 2018 · 6 comments
Closed

segfault on ARM #813

cppden opened this issue Jul 16, 2018 · 6 comments

Comments

@cppden
Copy link

cppden commented Jul 16, 2018

Thanks guys for awesome lib but can you please also make it work on ARM CPUs?

Total Test time (real) = 1.32 sec

The following tests FAILED:
2 - gtest-extra-test (SEGFAULT)
4 - format-test (Child aborted)
6 - ostream-test (SEGFAULT)
7 - printf-test (SEGFAULT)
9 - util-test (SEGFAULT)
13 - posix-test (SEGFAULT)

*** [Makefile:120: test] Error 8

The results are produced in termux (Android):
$ cat /proc/cpuinfo
Processor : ARMv7 Processor rev 1 (v7l)
processor : 0
BogoMIPS : 38.40

processor : 1
BogoMIPS : 38.40

processor : 2
BogoMIPS : 38.40

processor : 3
BogoMIPS : 38.40

Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
CPU implementer : 0x51
CPU architecture: 7
CPU variant : 0x2
CPU part : 0x06f
CPU revision : 1

Hardware : Qualcomm MSM8974PRO-AC

@vitaut
Copy link
Contributor

vitaut commented Jul 16, 2018

What fmt version do you use and could you provide a stack trace of the segfault?

@cppden
Copy link
Author

cppden commented Jul 17, 2018

the latest from master.
Core was generated by `./printf-test'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0xb6cdaf58 in __gnu_Unwind_Resume () from /system/lib/libm.so
(gdb) bt
#0 0xb6cdaf58 in __gnu_Unwind_Resume () from /system/lib/libm.so
#1 0xb6cdba78 in ___Unwind_Resume () from /system/lib/libm.so
#2 0xb6e49c98 in fmt::v5::vsprintf(fmt::v5::basic_string_view, fmt::v5::basic_format_args<fmt::v5::basic_printf_context<std::__ndk1::back_insert_iterator<fmt::v5::internal::basic_buffer >, char, fmt::v5::printf_arg_formatter<fmt::v5::back_insert_range<fmt::v5::internal::basic_buffer > > > >) ()
#3 0xb6e15ac0 in PrintfTest_NumberIsTooBigInArgIndex_Test::TestBody() ()
#4 0xb6f78a38 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const) ()
#5 0xb6f5574c in testing::Test::Run() ()
#6 0xb6f56860 in testing::TestInfo::Run() ()
#7 0xb6f56f50 in testing::TestCase::Run() ()
#8 0xb6f5fa88 in testing::internal::UnitTestImpl::RunAllTests() ()
#9 0xb6f79a28 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const) ()
#10 0xb6f5f538 in testing::UnitTest::Run() ()
#11 0xb6f47f1c in main ()

@vitaut
Copy link
Contributor

vitaut commented Jul 18, 2018

Thanks. Could you by any chance post a stack trace for the debug version (with line numbers) which can be compiled with cmake -DCMAKE_BUILD_TYPE=Debug && make?

@cppden
Copy link
Author

cppden commented Jul 21, 2018

Sorry for a delay though I'm pretty sure the issue is well reproducible on any cpu with strict data alignment access.
Here's debug dump for latest HEAD:
commit d778bde (HEAD -> master, origin/master, origin/HEAD)

Core was generated by `./printf-test'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0xb6cf0f58 in __gnu_Unwind_Resume () from /system/lib/libm.so
(gdb) bt
#0 0xb6cf0f58 in __gnu_Unwind_Resume () from /system/lib/libm.so
#1 0xb6cf1a78 in ___Unwind_Resume () from /system/lib/libm.so
#2 0xb6e2f144 in fmt::v5::vsprintf (format=..., args=...)
at /data/data/com.termux/files/home/github/fmt/include/fmt/printf.h:594
#3 0xb6e1e5fc in fmt::v5::sprintf<>(fmt::v5::basic_string_view) (
format_str=...)
at /data/data/com.termux/files/home/github/fmt/include/fmt/printf.h:607
#4 0xb6dfd92c in PrintfTest_NumberIsTooBigInArgIndex_Test::TestBody (
this=0xb6b0a158)
at /data/data/com.termux/files/home/github/fmt/test/printf-test.cc:74
#5 0xb6f96b48 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (object=0xb6b0a158, method=&virtual testing::Test::TestBody(),
location=0xb6fb5574 "the test body")
at /data/data/com.termux/files/home/github/fmt/test/gmock-gtest-all.cc:3562
#6 0xb6f75794 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0xb6b0a158, method=&virtual testing::Test::TestBody(),
location=0xb6fb5574 "the test body")
at /data/data/com.termux/files/home/github/fmt/test/gmock-gtest-all.cc:3598
#7 0xb6f3df54 in testing::Test::Run (this=0xb6b0a158)
at /data/data/com.termux/files/home/github/fmt/test/gmock-gtest-all.cc:3634
#8 0xb6f3eff0 in testing::TestInfo::Run (this=0xb6b10180)
at /data/data/com.termux/files/home/github/fmt/test/gmock-gtest-all.cc:3810
#9 0xb6f3faa4 in testing::TestCase::Run (this=0xb6b1b000)
at /data/data/com.termux/files/home/github/fmt/test/gmock-gtest-all.cc:3928
#10 0xb6f4baf0 in testing::internal::UnitTestImpl::RunAllTests (this=0xb6b13000)
at /data/data/com.termux/files/home/github/fmt/test/gmock-gtest-all.cc:5799
#11 0xb6f9a0e4 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0xb6b13000,.....

@vitaut
Copy link
Contributor

vitaut commented Jul 24, 2018

The segfault occurs in

  EXPECT_THROW_MSG(fmt::sprintf(format("%{}$", BIG_NUM)),
      format_error, "number is too big"); 

which is a test that intentionally throws (and catches) an exception on invalid input and the segfault seem to happens during exception propagation (__gnu_Unwind_Resume). I see some similar reports, e.g. android/ndk#613.

@cppden
Copy link
Author

cppden commented Jul 28, 2018

Thanks vitaut for figuring out the problem!

@cppden cppden closed this as completed Jul 28, 2018
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