Commit 516d4b9f authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/use-memsan' into integration_2023_w28

parents 92ba679b 49be2e9b
...@@ -189,6 +189,18 @@ if (SANITIZE_UNDEFINED) ...@@ -189,6 +189,18 @@ if (SANITIZE_UNDEFINED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
endif () endif ()
add_boolean_option(SANITIZE_MEMORY False "enable the memory sanitizer (MSan, requires clang, incompatible with ASan/UBSan)" ON)
if(SANITIZE_MEMORY)
if (SANITIZE_UNDEFINED OR SANITIZE_ADDRESS)
message(FATAL_ERROR "memory sanitizer cannot coexist with address sanitizer or undefined behavior sanitizer, please disable either MSan or ASan and UBSan")
endif()
if (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
message(FATAL_ERROR "memory sanitizer requires clang, please set clang using CC=/usr/bin/clang CXX=/usr/bin/clang++ ./build_oai ...")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -fsanitize-recover=memory")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -fsanitize-recover=memory")
endif()
add_definitions("-DASN_DISABLE_OER_SUPPORT -DHAVE_CONFIG_H -DHAVE_CONFIG_H_") add_definitions("-DASN_DISABLE_OER_SUPPORT -DHAVE_CONFIG_H -DHAVE_CONFIG_H_")
######################### #########################
......
...@@ -155,6 +155,10 @@ Options: ...@@ -155,6 +155,10 @@ Options:
Enable the address sanitizer on all targets Enable the address sanitizer on all targets
--sanitize-undefined | -fsanitize=undefined --sanitize-undefined | -fsanitize=undefined
Enable the undefined behavior sanitizer on all targets Enable the undefined behavior sanitizer on all targets
--sanitize-memory | -fsanitize=memory
Enable the memory sanitizer on all targets. Requires clang, and is
incompatible with ASan/UBSan. To build, issue:
CC=/usr/bin/clang CXX=/usr/bin/clang++ ./build_oai ... --sanitize-memory
-h | --help -h | --help
Print this help" Print this help"
} }
...@@ -407,6 +411,11 @@ function main() { ...@@ -407,6 +411,11 @@ function main() {
--sanitize-undefined | -fundefined=address) --sanitize-undefined | -fundefined=address)
CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True" CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True"
shift;; shift;;
--sanitize-memory | -fsanitize=memory)
echo_warning "Note: memory sanitizer\n* requires clang (tested: v17)\n* is incompatible with address/undefined behavior sanitizer\n* requires cmake_targets/tools/memsan.patch"
sleep 2
CMAKE_CMD="$CMAKE_CMD -DSANITIZE_MEMORY=ON -DSANITIZE_ADDRESS=OFF -DSANITIZE_UNDEFINED=OFF"
shift;;
-h | --help) -h | --help)
print_help print_help
exit 1;; exit 1;;
......
commit bf7f0c4f0f1bfce586667b50050640b67a7a747a
Author: Robert Schmidt <robert.schmidt@openairinterface.org>
Date: Wed Jun 7 18:24:50 2023 +0200
Fix dlopen() linker errors in dfts, ldpc, ldpc_parityCheck, and params_libconfig
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c29105d503..3b9e7d1246 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -508,7 +508,7 @@ add_library(CONFIG_LIB
)
target_link_libraries(CONFIG_LIB PRIVATE dl UTIL)
add_library(params_libconfig MODULE ${CONFIG_ROOTDIR}/libconfig/config_libconfig.c)
-target_link_libraries(params_libconfig config)
+target_link_libraries(params_libconfig config CONFIG_LIB minimal_lib)
# shared library loader
set (SHLIB_LOADER_SOURCES
${OPENAIR_DIR}/common/utils/load_module_shlib.c
@@ -1018,16 +1018,19 @@ if (ENABLE_LDPC_CUDA)
endif()
endif()
-add_library(ldpc MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} )
+add_library(ldpc MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} ${OPENAIR1_DIR}/PHY/CODING/crc_byte.c)
target_link_libraries(ldpc PRIVATE ldpc_gen_HEADERS)
+target_link_libraries(ldpc PRIVATE UTIL)
add_library(ldpc_parityCheck MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} )
target_compile_definitions(ldpc_parityCheck PUBLIC NR_LDPC_ENABLE_PARITY_CHECK)
target_link_libraries(ldpc_parityCheck PRIVATE ldpc_gen_HEADERS)
+target_link_libraries(ldpc_parityCheck PRIVATE UTIL minimal_lib)
add_library(coding MODULE ${PHY_TURBOSRC} )
add_library(dfts MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts.c )
+target_link_libraries(dfts PRIVATE minimal_lib)
set(PHY_SRC_COMMON
diff --git a/common/utils/minimal_stub.c b/common/utils/minimal_stub.c
index be9c1b399d..7ad0df4d56 100644
--- a/common/utils/minimal_stub.c
+++ b/common/utils/minimal_stub.c
@@ -1,6 +1,8 @@
+#include <stdlib.h>
#ifndef T_TRACER
int T_stdout;
#endif
+int oai_exit = 0;
void exit_function(const char *file, const char *function, const int line, const char *s, const int assert)
{
...@@ -253,7 +253,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, ...@@ -253,7 +253,9 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
uint8_t index=0; uint8_t index=0;
int nb_re_pucch = 12*pucch_pdu->prb_size; // prb size is 1 int nb_re_pucch = 12*pucch_pdu->prb_size; // prb size is 1
int32_t rp[frame_parms->nb_antennas_rx][pucch_pdu->nr_of_symbols][nb_re_pucch],*tmp_rp; int32_t rp[frame_parms->nb_antennas_rx][pucch_pdu->nr_of_symbols][nb_re_pucch];
memset(rp, 0, sizeof(rp));
int32_t *tmp_rp = NULL;
for (int l=0; l<pucch_pdu->nr_of_symbols; l++) { for (int l=0; l<pucch_pdu->nr_of_symbols; l++) {
uint8_t l2 = l + pucch_pdu->start_symbol_index; uint8_t l2 = l + pucch_pdu->start_symbol_index;
...@@ -1169,7 +1171,9 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, ...@@ -1169,7 +1171,9 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB,
int nb_re_pucch = 12*pucch_pdu->prb_size; int nb_re_pucch = 12*pucch_pdu->prb_size;
int16_t rp[Prx2][2][nb_re_pucch*2],*tmp_rp; int16_t rp[Prx2][2][nb_re_pucch*2];
memset(rp, 0, sizeof(rp));
int16_t *tmp_rp = NULL;
__m64 dmrs_re,dmrs_im; __m64 dmrs_re,dmrs_im;
for (int aa=0;aa<Prx;aa++){ for (int aa=0;aa<Prx;aa++){
......
...@@ -411,7 +411,7 @@ int main(int argc, char **argv) ...@@ -411,7 +411,7 @@ int main(int argc, char **argv)
} }
//configure UE //configure UE
UE = malloc(sizeof(PHY_VARS_NR_UE)); UE = calloc(1, sizeof(*UE));
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
//phy_init_nr_top(frame_parms); //phy_init_nr_top(frame_parms);
......
...@@ -123,7 +123,7 @@ int main(int argc, char **argv) ...@@ -123,7 +123,7 @@ int main(int argc, char **argv)
int16_t amp=0x7FFF; int16_t amp=0x7FFF;
int nr_slot_tx=0; int nr_slot_tx=0;
int nr_frame_tx=0; int nr_frame_tx=0;
uint64_t actual_payload=0,payload_received; uint64_t actual_payload = 0, payload_received = 0;
bool random_payload = true; bool random_payload = true;
int nr_bit=1; // maximum value possible is 2 int nr_bit=1; // maximum value possible is 2
uint8_t m0=0;// higher layer paramater initial cyclic shift uint8_t m0=0;// higher layer paramater initial cyclic shift
......
...@@ -427,7 +427,7 @@ int main(int argc, char **argv) ...@@ -427,7 +427,7 @@ int main(int argc, char **argv)
phy_init_nr_gNB(gNB); phy_init_nr_gNB(gNB);
//configure UE //configure UE
UE = malloc(sizeof(PHY_VARS_NR_UE)); UE = calloc(1, sizeof(*UE));
memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS)); memcpy(&UE->frame_parms, frame_parms, sizeof(NR_DL_FRAME_PARMS));
UE->frame_parms.nb_antennas_tx = n_tx; UE->frame_parms.nb_antennas_tx = n_tx;
......
...@@ -110,7 +110,7 @@ void fill_channel_desc(channel_desc_t *chan_desc, ...@@ -110,7 +110,7 @@ void fill_channel_desc(channel_desc_t *chan_desc,
LOG_D(OCM,"[CHANNEL] Doing delays ...\n"); LOG_D(OCM,"[CHANNEL] Doing delays ...\n");
if (delays==NULL) { if (delays==NULL) {
chan_desc->delays = (double *) malloc(nb_taps*sizeof(double)); chan_desc->delays = calloc(nb_taps, sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_DELAY ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_DELAY ;
delta_tau = Td/nb_taps; delta_tau = Td/nb_taps;
...@@ -131,22 +131,22 @@ void fill_channel_desc(channel_desc_t *chan_desc, ...@@ -131,22 +131,22 @@ void fill_channel_desc(channel_desc_t *chan_desc,
chan_desc->first_run = 1; chan_desc->first_run = 1;
chan_desc->ip = 0.0; chan_desc->ip = 0.0;
chan_desc->max_Doppler = max_Doppler; chan_desc->max_Doppler = max_Doppler;
chan_desc->ch = (struct complexd **) malloc(nb_tx*nb_rx*sizeof(struct complexd *)); chan_desc->ch = calloc(nb_tx*nb_rx, sizeof(struct complexd *));
chan_desc->chF = (struct complexd **) malloc(nb_tx*nb_rx*sizeof(struct complexd *)); chan_desc->chF = calloc(nb_tx*nb_rx, sizeof(struct complexd *));
chan_desc->a = (struct complexd **) malloc(nb_taps*sizeof(struct complexd *)); chan_desc->a = calloc(nb_taps, sizeof(struct complexd *));
LOG_D(OCM,"[CHANNEL] Filling ch \n"); LOG_D(OCM,"[CHANNEL] Filling ch \n");
for (i = 0; i<nb_tx*nb_rx; i++) for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complexd *) malloc(channel_length * sizeof(struct complexd)); chan_desc->ch[i] = calloc(channel_length, sizeof(struct complexd));
for (i = 0; i<nb_tx*nb_rx; i++) for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complexd *) malloc(275 * 12 * sizeof(struct complexd)); // allocate for up to 275 RBs, 12 symbols per RB chan_desc->chF[i] = calloc(275 * 12, sizeof(struct complexd)); // allocate for up to 275 RBs, 12 symbols per RB
LOG_D(OCM,"[CHANNEL] Filling a (nb_taps %d)\n",nb_taps); LOG_D(OCM,"[CHANNEL] Filling a (nb_taps %d)\n",nb_taps);
for (i = 0; i<nb_taps; i++) { for (i = 0; i<nb_taps; i++) {
LOG_D(OCM,"tap %d (%p,%zu)\n",i,&chan_desc->a[i],nb_tx*nb_rx * sizeof(struct complexd)); LOG_D(OCM,"tap %d (%p,%zu)\n",i,&chan_desc->a[i],nb_tx*nb_rx * sizeof(struct complexd));
chan_desc->a[i] = (struct complexd *) malloc(nb_tx*nb_rx * sizeof(struct complexd)); chan_desc->a[i] = calloc(nb_tx*nb_rx, sizeof(struct complexd));
} }
LOG_D(OCM,"[CHANNEL] Doing R_sqrt ...\n"); LOG_D(OCM,"[CHANNEL] Doing R_sqrt ...\n");
...@@ -367,7 +367,7 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS ...@@ -367,7 +367,7 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS
2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td));
printf("TDL : %f Ms/s, nb_taps %d, Td %e, channel_length %d\n",chan_desc->sampling_rate,tdl_paths,chan_desc->Td,chan_desc->channel_length); printf("TDL : %f Ms/s, nb_taps %d, Td %e, channel_length %d\n",chan_desc->sampling_rate,tdl_paths,chan_desc->Td,chan_desc->channel_length);
double sum_amps = 0; double sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = calloc(chan_desc->nb_taps, sizeof(double));
for (int i = 0; i<chan_desc->nb_taps; i++) { for (int i = 0; i<chan_desc->nb_taps; i++) {
chan_desc->amps[i] = pow(10,.1*tdl_amps_dB[i]); chan_desc->amps[i] = pow(10,.1*tdl_amps_dB[i]);
...@@ -382,19 +382,19 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS ...@@ -382,19 +382,19 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS
chan_desc->delays = tdl_delays; chan_desc->delays = tdl_delays;
chan_desc->aoa = 0; chan_desc->aoa = 0;
chan_desc->random_aoa = 0; chan_desc->random_aoa = 0;
chan_desc->ch = (struct complexd **) malloc(nb_tx*nb_rx*sizeof(struct complexd *)); chan_desc->ch = calloc(nb_tx*nb_rx, sizeof(struct complexd *));
chan_desc->chF = (struct complexd **) malloc(nb_tx*nb_rx*sizeof(struct complexd *)); chan_desc->chF = calloc(nb_tx*nb_rx, sizeof(struct complexd *));
chan_desc->a = (struct complexd **) malloc(chan_desc->nb_taps*sizeof(struct complexd *)); chan_desc->a = calloc(chan_desc->nb_taps, sizeof(struct complexd *));
chan_desc->ricean_factor = 1.0; chan_desc->ricean_factor = 1.0;
for (int i = 0; i<nb_tx*nb_rx; i++) for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complexd *) malloc(chan_desc->channel_length * sizeof(struct complexd)); chan_desc->ch[i] = calloc(chan_desc->channel_length, sizeof(struct complexd));
for (int i = 0; i<nb_tx*nb_rx; i++) for (int i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complexd *) malloc((2+(275*12)) * sizeof(struct complexd)); chan_desc->chF[i] = calloc(2+(275*12), sizeof(struct complexd));
for (int i = 0; i<chan_desc->nb_taps; i++) for (int i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complexd *) malloc(nb_tx*nb_rx * sizeof(struct complexd)); chan_desc->a[i] = calloc(nb_tx*nb_rx, sizeof(struct complexd));
int matrix_size = nb_tx*nb_rx; int matrix_size = nb_tx*nb_rx;
double *correlation_matrix[matrix_size]; double *correlation_matrix[matrix_size];
...@@ -446,9 +446,9 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS ...@@ -446,9 +446,9 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS
} }
} }
chan_desc->R_sqrt = (struct complexd **) malloc(matrix_size*sizeof(struct complexd **)); chan_desc->R_sqrt = calloc(matrix_size, sizeof(*chan_desc->R_sqrt));
for (int row = 0; row < matrix_size; row++) { for (int row = 0; row < matrix_size; row++) {
chan_desc->R_sqrt[row] = (struct complexd *) calloc(1, matrix_size*sizeof(struct complexd)); chan_desc->R_sqrt[row] = calloc(matrix_size, sizeof(**chan_desc->R_sqrt));
if (correlation_matrix[row] == NULL) { if (correlation_matrix[row] == NULL) {
// TS 38.104 - Table G.2.3.1.2-4: MIMO correlation matrices for low correlation // TS 38.104 - Table G.2.3.1.2-4: MIMO correlation matrices for low correlation
chan_desc->R_sqrt[row][row].r = 1.0; chan_desc->R_sqrt[row][row].r = 1.0;
...@@ -637,7 +637,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -637,7 +637,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->Td = 4.625; chan_desc->Td = 4.625;
chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td)); chan_desc->channel_length = (int) (2*chan_desc->sampling_rate*chan_desc->Td + 1 + 2/(M_PI*M_PI)*log(4*M_PI*chan_desc->sampling_rate*chan_desc->Td));
sum_amps = 0; sum_amps = 0;
chan_desc->amps = (double *) malloc(chan_desc->nb_taps*sizeof(double)); chan_desc->amps = calloc(chan_desc->nb_taps, sizeof(double));
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_AMPS ;
for (i = 0; i<chan_desc->nb_taps; i++) { for (i = 0; i<chan_desc->nb_taps; i++) {
...@@ -657,15 +657,15 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -657,15 +657,15 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->a = (struct complexd **) malloc(chan_desc->nb_taps*sizeof(struct complexd *)); chan_desc->a = (struct complexd **) malloc(chan_desc->nb_taps*sizeof(struct complexd *));
for (i = 0; i<nb_tx*nb_rx; i++) for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->ch[i] = (struct complexd *) malloc(chan_desc->channel_length * sizeof(struct complexd)); chan_desc->ch[i] = calloc(chan_desc->channel_length, sizeof(struct complexd));
for (i = 0; i<nb_tx*nb_rx; i++) for (i = 0; i<nb_tx*nb_rx; i++)
chan_desc->chF[i] = (struct complexd *) malloc(1200 * sizeof(struct complexd)); chan_desc->chF[i] = calloc(1200, sizeof(struct complexd));
for (i = 0; i<chan_desc->nb_taps; i++) for (i = 0; i<chan_desc->nb_taps; i++)
chan_desc->a[i] = (struct complexd *) malloc(nb_tx*nb_rx * sizeof(struct complexd)); chan_desc->a[i] = calloc(nb_tx*nb_rx, sizeof(struct complexd));
chan_desc->R_sqrt = (struct complexd **) malloc(6*sizeof(struct complexd **)); chan_desc->R_sqrt = calloc(6, sizeof(struct complexd **));
if (nb_tx==2 && nb_rx==2) { if (nb_tx==2 && nb_rx==2) {
for (i = 0; i<6; i++) for (i = 0; i<6; i++)
...@@ -680,7 +680,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx, ...@@ -680,7 +680,7 @@ channel_desc_t *new_channel_desc_scm(uint8_t nb_tx,
chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ; chan_desc->free_flags=chan_desc->free_flags|CHANMODEL_FREE_RSQRT_6 ;
for (i = 0; i<6; i++) { for (i = 0; i<6; i++) {
chan_desc->R_sqrt[i] = (struct complexd *) malloc(nb_tx*nb_rx*nb_tx*nb_rx * sizeof(struct complexd)); chan_desc->R_sqrt[i] = calloc(nb_tx*nb_rx*nb_tx*nb_rx, sizeof(struct complexd));
for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) { for (j = 0; j<nb_tx*nb_rx*nb_tx*nb_rx; j+=(nb_tx*nb_rx+1)) {
chan_desc->R_sqrt[i][j].r = 1.0; chan_desc->R_sqrt[i][j].r = 1.0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment