From 10bc2ee8a188f45c85c55f10934c22bb0e1da2f5 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Mon, 20 Nov 2017 16:32:41 +0000 Subject: [PATCH 1/4] Fix for RLC AM polling condition --- lib/src/upper/rlc_am.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index f8abc0aef..7a7778a2f 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -395,7 +395,7 @@ bool rlc_am::poll_required() if(poll_retx()) return true; - if(tx_sdu_queue.size() == 0 && retx_queue.size() == 0) + if(tx_window.size() == 0 && retx_queue.size() == 0) return true; /* According to 5.2.2.1 in 36.322 v13.3.0 a poll should be requested if From 38ab9921f812daf317e29ed184aea41fb1e93566 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Tue, 21 Nov 2017 09:06:48 +0000 Subject: [PATCH 2/4] Undoing unnecessary RLC fix --- lib/src/upper/rlc_am.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index 7a7778a2f..f8abc0aef 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -395,7 +395,7 @@ bool rlc_am::poll_required() if(poll_retx()) return true; - if(tx_window.size() == 0 && retx_queue.size() == 0) + if(tx_sdu_queue.size() == 0 && retx_queue.size() == 0) return true; /* According to 5.2.2.1 in 36.322 v13.3.0 a poll should be requested if From 91e706d4d195767cfd4073ec1fd0438ca54c84b4 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 22 Nov 2017 12:23:46 +0100 Subject: [PATCH 3/4] Fixes #107: srslte_simd_f_sqrt NaN solved if input is 0 --- lib/include/srslte/phy/utils/simd.h | 7 ++++++- lib/src/phy/utils/test/vector_test.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/include/srslte/phy/utils/simd.h b/lib/include/srslte/phy/utils/simd.h index 09e9cff8e..a9a79c486 100644 --- a/lib/include/srslte/phy/utils/simd.h +++ b/lib/include/srslte/phy/utils/simd.h @@ -449,7 +449,12 @@ static inline simd_f_t srslte_simd_f_sqrt(simd_f_t a) { #ifdef HAVE_NEON float32x4_t sqrt_reciprocal = vrsqrteq_f32(a); sqrt_reciprocal = vmulq_f32(vrsqrtsq_f32(vmulq_f32(a,sqrt_reciprocal), sqrt_reciprocal),sqrt_reciprocal); - return vmulq_f32(a,sqrt_reciprocal); + float32x4_t result = vmulq_f32(a,sqrt_reciprocal); + + /* Detect zeros in NEON 1/sqrtf for preventing NaN */ + float32x4_t zeros = vmovq_n_f32(0); /* Zero vector */ + uint32x4_t mask = vceqq_f32(a, zeros); /* Zero vector mask */ + return vbslq_f32(mask, zeros, result); /* Force zero results and return */ #endif /* HAVE_NEON */ #endif /* LV_HAVE_SSE */ #endif /* LV_HAVE_AVX2 */ diff --git a/lib/src/phy/utils/test/vector_test.c b/lib/src/phy/utils/test/vector_test.c index 4ebed9862..9058e8813 100644 --- a/lib/src/phy/utils/test/vector_test.c +++ b/lib/src/phy/utils/test/vector_test.c @@ -502,6 +502,7 @@ TEST(srslte_vec_abs_cf, for (int i = 0; i < block_size; i++) { x[i] = RANDOM_CF(); } + x[0] = 0.0f; TEST_CALL(srslte_vec_abs_cf(x, z, block_size)) From 176dae270c28862d60bf3ac142293bf942d0782d Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 22 Nov 2017 16:00:07 +0100 Subject: [PATCH 4/4] Fixes #105. Added backtrace print in 'srsLTE.backtrace.crash' --- lib/examples/cell_measurement.c | 2 + lib/examples/cell_search.c | 2 + lib/examples/pdsch_enodeb.c | 2 + lib/examples/pdsch_ue.c | 2 + lib/include/srslte/phy/utils/debug.h | 2 + lib/src/phy/utils/debug.c | 61 ++++++++++++++++++++++++++++ srsenb/src/main.cc | 2 + srsue/src/main.cc | 3 ++ 8 files changed, 76 insertions(+) diff --git a/lib/examples/cell_measurement.c b/lib/examples/cell_measurement.c index bfb8194df..6415257f0 100644 --- a/lib/examples/cell_measurement.c +++ b/lib/examples/cell_measurement.c @@ -163,6 +163,8 @@ int main(int argc, char **argv) { float cfo = 0; bool acks[SRSLTE_MAX_CODEWORDS] = {false}; + srslte_debug_handle_crash(argc, argv); + if (parse_args(&prog_args, argc, argv)) { exit(-1); } diff --git a/lib/examples/cell_search.c b/lib/examples/cell_search.c index 281e3d102..9ecc79c72 100644 --- a/lib/examples/cell_search.c +++ b/lib/examples/cell_search.c @@ -153,6 +153,8 @@ int main(int argc, char **argv) { uint32_t freq; uint32_t n_found_cells=0; + srslte_debug_handle_crash(argc, argv); + parse_args(argc, argv); printf("Opening RF device...\n"); diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 1d807973c..fa5483003 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -701,6 +701,8 @@ int main(int argc, char **argv) { srslte_refsignal_t csr_refs; srslte_refsignal_t mbsfn_refs; + srslte_debug_handle_crash(argc, argv); + #ifdef DISABLE_RF if (argc < 3) { usage(argv[0]); diff --git a/lib/examples/pdsch_ue.c b/lib/examples/pdsch_ue.c index 681b75566..e8d4b1d00 100644 --- a/lib/examples/pdsch_ue.c +++ b/lib/examples/pdsch_ue.c @@ -341,6 +341,8 @@ int main(int argc, char **argv) { int sfn_offset; float cfo = 0; + srslte_debug_handle_crash(argc, argv); + parse_args(&prog_args, argc, argv); for (int i = 0; i< SRSLTE_MAX_CODEWORDS; i++) { diff --git a/lib/include/srslte/phy/utils/debug.h b/lib/include/srslte/phy/utils/debug.h index c88e1a3ce..11c7a23df 100644 --- a/lib/include/srslte/phy/utils/debug.h +++ b/lib/include/srslte/phy/utils/debug.h @@ -70,4 +70,6 @@ SRSLTE_API extern int srslte_verbose; #define ERROR(_fmt, ...) fprintf(stderr, "[ERROR in %s]:" _fmt "\n", __FUNCTION__, ##__VA_ARGS__) #endif /* CMAKE_BUILD_TYPE==Debug */ +void srslte_debug_handle_crash(int argc, char **argv); + #endif // DEBUG_H diff --git a/lib/src/phy/utils/debug.c b/lib/src/phy/utils/debug.c index 423abee6c..7cb9c0f11 100644 --- a/lib/src/phy/utils/debug.c +++ b/lib/src/phy/utils/debug.c @@ -24,7 +24,14 @@ * */ +#include +#include +#include +#include +#include + #include "srslte/phy/utils/debug.h" +#include "srslte/version.h" int srslte_verbose = 0; @@ -37,3 +44,57 @@ void get_time_interval(struct timeval * tdata) { tdata[0].tv_usec += 1000000; } } + +const static char crash_file_name[] = "./srsLTE.backtrace.crash"; +static int bt_argc; +static char **bt_argv; + +static void crash_handler(int sig) { + void *array[128]; + int size; + + /* Get all stack traces */ + size = backtrace(array, 128); + + FILE *f = fopen(crash_file_name, "a"); + if (!f) { + printf("srsLTE crashed... we could not save backtrace in '%s'...\n", crash_file_name); + } else { + char **symbols = backtrace_symbols(array, size); + + time_t lnTime; + struct tm *stTime; + char strdate[32]; + + time(&lnTime); + stTime = localtime(&lnTime); + + strftime(strdate, 32, "%d/%m/%Y %H:%M:%S", stTime); + + fprintf(f, "--- command='"); + for (int i = 0; i < bt_argc; i++) { + fprintf(f, "%s%s", (i == 0) ? "" : " ", bt_argv[i]); + } + fprintf(f, "' version=%s signal=%d date='%s' ---\n", SRSLTE_VERSION_STRING, sig, strdate); + + for (int i = 0; i < size; i++) { + fprintf(f, "\t%s\n", symbols[i]); + } + fprintf(f, "\n"); + + printf("srsLTE crashed... backtrace saved in '%s'...\n", crash_file_name); + fclose(f); + } + printf("--- exiting ---\n"); + exit(1); +} + +void srslte_debug_handle_crash(int argc, char **argv) { + bt_argc = argc; + bt_argv = argv; + + signal(SIGSEGV, crash_handler); + signal(SIGABRT, crash_handler); + signal(SIGILL, crash_handler); + signal(SIGFPE, crash_handler); +} diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 528878388..5cc4f5b1c 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -350,6 +350,8 @@ int main(int argc, char *argv[]) metrics_stdout metrics; enb *enb = enb::get_instance(); + srslte_debug_handle_crash(argc, argv); + cout << "--- Software Radio Systems LTE eNodeB ---" << endl << endl; parse_args(&args, argc, argv); diff --git a/srsue/src/main.cc b/srsue/src/main.cc index cc0b07043..f1edaaf75 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -374,6 +374,9 @@ int main(int argc, char *argv[]) srslte::metrics_hub metricshub; signal(SIGINT, sig_int_handler); all_args_t args; + + srslte_debug_handle_crash(argc, argv); + parse_args(&args, argc, argv); srsue_instance_type_t type = LTE;