Message ID | 1423617597-32752-1-git-send-email-stewart@linux.vnet.ibm.com |
---|---|
State | Accepted |
Headers | show |
On Wed, Feb 11, 2015 at 12:19:57PM +1100, Stewart Smith wrote: > Why not this patch instead? If no objections, I'll apply it. I do think > we could probably change some of our abort()s to be the assert of the > condition that fails though. This is a simpler approach, yes. > Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> > --- > core/utils.c | 4 ++-- > libc/include/stdlib.h | 8 +++++++- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/core/utils.c b/core/utils.c > index 1a81ae2..9c94ecc 100644 > --- a/core/utils.c > +++ b/core/utils.c > @@ -26,10 +26,10 @@ unsigned long __stack_chk_guard = 0xdeadf00dbaad300d; > void __noreturn assert_fail(const char *msg) > { > prlog(PR_EMERG, "Assert fail: %s\n", msg); > - abort(); > + _abort(); You probably also need _abort() in the stack protector code. Ananth
Ananth N Mavinakayanahalli <ananth@in.ibm.com> writes: > On Wed, Feb 11, 2015 at 12:19:57PM +1100, Stewart Smith wrote: >> Why not this patch instead? If no objections, I'll apply it. I do think >> we could probably change some of our abort()s to be the assert of the >> condition that fails though. > > This is a simpler approach, yes. Cool, I'll merge. >> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> >> --- >> core/utils.c | 4 ++-- >> libc/include/stdlib.h | 8 +++++++- >> 2 files changed, 9 insertions(+), 3 deletions(-) >> >> diff --git a/core/utils.c b/core/utils.c >> index 1a81ae2..9c94ecc 100644 >> --- a/core/utils.c >> +++ b/core/utils.c >> @@ -26,10 +26,10 @@ unsigned long __stack_chk_guard = 0xdeadf00dbaad300d; >> void __noreturn assert_fail(const char *msg) >> { >> prlog(PR_EMERG, "Assert fail: %s\n", msg); >> - abort(); >> + _abort(); > > You probably also need _abort() in the stack protector code. I think it ends up being okay as we do want to update attn area then, and now abort() will do that for us (previously it didn't).
diff --git a/core/utils.c b/core/utils.c index 1a81ae2..9c94ecc 100644 --- a/core/utils.c +++ b/core/utils.c @@ -26,10 +26,10 @@ unsigned long __stack_chk_guard = 0xdeadf00dbaad300d; void __noreturn assert_fail(const char *msg) { prlog(PR_EMERG, "Assert fail: %s\n", msg); - abort(); + _abort(); } -void __noreturn abort(void) +void __noreturn _abort(void) { static bool in_abort = false; unsigned long hid0; diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 4ab2825..68ca386 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -25,6 +25,12 @@ unsigned long int strtoul(const char *nptr, char **endptr, int base); long int strtol(const char *nptr, char **endptr, int base); int rand(void); -void __attribute__((noreturn)) abort(void); +void __attribute__((noreturn)) _abort(void); +#define abort() do { \ + update_sp_attn_area("abort():" __FILE__ \ + ":" stringify(__LINE__)); \ + _abort(); \ + } while(0) + #endif
Why not this patch instead? If no objections, I'll apply it. I do think we could probably change some of our abort()s to be the assert of the condition that fails though. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> --- core/utils.c | 4 ++-- libc/include/stdlib.h | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-)