Skip to content

Commit

Permalink
EventPipe C library CoreClr ep_rt_object_array_alloc should zero init. (
Browse files Browse the repository at this point in the history
#47111)

EventPipe C library is defensive in its type allocators:

ep_rt_object_alloc
ep_rt_object_array_alloc

meaning that they will zero init memory before returned. On Mono this is
done through use of g_new0 and on CoreClr we use C++11 zero init feature
when allocating struct (only type allocated through these functions).

On CoreClr this was only applied for ep_rt_object_alloc but not for
ep_rt_object_array_alloc meaning that ep_rt_object_array_alloc would
return arrays of allocated objects but not zero initialized.

PR makes sure we call new (nothrow) utilizing C++11's zero initialization
capabilities of non-class types without constructors.
  • Loading branch information
lateralusX authored Jan 21, 2021
1 parent ed5137a commit 16e6e95
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ ep_rt_execute_rundown (void)

// STATIC_CONTRACT_NOTHROW
#undef ep_rt_object_array_alloc
#define ep_rt_object_array_alloc(obj_type,size) (new (nothrow) obj_type [size])
#define ep_rt_object_array_alloc(obj_type,size) (new (nothrow) obj_type [size]())

// STATIC_CONTRACT_NOTHROW
#undef ep_rt_object_array_free
Expand Down

0 comments on commit 16e6e95

Please sign in to comment.