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

BUILD_TESTS don't work on SPARC64 debian 7.8.0 #48

Closed
LowLevelMahn opened this Issue Jul 24, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@LowLevelMahn

LowLevelMahn commented Jul 24, 2015

is (or better should be?) pugixml big-endian/unaligned-access aware - if that is the problem at all?

i've got an qemu image for emulation if needed (~290MB)

cmake 3.2.3
gcc 4.6.3
libc-2.13

on this system big-endian and unaligned-accesses are not allowed

pugixml (and tests) compilation works but some test seems to fail

:~/pugixml/tests# ~/cmake-3.2.3/bin/cmake -D BUILD_TESTS=TRUE /pugixmml/scripts/
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /root/pugixml/tests
root@debian:
/pugixml/tests# make
Scanning dependencies of target pugixml
[ 2%] Building CXX object CMakeFiles/pugixml.dir/root/pugixml/src/pugixml.cpp.o
Linking CXX static library libpugixml.a
[ 2%] Built target pugixml
Scanning dependencies of target check
[ 5%] Building CXX object CMakeFiles/check.dir/test_write.cpp.o
[ 7%] Building CXX object CMakeFiles/check.dir/test.cpp.o
[ 10%] Building CXX object CMakeFiles/check.dir/test_xpath_api.cpp.o
[ 13%] Building CXX object CMakeFiles/check.dir/test_version.cpp.o
[ 15%] Building CXX object CMakeFiles/check.dir/test_dom_traverse.cpp.o
[ 18%] Building CXX object CMakeFiles/check.dir/test_xpath_paths_abbrev_w3c.cpp.o
[ 21%] Building CXX object CMakeFiles/check.dir/test_header_guard.cpp.o
[ 23%] Building CXX object CMakeFiles/check.dir/test_xpath_functions.cpp.o
[ 26%] Building CXX object CMakeFiles/check.dir/test_parse.cpp.o
[ 28%] Building CXX object CMakeFiles/check.dir/test_header_string_2.cpp.o
[ 31%] Building CXX object CMakeFiles/check.dir/test_header_only.cpp.o
[ 34%] Building CXX object CMakeFiles/check.dir/test_xpath_paths_w3c.cpp.o
[ 36%] Building CXX object CMakeFiles/check.dir/test_header_string_iostream.cpp.o
[ 39%] Building CXX object CMakeFiles/check.dir/test_header_iosfwd_2.cpp.o
[ 42%] Building CXX object CMakeFiles/check.dir/test_document.cpp.o
[ 44%] Building CXX object CMakeFiles/check.dir/test_xpath_xalan_1.cpp.o
[ 47%] Building CXX object CMakeFiles/check.dir/main.cpp.o
[ 50%] Building CXX object CMakeFiles/check.dir/test_memory.cpp.o
[ 52%] Building CXX object CMakeFiles/check.dir/test_header_iosfwd_1.cpp.o
[ 55%] Building CXX object CMakeFiles/check.dir/test_parse_doctype.cpp.o
[ 57%] Building CXX object CMakeFiles/check.dir/test_xpath_xalan_4.cpp.o
[ 60%] Building CXX object CMakeFiles/check.dir/test_xpath_variables.cpp.o
[ 63%] Building CXX object CMakeFiles/check.dir/test_xpath_xalan_5.cpp.o
[ 65%] Building CXX object CMakeFiles/check.dir/test_xpath_parse.cpp.o
[ 68%] Building CXX object CMakeFiles/check.dir/test_header_iostream_2.cpp.o
[ 71%] Building CXX object CMakeFiles/check.dir/allocator.cpp.o
[ 73%] Building CXX object CMakeFiles/check.dir/test_dom_modify.cpp.o
[ 76%] Building CXX object CMakeFiles/check.dir/test_xpath_xalan_2.cpp.o
[ 78%] Building CXX object CMakeFiles/check.dir/test_header_iostream_1.cpp.o
[ 81%] Building CXX object CMakeFiles/check.dir/test_xpath_paths.cpp.o
[ 84%] Building CXX object CMakeFiles/check.dir/test_dom_text.cpp.o
[ 86%] Building CXX object CMakeFiles/check.dir/test_header_string_1.cpp.o
[ 89%] Building CXX object CMakeFiles/check.dir/writer_string.cpp.o
[ 92%] Building CXX object CMakeFiles/check.dir/test_xpath_xalan_3.cpp.o
[ 94%] Building CXX object CMakeFiles/check.dir/test_unicode.cpp.o
[ 97%] Building CXX object CMakeFiles/check.dir/test_xpath.cpp.o
[100%] Building CXX object CMakeFiles/check.dir/test_xpath_operators.cpp.o
Linking CXX executable check
[ 4028.960310] check[3168]: segfault at 3f91bc ip 00000000703620dc (rpc 0000000070361a30) sp 00000000ff803648 error 30002 in libc-2.13.so[702d8000+172000]
Segmentation fault
make[2]: *** [check] Error 139
make[1]: *** [CMakeFiles/check.dir/all] Error 2
make: *** [all] Error 2

@zeux

This comment has been minimized.

Owner

zeux commented Jul 24, 2015

A qemu image would help.

I suspect that this is specific to the way the tests are setup combined with the unaligned memory access not working. The tests override allocation functions but in doing so they violate the basic malloc contract because they return unaligned memory. This is done to catch single-byte buffer overflows on heap. This can create cases when pugixml accesses unaligned memory - I had these issues before with instrumentation that flags unaligned accesses like UB sanitizers.

@LowLevelMahn

This comment has been minimized.

LowLevelMahn commented Jul 24, 2015

i'll prepare a small installation text and put the image somewhere on an free downloader website, but beware the sparc emulation is textmode only, very slow (costs serveral minutes to compile pugixml) but works

@LowLevelMahn

This comment has been minimized.

LowLevelMahn commented Jul 25, 2015

uploaded the image+start description (pugi_sparc.txt) to depositfiles (seems to be the only free file hoster with ftp upload feature)
https://depositfiles.com/files/sj20aqwp0

press the "regular download" button, wait some seconds, solve the chapca, "download file in regular mode by browser"

@zeux

This comment has been minimized.

Owner

zeux commented Jul 25, 2015

cmake 3.2.3 (build from source in 10h)

Wow. Thank you! I'm looking into this (btw pugixml does not require cmake - you can just do "make test" after git clone)

As I suspected, one of the issues is the test-only allocator; although even if I disable that I still get crashes somewhere further.

zeux added a commit that referenced this issue Jul 25, 2015

tests: Only enable page heap on x86/x64
This fixes tests in PUGIXML_NO_XPATH mode on SPARC64 (#48).

SPARC does not allow unaligned accesses - e.g. you can't read an unaligned int.
Normally pugixml does not perform unaligned integer/pointer accesses, but page
heap can allocate blocks that are not aligned so that we can detect a single-
byte read/write overrun.

Additionally, the hardcoded page size we're currently using is really system
specific - on SPARC the page size can be 8 Kb instead of 4 Kb so mprotect can
fail.

@zeux zeux closed this in bd7a8fa Jul 25, 2015

@zeux

This comment has been minimized.

Owner

zeux commented Jul 25, 2015

It's interesting that this problem can't really be caught by the undefined behavior sanitizer on x86/x64 despite the fact that it checks alignment violations:

x86 has sizeof(void*) = 4 alignof(double) = 4
x64 has sizeof(void*) = 8 alignof(double) = 8

And the problem only manifests when sizeof(void*) < alignof(double).

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