Patchwork [ubsan] Don't always use NORETURN

login
register
mail settings
Submitter Marek Polacek
Date July 15, 2013, 6:32 a.m.
Message ID <20130715063229.GK3697@redhat.com>
Download mbox | patch
Permalink /patch/258958/
State New
Headers show

Comments

Marek Polacek - July 15, 2013, 6:32 a.m.
Some libubsan functions aren't really noreturn, so don't mark them as
such.  This prevents failures with -O1+, since we don't generate any
code after calling noreturn routines, thus segfault when we actually
get there.

Applying to ubsan branch.

2013-07-15  Marek Polacek  <polacek@redhat.com>

	* builtin-attrs.def (ATTR_COLD_NOTHROW_LEAF_LIST): Define.
	* sanitizer.def (BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW): Don't mark
	as NORETURN.
	(BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS): Likewise.
	* asan.c (ATTR_COLD_NOTHROW_LEAF_LIST): Define.


	Marek

Patch

--- gcc/builtin-attrs.def.mp2	2013-07-15 07:52:25.339442743 +0200
+++ gcc/builtin-attrs.def	2013-07-15 08:16:45.725146824 +0200
@@ -131,6 +131,8 @@  DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHRO
 			ATTR_NULL, ATTR_NOTHROW_LIST)
 DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LEAF_LIST, ATTR_NORETURN,\
 			ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
+DEF_ATTR_TREE_LIST (ATTR_COLD_NOTHROW_LEAF_LIST, ATTR_COLD,\
+			ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
 DEF_ATTR_TREE_LIST (ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST, ATTR_COLD,\
 			ATTR_NULL, ATTR_NORETURN_NOTHROW_LEAF_LIST)
 DEF_ATTR_TREE_LIST (ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST, ATTR_CONST,\
--- gcc/sanitizer.def.mp2	2013-07-15 07:47:46.080293252 +0200
+++ gcc/sanitizer.def	2013-07-15 08:17:03.830219023 +0200
@@ -288,11 +288,11 @@  DEF_SANITIZER_BUILTIN(BUILT_IN_TSAN_ATOM
 DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_DIVREM_OVERFLOW,
 		      "__ubsan_handle_divrem_overflow",
 		      BT_FN_VOID_PTR_PTR_PTR,
-		      ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST)
+		      ATTR_COLD_NOTHROW_LEAF_LIST)
 DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_SHIFT_OUT_OF_BOUNDS,
 		      "__ubsan_handle_shift_out_of_bounds",
 		      BT_FN_VOID_PTR_PTR_PTR,
-		      ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST)
+		      ATTR_COLD_NOTHROW_LEAF_LIST)
 DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE,
 		      "__ubsan_handle_builtin_unreachable",
 		      BT_FN_VOID_PTR,
--- gcc/asan.c.mp2	2013-07-15 07:46:29.786987718 +0200
+++ gcc/asan.c	2013-07-15 08:21:21.224095627 +0200
@@ -2102,6 +2102,9 @@  initialize_sanitizer_builtins (void)
 #undef ATTR_TMPURE_NORETURN_NOTHROW_LEAF_LIST
 #define ATTR_TMPURE_NORETURN_NOTHROW_LEAF_LIST \
   ECF_TM_PURE | ATTR_NORETURN_NOTHROW_LEAF_LIST
+#undef ATTR_COLD_NOTHROW_LEAF_LIST
+#define ATTR_COLD_NOTHROW_LEAF_LIST \
+  /* ECF_COLD missing */ ATTR_NOTHROW_LEAF_LIST
 #undef ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST
 #define ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST \
   /* ECF_COLD missing */ ATTR_NORETURN_NOTHROW_LEAF_LIST