mirror of
https://github.com/amd/blis.git
synced 2026-04-19 23:28:52 +00:00
Initialize mem_t structures safely and handle NULL communicator in threading
- Explicitly initialize all fields of mem_t structures in bli_znormfv_unb_var1 and bli_dnormfv_unb_var1 to prevent undefined behavior when memory is not allocated. - Add a NULL check after bli_thread_broadcast() in bli_thrinfo_sup_create_for_cntl to ensure that the communicator is valid, and call bli_abort() if broadcast fails.
This commit is contained in:
@@ -231,6 +231,12 @@ thrinfo_t* bli_thrinfo_sup_create_for_cntl
|
||||
// communicator.
|
||||
new_comms = bli_thread_broadcast( thread_par, new_comms );
|
||||
|
||||
// Check if broadcast failed (can happen when parent communicator is NULL)
|
||||
if ( new_comms == NULL )
|
||||
{
|
||||
bli_abort();
|
||||
}
|
||||
|
||||
// Chiefs in the child communicator allocate the communicator
|
||||
// object and store it in the array element corresponding to the
|
||||
// parent's work id.
|
||||
|
||||
@@ -573,8 +573,21 @@ void bli_znormfv_unb_var1
|
||||
an allocated memory if created or a NULL .
|
||||
*/
|
||||
|
||||
mem_t mem_buf_X = { 0 };
|
||||
mem_t mem_buf_X;
|
||||
inc_t incx_buf = incx;
|
||||
|
||||
/*
|
||||
Initialize mem pool buffer to NULL and size to 0
|
||||
"buf" and "size" fields are assigned once memory
|
||||
is allocated from the pool in bli_pba_acquire_m().
|
||||
This will ensure bli_mem_is_alloc() will be passed on
|
||||
an allocated memory if created or a NULL .
|
||||
*/
|
||||
mem_buf_X.pblk.buf = NULL;
|
||||
mem_buf_X.pblk.block_size = 0;
|
||||
mem_buf_X.buf_type = 0;
|
||||
mem_buf_X.size = 0;
|
||||
mem_buf_X.pool = NULL;
|
||||
|
||||
// Packing for non-unit strided vector x.
|
||||
// In order to get the buffer from pool via rntm access to memory broker
|
||||
@@ -655,7 +668,20 @@ void bli_znormfv_unb_var1
|
||||
the local results will finally be reduced as per the mandate.
|
||||
*/
|
||||
|
||||
mem_t mem_buf_norm = { 0 };
|
||||
mem_t mem_buf_norm;
|
||||
|
||||
/*
|
||||
Initialize mem pool buffer to NULL and size to 0
|
||||
"buf" and "size" fields are assigned once memory
|
||||
is allocated from the pool in bli_pba_acquire_m().
|
||||
This will ensure bli_mem_is_alloc() will be passed on
|
||||
an allocated memory if created or a NULL .
|
||||
*/
|
||||
mem_buf_norm.pblk.buf = NULL;
|
||||
mem_buf_norm.pblk.block_size = 0;
|
||||
mem_buf_norm.buf_type = 0;
|
||||
mem_buf_norm.size = 0;
|
||||
mem_buf_norm.pool = NULL;
|
||||
|
||||
double *norm_per_thread = NULL;
|
||||
|
||||
@@ -1203,9 +1229,22 @@ void bli_dnormfv_unb_var1
|
||||
an allocated memory if created or a NULL .
|
||||
*/
|
||||
|
||||
mem_t mem_buf_X = { 0 };
|
||||
mem_t mem_buf_X;
|
||||
inc_t incx_buf = incx;
|
||||
|
||||
/*
|
||||
Initialize mem pool buffer to NULL and size to 0
|
||||
"buf" and "size" fields are assigned once memory
|
||||
is allocated from the pool in bli_pba_acquire_m().
|
||||
This will ensure bli_mem_is_alloc() will be passed on
|
||||
an allocated memory if created or a NULL .
|
||||
*/
|
||||
mem_buf_X.pblk.buf = NULL;
|
||||
mem_buf_X.pblk.block_size = 0;
|
||||
mem_buf_X.buf_type = 0;
|
||||
mem_buf_X.size = 0;
|
||||
mem_buf_X.pool = NULL;
|
||||
|
||||
// Packing for non-unit strided vector x.
|
||||
// In order to get the buffer from pool via rntm access to memory broker
|
||||
// is needed. Following are initializations for rntm.
|
||||
|
||||
Reference in New Issue
Block a user