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

running the test_runner crashes #327

Open
ranj14 opened this issue Jan 12, 2017 · 4 comments
Open

running the test_runner crashes #327

ranj14 opened this issue Jan 12, 2017 · 4 comments

Comments

@ranj14
Copy link

ranj14 commented Jan 12, 2017

Hi.

I recently built the cpprestsdk project on linux-cent0S. I have these prerequisites available on my PC: Boost1.63.0, openssl1.0.1 and gcc485.

I ran cmake with -D options as :

cmake .. -DCMAKE_BUILD_TYPE=Release -DBoost_NO_BOOST_CMAKE=TRUE -DBoost_NO_SYSTEM_PATHS=TRUE -DBOOST_ROOT:PATHNAME=/boost_1_63_0/ -DBOOST_LIBRARYDIR:FILEPATH=/boost_1_63_0/libs/ -DBoost_INCLUDE_DIR:FILEPATH=boost_1_63_0/

When I run the test binary, it crashses.
./test_runner _test.so
** segmentation fault
*

Could any one let em know what could be the issue here. Thanks

@grahamreeds
Copy link

grahamreeds commented Jan 14, 2017 via email

@saqib-ahmed
Copy link

saqib-ahmed commented Feb 28, 2017

@grahamreeds I ran into same problem on fedora 25. Following stack traces of segmentation faults are produced using GDB. Seems like a problem with boost library.

Stack Trace for libjson_test

#0  0x00007ffff5a0ff25 in malloc_consolidate (av=av@entry=0x7ffff5d4fae0 <main_arena>) 
at malloc.c:4218
#1  0x00007ffff5a12eaf in _int_malloc (av=av@entry=0x7ffff5d4fae0 <main_arena>, bytes=bytes@entry=32816) 
at malloc.c:3485
#2  0x00007ffff5a14f14 in __GI___libc_malloc (bytes=32816) 
at malloc.c:2925
#3  0x00007ffff5a56d5b in __alloc_dir (statp=0x7fffffffd860, flags=0, close_fd=true, fd=3) 
at ../sysdeps/posix/opendir.c:247
#4  opendir_tail (fd=3) 
at ../sysdeps/posix/opendir.c:145
#5  __opendir (name=<optimized out>) 
at ../sysdeps/posix/opendir.c:200
#6  0x00007ffff6606ed8 in (anonymous namespace)::dir_itr_first (target="", dir=<optimized out>, buffer=@0x66f1e8: 0x7ffff5d4fb38 <main_arena+88>, handle=@0x66f1e0: 0x66f390) 
at libs/filesystem/src/operations.cpp:2043
#7  boost::filesystem::detail::directory_iterator_construct (it=..., p=..., ec=0x0) 
at libs/filesystem/src/operations.cpp:2267
#8  0x00000000004365f1 in boost::filesystem::directory_iterator::directory_iterator (this=0x7fffffffda50, p=...)
at /usr/include/boost/filesystem/operations.hpp:903
#9  0x000000000043215c in get_files_in_directory () 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:131
#10 0x0000000000432525 in get_matching_binaries (dllName="libjson_test.so")
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:181
#11 0x0000000000433a94 in load_all_tests (module_loader=...) 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:415
#12 0x00000000004344e4 in main (argc=2, argv=0x7fffffffde88) 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:579

Stack Trace for libhttpclient_test

#0  __memmove_sse2_unaligned_erms () 
at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:420
#1  0x00007ffff66048a7 in std::char_traits<char>::copy (__n=4156262400,  __s2=0x66f3a0 "/home/saqib/Dev_active/cpprestsdk/Release/build.debug/Binaries", __s1=<optimized out>)
at /usr/include/c++/6.2.1/bits/char_traits.h:290
#2  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=4156262400, __s=0x66f3a0 "/home/saqib/Dev_active/cpprestsdk/Release/build.debug/Binaries", __d=<optimized out>)
at /usr/include/c++/6.2.1/bits/basic_string.h:300
#3  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars (__k2=<optimized out>,  __k1=0x66f3a0 "/home/saqib/Dev_active/cpprestsdk/Release/build.debug/Binaries", __p=<optimized out>)
at /usr/include/c++/6.2.1/bits/basic_string.h:342
#4  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (this=this@entry=0x7fffffffd990,  __beg=0x66f3a0 "/home/saqib/Dev_active/cpprestsdk/Release/build.debug/Binaries", __end=<optimized out>)
at /usr/include/c++/6.2.1/bits/basic_string.tcc:225
#5  0x00007ffff6607014 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char*> ( __end=<optimized out>, __beg=<optimized out>, this=0x7fffffffd990) 
at /usr/include/c++/6.2.1/bits/basic_string.h:196
#6  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (__end=<optimized out>,  __beg=<optimized out>, this=0x7fffffffd990) 
at /usr/include/c++/6.2.1/bits/basic_string.h:215
#7  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__str="", this=0x7fffffffd990)
at /usr/include/c++/6.2.1/bits/basic_string.h:400
#8  boost::filesystem::path::path (p=..., this=0x7fffffffd990) 
at boost/filesystem/path.hpp:133
#9  boost::filesystem::operator/ (rhs=..., lhs=...) 
at boost/filesystem/path.hpp:789
#10 boost::filesystem::detail::directory_iterator_construct (it=..., p=..., ec=0x0) 
at libs/filesystem/src/operations.cpp:2281
#11 0x00000000004365f1 in boost::filesystem::directory_iterator::directory_iterator (this=0x7fffffffda40, p=...)
at /usr/include/boost/filesystem/operations.hpp:903
#12 0x000000000043215c in get_files_in_directory () 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:131
#13 0x0000000000432525 in get_matching_binaries (dllName="libhttpclient_test.so")
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:181
#14 0x0000000000433a94 in load_all_tests (module_loader=...) 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:415
#15 0x00000000004344e4 in main (argc=2, argv=0x7fffffffde78) 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:579

Stack Trace for liburi_test

#0  0x00007ffff5a0ff25 in malloc_consolidate (av=av@entry=0x7ffff5d4fae0 <main_arena>) 
at malloc.c:4218
#1  0x00007ffff5a12eaf in _int_malloc (av=av@entry=0x7ffff5d4fae0 <main_arena>, bytes=bytes@entry=32816) 
at malloc.c:3485
#2  0x00007ffff5a14f14 in __GI___libc_malloc (bytes=32816) 
at malloc.c:2925
#3  0x00007ffff5a56d5b in __alloc_dir (statp=0x7fffffffd860, flags=0, close_fd=true, fd=3) 
at ../sysdeps/posix/opendir.c:247
#4  opendir_tail (fd=3) 
at ../sysdeps/posix/opendir.c:145
#5  __opendir (name=<optimized out>) 
at ../sysdeps/posix/opendir.c:200
#6  0x00007ffff6606ed8 in (anonymous namespace)::dir_itr_first (target="", dir=<optimized out>, buffer=@0x66f1e8: 0x7ffff5d4fb38 <main_arena+88>, handle=@0x66f1e0: 0x66f390) 
at libs/filesystem/src/operations.cpp:2043
#7  boost::filesystem::detail::directory_iterator_construct (it=..., p=..., ec=0x0) 
at libs/filesystem/src/operations.cpp:2267
#8  0x00000000004365f1 in boost::filesystem::directory_iterator::directory_iterator (this=0x7fffffffda50, p=...)
at /usr/include/boost/filesystem/operations.hpp:903
#9  0x000000000043215c in get_files_in_directory () 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:131
#10 0x0000000000432525 in get_matching_binaries (dllName="liburi_test.so")
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:181
#11 0x0000000000433a94 in load_all_tests (module_loader=...) 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:415
#12 0x00000000004344e4 in main (argc=2, argv=0x7fffffffde88) 
at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:579

@ras0219-msft
Copy link
Contributor

@saqibahmed515 It looks like all your call stacks are in the initial load of the test modules. This is extremely early on in the testing harness and isn't a failure inside the main cpprest codebase itself.

Just guessing based on the failure, but you probably have a toolchain problem between cpprest, boost, and your crt. Try writing a simple application that runs the code in [1]. It should crash in the exact same way.

[1] https://github.com/Microsoft/cpprestsdk/blob/master/Release/tests/common/TestRunner/test_runner.cpp#L72

std::vector<std::string> files;
using namespace boost::filesystem;
auto exe_directory = initial_path().string();
for (auto it = directory_iterator(path(exe_directory)); it != directory_iterator(); ++it)
{
    if (is_regular_file(*it))
    {
        files.push_back(it->path().filename().string());
    }
}

@saqib-ahmed
Copy link

saqib-ahmed commented Mar 2, 2017

@ras0219-msft You suspected the right culprit. I tested the program you wrote and it gives following call stack at segmentation fault which is exactly same as previous stack traces:

#0  0x00007ffff5a0ff25 in malloc_consolidate (av=av@entry=0x7ffff5d4fae0 <main_arena>) 
    at malloc.c:4218
#1  0x00007ffff5a12eaf in _int_malloc (av=av@entry=0x7ffff5d4fae0 <main_arena>, bytes=bytes@entry=32816) 
    at malloc.c:3485
#2  0x00007ffff5a14f14 in __GI___libc_malloc (bytes=32816) 
    at malloc.c:2925
#3  0x00007ffff5a56d5b in __alloc_dir (statp=0x7fffffffd860, flags=0, close_fd=true, fd=3) 
    at ../sysdeps/posix/opendir.c:247
#4  opendir_tail (fd=3) 
    at ../sysdeps/posix/opendir.c:145
#5  __opendir (name=<optimized out>) 
    at ../sysdeps/posix/opendir.c:200
#6  0x00007ffff6606ed8 in (anonymous namespace)::dir_itr_first (target="", dir=<optimized out>, buffer=@0x66f218: 0x10, handle=@0x66f210: 0xc)
    at libs/filesystem/src/operations.cpp:2043
#7  boost::filesystem::detail::directory_iterator_construct (it=..., p=..., ec=0x0) 
    at libs/filesystem/src/operations.cpp:2267
#8  0x00000000004365f1 in boost::filesystem::directory_iterator::directory_iterator (this=0x7fffffffda50, p=...)
    at /usr/include/boost/filesystem/operations.hpp:903
#9  0x000000000043215c in get_files_in_directory () 
    at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:131
#10 0x0000000000432525 in get_matching_binaries (dllName="libcrossover")
    at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:181
#11 0x0000000000433a94 in load_all_tests (module_loader=...) 
    at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:415
#12 0x00000000004344e4 in main (argc=2, argv=0x7fffffffde88) 
    at /home/saqib/Dev_active/cpprestsdk/Release/tests/common/TestRunner/test_runner.cpp:579

Problem's been identified. It's my toolchains. Question is, what to do now. How can I work around the problem.

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

4 participants