aboutsummaryrefslogtreecommitdiff
path: root/malloc/trace_run.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2016-07-15 18:26:14 -0400
committerDJ Delorie <dj@delorie.com>2016-07-15 18:26:14 -0400
commitfcf17bd0d948d19c84ab72ba0a57688f4533327d (patch)
tree3e0fa732760cc78497e8c9d2f89255ea81f91ac9 /malloc/trace_run.c
parent0eacff38a33d1d8e0f2899f53422c567061cc075 (diff)
downloadglibc-fcf17bd0d948d19c84ab72ba0a57688f4533327d.tar.xz
glibc-fcf17bd0d948d19c84ab72ba0a57688f4533327d.zip
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.
Diffstat (limited to 'malloc/trace_run.c')
-rw-r--r--malloc/trace_run.c16
1 files changed, 16 insertions, 0 deletions
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