Bug 81355 - SegFault when using attribute target dispatch with empty parameter
Summary: SegFault when using attribute target dispatch with empty parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.1.0
: P3 normal
Target Milestone: ---
Assignee: Martin Liška
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-08 01:37 UTC by Erich Keane
Modified: 2017-09-19 09:03 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 8.0
Known to fail: 5.4.0, 6.3.0, 7.1.0
Last reconfirmed: 2017-07-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Keane 2017-07-08 01:37:56 UTC
This very simple repro causes a segfault:
__attribute__((target("default")))
int foo() {return 99;}
__attribute__((target("sse4.2","")))
int foo() {return 1;}

int main() {
    return foo();
}

As you can see, this does dispatch, and should otherwise be valid.  However, the blank string causes a segfault: https://godbolt.org/g/dmuCaZ

Additionally of interest, ONLY the 1st parameter to target participates in dispatch.
Comment 1 Martin Liška 2017-07-11 10:21:42 UTC
Confirmed, I'll fix that!
Comment 2 Martin Liška 2017-08-10 07:44:21 UTC
Author: marxin
Date: Thu Aug 10 07:43:49 2017
New Revision: 251020

URL: https://gcc.gnu.org/viewcvs?rev=251020&root=gcc&view=rev
Log:
Fix target attribute handling (PR c++/81355).

2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* c-attribs.c (handle_target_attribute):
	Report warning for an empty string argument of target attribute.
2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/other/pr81355.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/c-attribs.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Martin Liška 2017-08-10 07:52:00 UTC
Fixed on trunk.
Comment 4 Aldy Hernandez 2017-09-13 16:48:12 UTC
Author: aldyh
Date: Wed Sep 13 16:47:40 2017
New Revision: 252379

URL: https://gcc.gnu.org/viewcvs?rev=252379&root=gcc&view=rev
Log:
Fix target attribute handling (PR c++/81355).

2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* c-attribs.c (handle_target_attribute):
	Report warning for an empty string argument of target attribute.
2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.

Added:
    branches/range-gen2/gcc/testsuite/g++.dg/other/pr81355.C
Modified:
    branches/range-gen2/gcc/ChangeLog
    branches/range-gen2/gcc/c-family/c-attribs.c
    branches/range-gen2/gcc/testsuite/ChangeLog
Comment 5 Martin Liška 2017-09-15 08:14:30 UTC
Author: marxin
Date: Fri Sep 15 08:13:58 2017
New Revision: 252785

URL: https://gcc.gnu.org/viewcvs?rev=252785&root=gcc&view=rev
Log:
Backport r251020

2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* c-attribs.c (handle_target_attribute):
	Report warning for an empty string argument of target attribute.
2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/other/pr81355.C
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/c-family/c-attribs.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 6 Martin Liška 2017-09-15 09:17:51 UTC
Author: marxin
Date: Fri Sep 15 09:17:18 2017
New Revision: 252795

URL: https://gcc.gnu.org/viewcvs?rev=252795&root=gcc&view=rev
Log:
Backport r251020

2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* c-attribs.c (handle_target_attribute):
	Report warning for an empty string argument of target attribute.
2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/other/pr81355.C
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/c-family/c-common.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 7 Martin Liška 2017-09-15 12:14:33 UTC
Author: marxin
Date: Fri Sep 15 12:14:01 2017
New Revision: 252811

URL: https://gcc.gnu.org/viewcvs?rev=252811&root=gcc&view=rev
Log:
Backport r251020

2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* c-attribs.c (handle_target_attribute):
	Report warning for an empty string argument of target attribute.
2017-09-15  Martin Liska  <mliska@suse.cz>

	Backport from mainline
	2017-08-10  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* g++.dg/other/pr81355.C: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/other/pr81355.C
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/c-family/c-common.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 8 Martin Liška 2017-09-15 12:17:19 UTC
Fixed on all active branches.
Comment 9 Martin Liška 2017-09-19 08:13:29 UTC
Author: marxin
Date: Tue Sep 19 08:12:58 2017
New Revision: 252965

URL: https://gcc.gnu.org/viewcvs?rev=252965&root=gcc&view=rev
Log:
Ignore empty string in target attribute (PR c++/81355).

2017-09-19  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* config/i386/i386.c (sorted_attr_string): Skip empty strings.

Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/config/i386/i386.c
Comment 10 Martin Liška 2017-09-19 08:18:33 UTC
Author: marxin
Date: Tue Sep 19 08:18:02 2017
New Revision: 252967

URL: https://gcc.gnu.org/viewcvs?rev=252967&root=gcc&view=rev
Log:
Ignore empty string in target attribute (PR c++/81355).

2017-09-19  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* config/i386/i386.c (sorted_attr_string): Skip empty strings.

Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/config/i386/i386.c
Comment 11 Martin Liška 2017-09-19 09:03:37 UTC
Author: marxin
Date: Tue Sep 19 09:03:05 2017
New Revision: 252970

URL: https://gcc.gnu.org/viewcvs?rev=252970&root=gcc&view=rev
Log:
Ignore empty string in target attribute (PR c++/81355).

2017-09-19  Martin Liska  <mliska@suse.cz>

	PR c++/81355
	* config/i386/i386.c (sorted_attr_string): Skip empty strings.

Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/config/i386/i386.c