From 924d88bbf94ae4467dcc23917ad083b1caf33683 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Tue, 17 Jan 2023 13:06:25 +0100 Subject: [PATCH] bugfix: avoid a crash when oai_exit is set There was a crash when we exit the nr softmodem with AW2S device. The array rxbase[] was surely freed() by some other thread, so let's not access it after detecting oai_exit != 0. We also need to unblock a possible reader thread. The chosen way to do may be not the best. To be checked. --- radio/ETHERNET/USERSPACE/LIB/eth_udp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/radio/ETHERNET/USERSPACE/LIB/eth_udp.c b/radio/ETHERNET/USERSPACE/LIB/eth_udp.c index ca62ceab6c..c098d4f539 100644 --- a/radio/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/radio/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -451,6 +451,11 @@ void *udp_read_thread(void *arg) { buffer,sizeof(buffer),0, (struct sockaddr *)&((eth_state_t*)device->priv)->dest_addrd, (socklen_t *)&((eth_state_t*)device->priv)->addr_len); + /* if oai_exit is 1 here, don't access the array rxbase, + * it may have been freed(), so let's break at this point + */ + if (oai_exit) + break; aid = *(uint16_t*)(&buffer[ECPRICOMMON_BYTES]); TS = *(openair0_timestamp *)(&buffer[ECPRICOMMON_BYTES+ECPRIPCID_BYTES]); // convert TS to samples, /6 for AW2S @ 30.72 Ms/s, this is converted for other sample rates in OAI application @@ -475,6 +480,11 @@ void *udp_read_thread(void *arg) { } sleep(1); } + + /* let's unblock reader (maybe not the best way to do it) */ + fhstate->first_read = 0; + fhstate->r[0] = 1; + return(0); }