From fcf17bd0d948d19c84ab72ba0a57688f4533327d Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Fri, 15 Jul 2016 18:26:14 -0400 Subject: Fix NULL return value handling Decided that a call that returns NULL should be encoded in the workload but that the simulator should just skip those calls, rather than skip them in the converter. --- malloc/trace_run.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'malloc/trace_run.c') diff --git a/malloc/trace_run.c b/malloc/trace_run.c index a42e81d80f..e64b18981a 100644 --- a/malloc/trace_run.c +++ b/malloc/trace_run.c @@ -242,6 +242,9 @@ thread_common (void *my_data_v) p2 = get_int (&cp); sz = get_int (&cp); dprintf("op %d:%ld %ld = MALLOC %ld\n", (int)me, cp-data, p2, sz); + /* we can't force malloc to return NULL (fail), so just skip it. */ + if (p2 == 0) + break; if (p2 > n_ptrs) myabort(); stime = rdtsc_s(); @@ -271,6 +274,9 @@ thread_common (void *my_data_v) p2 = get_int (&cp); sz = get_int (&cp); dprintf("op %d:%ld %ld = CALLOC %ld\n", (int)me, cp-data, p2, sz); + /* we can't force calloc to return NULL (fail), so just skip it. */ + if (p2 == 0) + break; if (p2 > n_ptrs) myabort(); if (ptrs[p2]) @@ -303,6 +309,16 @@ thread_common (void *my_data_v) if (ptrs[p1]) atomic_rss (-sizes[p1]); free_wipe(p1); + /* we can't force realloc to return NULL (fail), so just skip it. */ + if (p2 == 0) + { + if (p1) + { + free ((void *)ptrs[p1]); + ptrs[p1] = 0; + } + break; + } stime = rdtsc_s(); Q1; #ifdef MDEBUG -- cgit v1.2.3