summaryrefslogtreecommitdiff
path: root/rdoff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-08-28 18:32:46 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-08-28 18:32:46 -0700
commit6a4353c4c29274fb2df6ca712fad70b8701c9187 (patch)
tree81456594614ae6120f6b1f0746d3c146ee890539 /rdoff
parentf8a15a8ea3cc3484f4250fd878569f15412434ab (diff)
downloadnasm-6a4353c4c29274fb2df6ca712fad70b8701c9187.tar.gz
errors: be more robust in handling unexpected fatal errors
Introduce a new error level, ERR_CRITICAL, beyond which we will minimize the amount of code that will be executed before we die; in particular don't execute any memory allocations, and if we somehow end up recursing, abort() immediately. Basically, "less than panic, more than fatal." At this point this level is used by nasm_alloc_failed(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'rdoff')
-rw-r--r--rdoff/rdoff.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/rdoff/rdoff.c b/rdoff/rdoff.c
index 3fd2a0e9..bdba82ae 100644
--- a/rdoff/rdoff.c
+++ b/rdoff/rdoff.c
@@ -228,12 +228,18 @@ int rdf_errno = 0;
/* ========================================================================
* Hook for nasm_error() to work
* ======================================================================== */
-static void rdoff_verror(errflags severity, const char *fmt, va_list val)
+fatal_func nasm_verror_critical(errflags severity, const char *fmt, va_list val)
{
vfprintf(stderr, fmt, val);
+ exit((severity & ERR_MASK) - ERR_FATAL + 2);
+}
+static void rdoff_verror(errflags severity, const char *fmt, va_list val)
+{
if ((severity & ERR_MASK) >= ERR_FATAL)
- exit(1);
+ nasm_verror_critical(severity, fmt, val);
+ else
+ vfprintf(stderr, fmt, val);
}
void rdoff_init(void)