Bug 57358 - segmentation fault with attribute(optimize(O0))
Summary: segmentation fault with attribute(optimize(O0))
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Martin Jambor
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-21 15:17 UTC by Nickolay Kolchin-Semyonov
Modified: 2013-06-24 12:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-06-11 00:00:00


Attachments
backtrace (881 bytes, text/plain)
2013-05-21 15:17 UTC, Nickolay Kolchin-Semyonov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nickolay Kolchin-Semyonov 2013-05-21 15:17:15 UTC
Created attachment 30157 [details]
backtrace

The following code crashes GCC (gcc-4.8.0 -O2):

typedef void (*done)(void* arg);
struct t { done func; void* arg; };
static void test_func() __attribute__((optimize("O0")));                          static void test_func(struct t* a)
{
  a->func(a->arg);
}

Program received signal SIGSEGV, Segmentation fault.
walk_aliased_vdefs_1 (ref=ref@entry=0x7fffffffda70, vdef=0x0,
    walker=0x6f5d90 <mark_modified(ao_ref*, tree, void*)>, data=0x7fffffffda5f,
    visited=0x7fffffffda28, cnt=0)
    at /mnt/work/oktet/transas/sources/4.8/gcc/gcc/tree-ssa-alias.c:2196
2196          gimple def_stmt = SSA_NAME_DEF_STMT (vdef);

Backtrace from gdb attached.

Reproducable with custom GCC build and gentoo 4.8. No error in 4.7.
Comment 1 Nickolay Kolchin-Semyonov 2013-06-04 14:16:44 UTC
Reproducable with gcc-4.8.1.

Using built-in specs.
COLLECT_GCC=gcc-4.8.1
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /mnt/work/tmp/portage/sys-devel/gcc-4.8.1/work/gcc-4.8.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-cloog --disable-isl-version-check --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,go,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.1 p1.0, pie-0.5.6'
Thread model: posix
gcc version 4.8.1 (Gentoo 4.8.1 p1.0, pie-0.5.6)

$ gcc-4.8.1 -O3 -c no-optimize.c
no-optimize.c: In function ‘test_func’:
no-optimize.c:7:1: internal compiler error: Segmentation fault
 }
 ^
Comment 2 Nickolay Kolchin-Semyonov 2013-06-04 15:14:44 UTC
More simplified test variant:

struct t { void (*func)(void*); };
void test_func(struct t* a) __attribute__((optimize("O0")));
void test_func(struct t* a)
{
  a->func(0);
}

P.S. If you compile this as C++ code, no segmentation fault would occure.
Comment 3 Martin Jambor 2013-06-11 12:00:02 UTC
I'll take a look.
Comment 4 Martin Jambor 2013-06-14 09:59:54 UTC
I have submitted a fix for the 4.8 branch here:

http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00663.html

and for the current trunk here:

http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00666.html
Comment 5 Martin Jambor 2013-06-24 12:52:24 UTC
Author: jamborm
Date: Mon Jun 24 12:51:43 2013
New Revision: 200369

URL: http://gcc.gnu.org/viewcvs?rev=200369&root=gcc&view=rev
Log:
2013-06-24  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/57358
	* ipa-prop.c (ipa_func_spec_opts_forbid_analysis_p): New function.
	(ipa_compute_jump_functions_for_edge): Bail out if it returns true.
	(ipa_analyze_params_uses): Generate pessimistic info when true.

testsuite
	* gcc.dg/ipa/pr57358.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/ipa/pr57358.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-prop.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Martin Jambor 2013-06-24 12:59:15 UTC
Author: jamborm
Date: Mon Jun 24 12:57:52 2013
New Revision: 200370

URL: http://gcc.gnu.org/viewcvs?rev=200370&root=gcc&view=rev
Log:
2013-06-24  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/57358
	* ipa-prop.c (parm_ref_data_preserved_p): Always return true when
	not optimizing.

testsuite/
	* gcc.dg/ipa/pr57358.c: New test.


Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/ipa/pr57358.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/ipa-prop.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog