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

arm64, alignment problem causes a failure to build from source #2368

Open
mr-c opened this issue Jan 2, 2019 · 3 comments
Open

arm64, alignment problem causes a failure to build from source #2368

mr-c opened this issue Jan 2, 2019 · 3 comments

Comments

@mr-c
Copy link
Contributor

mr-c commented Jan 2, 2019

https://github.com/seqan/seqan/blob/master/include/seqan/misc/bit_twiddling.h#L348

Steve McIntyre steve@einval.com at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917851 writes:

Hi!

I've been doing a full rebuild of the Debian archive, building all
source packages targeting armel and armhf using arm64 hardware. We are
planning in future to move all of our 32-bit armel/armhf builds to
using arm64 machines, so this rebuild is to identify packages that
might have problems with this configuration.

A feature of the arm64 kernel is that it does not support fixing up
code with broken alignment, so code that might have built and run OK
on our older armel/armhf build machines due to kernel fixups will now
fail.

When building your package, I've found a bus error (aka alignment
fault). The full log is online at

https://www.einval.com/debian/arm/rebuild-logs/armel/FAIL/seqan2_2.4.0+dfsg-9_armel.log

for reference

I've done a quick bit of debugging to find the source of the
bug. Here's a gdb stacktrace and variable printout to demonstrate the
problem.

(sid-armel)steve@mjolnir:~/debian/build/seqan2/seqan2-2.4.0+dfsg$ gdb obj-arm-linux-gnueabi/bin/test_index_fm_rank_dictionary obj-arm-linux-gnueabi/tests/index/core
...
Core was generated by `/home/steve/debian/build/seqan2/seqan2-2.4.0+dfsg/obj-arm-linux-gnueabi/bin/tes'.
Program terminated with signal SIGBUS, Bus error.
#0  0x00bf7d24 in seqan::_getWordRank<bool, void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u>, unsigned long long, unsigned int> (
    word=@0x234df2a: 6741939070857683030, c=true, posInWord=63) at ./include/seqan/misc/bit_twiddling.h:346
346     _popCountImpl(TWord word, WordSize_<64> const & /*tag*/)
(gdb) bt
#0  0x00bf7d24 in seqan::_getWordRank<bool, void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u>, unsigned long long, unsigned int> (
    word=@0x234df2a: 6741939070857683030, c=true, posInWord=63) at ./include/seqan/misc/bit_twiddling.h:346
#1  seqan::_getWordRank<bool, void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u>, unsigned long long> (dict=..., word=@0x234df2a: 6741939070857683030, 
    c=true) at ./include/seqan/index/index_fm_rank_dictionary_levels.h:1139
#2  seqan::_getValueRank<bool, void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u>, seqan::Tuple<seqan::Tuple<bool, 64u, seqan::BitPacked<16u, 16u> >, 2u, void>, unsigned int> (c=true, dict=..., posInBlock=127, values=...) at ./include/seqan/index/index_fm_rank_dictionary_levels.h:1261
#3  seqan::_getValuesRanks<void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u>, unsigned int> (pos=<optimized out>, dict=...)
    at ./include/seqan/index/index_fm_rank_dictionary_levels.h:1349
#4  seqan::updateRanks<bool, void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u> > (dict=...) at ./include/seqan/index/index_fm_rank_dictionary_levels.h:1711
#5  seqan::createRankDictionary<bool, seqan::Levels<void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u> >, seqan::String<bool, seqan::Alloc<void> > > (
    dict=..., text=...) at ./include/seqan/index/index_fm_rank_dictionary_base.h:268
#6  0x00bf8cfc in seqan::RankDictionary<bool, seqan::Levels<void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u> > >::RankDictionary<seqan::String<bool, seqan::Alloc<void> > > (text=..., this=0xffd11048) at ./include/seqan/index/index_fm_rank_dictionary_levels.h:430
#7  RankDictionaryTest__Constructor<seqan::RankDictionary<bool, seqan::Levels<void, seqan::LevelsRDConfig<unsigned int, seqan::Alloc<void>, 2u, 2u> > > >::runTest (
    this=0x232df30) at ./tests/index/test_index_fm_rank_dictionary.cpp:186
#8  0x00bc2074 in seqan::TestSystem::runAll () at /usr/include/c++/8/bits/unique_ptr.h:342
#9  0xf783a474 in __libc_start_main (main=0xffd11244, argc=-141082624, argv=0xf783a474 <__libc_start_main+268>, init=<optimized out>, fini=0xc45368 <__libc_csu_fini>, 
    rtld_fini=0xf7c9e66c <_dl_fini>, stack_end=0xffd11244) at libc-start.c:308
#10 0x00bb40ac in _start () at ./include/seqan/basic/debug_test_system.h:502
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) list
341     // GCC or CLANG implementations.
342     // SSE4.2 popcnt is emitted when compiling with -mpopcnt or -march=corei7
343
344     template <typename TWord>
345     inline unsigned
346     _popCountImpl(TWord word, WordSize_<64> const & /*tag*/)
347     {
348         return __builtin_popcountll(static_cast<uint64_t>(word));
349     }
350
(gdb) p word
$1 = (const unsigned long long &) @0x234df2a: 6741939070857683030

This is classic buggy code for alignment faults - simply casting a
uint64_t over the unaligned address 0x234df2a is not safe.

@rrahn
Copy link
Contributor

rrahn commented Jan 9, 2019

Hi @mr-c thanks for reporting this.
How urgent is this issue on your site? As we are currently quite busy with SeqAn3 development.

@mr-c
Copy link
Contributor Author

mr-c commented Jan 9, 2019

Hey @rrahn, you are welcome.

Currently it isn't preventing seqan 2.x from being in the next Debian release, but it is blocking our ability to update the package.

So, not super urgent. I'll let you know if that changes.

@mr-c
Copy link
Contributor Author

mr-c commented Jan 22, 2021

Hello from 2021; it would be nice to fix this; I see lots of commits to the repo since the last release. Perhaps someone could point out a fix that we can apply to the Debian package?

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