http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48625
Summary: Segfault in libitm when compiling with -O2 Product: gcc Version: trans-mem Status: UNCONFIRMED Keywords: trans-mem Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: mar...@gcc.gnu.org Host: x86_64 GNU/Linux Target: x86_64 GNU/Linux Build: transactional-memory branch Revision 172498 Created attachment 23998 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23998 Reduced Kmeans benchmarks from the STAMP suite that segfaults in libitm The kmeans benchmark from the STAMP TM suite segfaults at run time when compiled with -O2. I attached a reduced version of the kmeans program (one file containing all functions plus header and input files - it is still quite large). Compiling the file works fine: martin:~/GCC_STAMP/stamp-0.9.10/kmeans_red$ ~/GCC_TM_BRANCH/gcc_install/bin/gcc-tm -I../include -I~/GCC_TM_BRANCH/transactional-memory/libitm -g -O2 -Wall -fgnu-tm -o kmeans_all kmeans_all.c -lpthread -litm -lm kmeans_all.c: In function 'main': kmeans_all.c:162:13: warning: variable 'len' set but not used At run time it crashes with a segfault in the libitm. The crash is related to the barrier optimization (using ReadforWrite barriers). When compiled with -O1 instead of -O2 the program runs fine. Please see the gdb's backtrace of the segfault: martin:~/GCC_STAMP/stamp-0.9.10/kmeans_red$ gdb --args ./kmeans_all -m15 -n15 -i inputs/random-n2048-d16-c16.txt -p 4 GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from ~/GCC_STAMP/stamp-0.9.10/kmeans_red/kmeans_all...done. (gdb) run Starting program: ~/GCC_STAMP/stamp-0.9.10/kmeans_red/kmeans_all -m15 -n15 -i inputs/random-n2048-d16-c16.txt -p 4 [Thread debugging using libthread_db enabled] [New Thread 0x7ffff698a700 (LWP 27681)] [New Thread 0x7ffff6189700 (LWP 27682)] [New Thread 0x7ffff5988700 (LWP 27683)] Program received signal SIGSEGV, Segmentation fault. do_write_lock (this=0x64f730, addr=<value optimized out>) at ../../../transactional-memory/libitm/method-wbetl.cc:265 265 *line = *addr; (gdb) backtrace #0 do_write_lock (this=0x64f730, addr=<value optimized out>) at ../../../transactional-memory/libitm/method-wbetl.cc:265 #1 0x00007ffff71b64a9 in do_read<unsigned int> (ptr=0x81, lock=GTM::gtm_dispatch::RfW) at ../../../transactional-memory/libitm/barrier.tpl:47 #2 0x0000000000401e0f in work (argPtr=<value optimized out>) at kmeans_all.c:559 #3 0x0000000000401c75 in threadWait (argPtr=<value optimized out>) at kmeans_all.c:948 #4 0x0000000000401cd5 in thread_start (funcPtr=<value optimized out>, argPtr=<value optimized out>) at kmeans_all.c:1020 #5 0x0000000000402443 in normal_exec (nthreads=4, feature=0x625260, nfeatures=16, npoints=2048, nclusters=15, threshold=0.00100000005, membership=<value optimized out>, randomPtr=0x64d770) at kmeans_all.c:684 #6 0x00000000004026a1 in cluster_exec (nthreads=4, numObjects=2048, numAttributes=16, attributes=0x625260, use_zscore_transform=<value optimized out>, min_nclusters=15, max_nclusters=15, threshold=0.00100000005, best_nclusters=0x7fffffffddec, cluster_centres=0x7fffffffddd8, cluster_assign=0x649750) at kmeans_all.c:1404 #7 0x0000000000402c5e in main (argc=6312528, argv=<value optimized out>) at kmeans_all.c:299 Any help is appreciated :-)