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.
case __MTB_TYPE_MALLOC:
case __MTB_TYPE_CALLOC:
acq_ptr (thread, pa2);
- if (pa2->valid)
+ if (pa2 && pa2->valid)
printf ("%d: pointer %p malloc'd again? %d:%s\n", i, pa2->ptr, pa2->reason_idx, pa2->reason);
thread->add (r->type == __MTB_TYPE_MALLOC ? C_MALLOC : C_CALLOC);
- thread->add_int (pa2->idx);
+ thread->add_int (pa2 ? pa2->idx : 0);
thread->add_int (r->size);
- pa2->valid = 1;
- pa2->reason = "malloc";
- pa2->reason_idx = i;
+ if (pa2)
+ {
+ pa2->valid = 1;
+ pa2->reason = "malloc";
+ pa2->reason_idx = i;
+ }
break;
case __MTB_TYPE_FREE:
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();
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])
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