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

Segmentation fault with CXXFLAGS="-O3" or CXXFLAGS="-O1 -ftree-loop-vectorize" #35

Closed
Arfrever opened this issue Feb 26, 2021 · 4 comments

Comments

@Arfrever
Copy link

Arfrever commented Feb 26, 2021

Segmentation fault in marisa-test occurs if Marisa is configured with CXXFLAGS="-O3".
Problem does not occur for me with additional -march=westmere or -march=native (e.g. CXXFLAGS="-O3 -march=westmere").
I use GCC 10.2.0.

$ CXXFLAGS="-g -O3" ./configure
...
$ make
...
$ make check
...
make  check-TESTS
make[2]: Entering directory '/tmp/marisa-trie/tests'
make[3]: Entering directory '/tmp/marisa-trie/tests'
PASS: base-test
PASS: io-test
PASS: vector-test
PASS: trie-test
../test-driver: line 109: 14027 Segmentation fault      "$@" > $log_file 2>&1
FAIL: marisa-test
============================================================================
Testsuite summary for marisa 0.2.6
============================================================================
# TOTAL: 5
# PASS:  4
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/test-suite.log
Please report to susumu.yata@gmail.com
============================================================================
make[3]: *** [Makefile:715: test-suite.log] Error 1
make[3]: Leaving directory '/tmp/marisa-trie/tests'
make[2]: *** [Makefile:823: check-TESTS] Error 2
make[2]: Leaving directory '/tmp/marisa-trie/tests'
make[1]: *** [Makefile:925: check-am] Error 2
make[1]: Leaving directory '/tmp/marisa-trie/tests'
make: *** [Makefile:456: check-recursive] Error 1
$ LD_LIBRARY_PATH="$(pwd)/lib/marisa/.libs" gdb tests/.libs/marisa-test
...
(gdb) r
Starting program: /tmp/marisa-trie/tests/.libs/marisa-test 
marisa-test.cc:13: TestEmptyTrie(): ok
marisa-test.cc:87: TestTinyTrie(): ok

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fab3c5 in marisa::grimoire::algorithm::details::get_label<marisa::grimoire::trie::Entry> (depth=1, unit=...)
    at ../../../../lib/marisa/grimoire/algorithm/sort.h:19
19        return (depth < unit.length()) ? (int)(UInt8)unit[depth] : -1;
(gdb) bt
#0  0x00007ffff7fab3c5 in marisa::grimoire::algorithm::details::get_label<marisa::grimoire::trie::Entry> (depth=1, unit=...)
    at ../../../../lib/marisa/grimoire/algorithm/sort.h:19
#1  marisa::grimoire::algorithm::details::sort<marisa::grimoire::trie::Entry*> (l=l@entry=0x55555557c110, r=r@entry=0x55555557c660, depth=depth@entry=1)
    at ../../../../lib/marisa/grimoire/algorithm/sort.h:103
#2  0x00007ffff7fab4ea in marisa::grimoire::algorithm::details::sort<marisa::grimoire::trie::Entry*> (l=0x55555557aed0, r=0x55555557dce0, 
    depth=depth@entry=0) at ../../../../lib/marisa/grimoire/algorithm/sort.h:132
#3  0x00007ffff7fac2c3 in marisa::grimoire::algorithm::sort<marisa::grimoire::trie::Entry*> (end=<optimized out>, begin=<optimized out>)
    at ../../../../lib/marisa/grimoire/algorithm/sort.h:189
#4  marisa::grimoire::Algorithm::sort<marisa::grimoire::trie::Entry*> (end=<optimized out>, begin=<optimized out>, this=<optimized out>)
    at ../../../../lib/marisa/grimoire/algorithm.h:15
#5  marisa::grimoire::trie::Tail::build_ (this=0x7fffffffd130, entries=..., offsets=0x7fffffffd310, mode=MARISA_TEXT_TAIL) at tail.cc:161
#6  0x00007ffff7facde7 in marisa::grimoire::trie::Tail::build (this=this@entry=0x7fffffffd918, entries=..., offsets=offsets@entry=0x7fffffffd310, 
    mode=MARISA_TEXT_TAIL) at tail.cc:41
#7  0x00007ffff7fb569b in marisa::grimoire::trie::LoudsTrie::build_next_trie<marisa::grimoire::trie::Key> (this=0x7fffffffd630, keys=..., 
    terminals=0x7fffffffd310, config=..., trie_id=1) at ../../../../lib/marisa/grimoire/trie/config.h:35
#8  0x00007ffff7fbea57 in marisa::grimoire::trie::LoudsTrie::build_trie<marisa::grimoire::trie::Key> (this=this@entry=0x7fffffffd630, keys=..., 
    terminals=terminals@entry=0x7fffffffd4c0, config=..., trie_id=trie_id@entry=1) at louds-trie.cc:300
#9  0x00007ffff7fb5940 in marisa::grimoire::trie::LoudsTrie::build_ (this=0x7fffffffd630, keyset=..., config=...) at louds-trie.cc:257
#10 0x00007ffff7fb69e3 in marisa::grimoire::trie::LoudsTrie::build (this=this@entry=0x555555576bd0, keyset=..., flags=flags@entry=135169)
    at louds-trie.cc:27
#11 0x00007ffff7fa975a in marisa::Trie::build (this=this@entry=0x7fffffffdb38, keyset=..., config_flags=config_flags@entry=135169) at trie.cc:16
#12 0x000055555555ada4 in (anonymous namespace)::TestTrie (num_tries=1, tail_mode=MARISA_TEXT_TAIL, node_order=MARISA_WEIGHT_ORDER, keyset=...)
    at marisa-test.cc:268
#13 0x000055555555bd0a in (anonymous namespace)::TestTrie (tail_mode=MARISA_TEXT_TAIL, node_order=MARISA_WEIGHT_ORDER, keyset=...) at marisa-test.cc:357
#14 0x000055555555be2e in (anonymous namespace)::TestTrie (tail_mode=MARISA_TEXT_TAIL) at marisa-test.cc:367
#15 0x0000555555559b7e in (anonymous namespace)::TestTrie () at marisa-test.cc:372
#16 main () at marisa-test.cc:383
(gdb) 
@Arfrever Arfrever changed the title Segmentation fault with CXXFLAGS="-O3" Segmentation fault with CXXFLAGS="-O3" or CXXFLAGS="-O1 -ftree-loop-vectorize" Mar 4, 2021
@Arfrever
Copy link
Author

Arfrever commented Mar 4, 2021

More precisely, segmentation fault occurs with -ftree-loop-vectorize and at least -O1 (so either CXXFLAGS="-O1 -ftree-loop-vectorize" or CXXFLAGS="-O2 -ftree-loop-vectorize").
Segmentation fault occurs with GCC 10.2.0, and does not occur with GCC 8.4.0 or 9.3.0.

@Arfrever
Copy link
Author

Arfrever commented Mar 4, 2021

Reported as GCC bug 99375.

@Arfrever
Copy link
Author

Arfrever commented Mar 4, 2021

Problem was fixed in GCC 10 branch:
GCC commit 1ab88985631dd2c5a5e3b5c0dce47cf8b6ed2f82
Fix will be released in GCC 10.3.0.

(I will close this report in Marisa after release of GCC 10.3.0.)

@Arfrever
Copy link
Author

Arfrever commented Apr 8, 2021

@Arfrever Arfrever closed this as completed Apr 8, 2021
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

1 participant