srsran / srsRAN_4G

Open source SDR 4G software suite from Software Radio Systems (SRS) https://docs.srsran.com/projects/4g
https://www.srsran.com
GNU Affero General Public License v3.0
3.48k stars 1.14k forks source link

Crash when ulimit rt priority is 0 #970

Open matan1008 opened 2 years ago

matan1008 commented 2 years ago

Issue Description

When running srsenb without sudo in a shell where ulimit -r is 0, the enb crash. Specifically, it crashes on pthread_join(*thread, NULL); https://github.com/srsran/srsRAN/blob/master/lib/src/common/threads.c#L159

Setup Details

Ubuntu 22.04.1 USRP B210

Expected Behavior

I would expect it to create threads with normal priority or exit with indicative error.

Actual Behaviour

Crash:

Active RF plugins: libsrsran_rf_uhd.so libsrsran_rf_zmq.so
Inactive RF plugins: 
---  Software Radio Systems LTE eNodeB  ---

Reading configuration file /home/user/Documents/local_confs/current_enb.conf...

Built in Release mode using commit ce8a3cae1 on branch master.

connect(): Connection refused
Failed to initiate S1 connection. Attempting reconnection in 10 seconds
Warning: Failed to create thread with real-time priority. Creating it with normal priority: Connection refused
Opening 1 channels in RF device=UHD with args=clock=gpsdo
Supported RF device list: UHD zmq file
[INFO] [UHD] linux; GNU C++ version 11.2.0; Boost_107400; UHD_4.2.0.1-0ubuntu1~jammy1
[INFO] [LOGGING] Fastpath logging disabled at runtime.
Opening USRP channels=1, args: type=b200,master_clock_rate=23.04e6
[INFO] [UHD RF] RF UHD Generic instance constructed
[INFO] [B200] Detected Device: B210
[INFO] [B200] Operating over USB 3.
[INFO] [B200] Detecting internal GPSDO.... 
[INFO] [GPS] Found an internal GPSDO: GPSTCXO , Firmware Rev 0.929a
[INFO] [B200] Initialize CODEC control...
[INFO] [B200] Initialize Radio control...
[INFO] [B200] Performing register loopback test... 
[INFO] [B200] Register loopback test passed
[INFO] [B200] Performing register loopback test... 
[INFO] [B200] Register loopback test passed
[INFO] [B200] Asking for clock rate 23.040000 MHz... 
[INFO] [B200] Actually got clock rate 23.040000 MHz.
Setting USRP time to 1661318142.000000s
[INFO] [MULTI_USRP]     1) catch time transition at pps edge
[INFO] [MULTI_USRP]     2) set times next pps (synchronously)
Warning: Failed to create thread with real-time priority. Creating it with normal priority: No such file or directory
Warning: Failed to create thread with real-time priority. Creating it with normal priority: No such file or directory
Warning: Failed to create thread with real-time priority. Creating it with normal priority: No such file or directory
--- command='./build/srsenb/src/srsenb /home/user/Documents/local_confs/current_enb.conf' version=22.04.1 signal=11 date='24/08/2022 05:15:43' ---
    ./build/srsenb/src/srsenb(+0x37ac3a) [0x561d02714c3a]
    /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f49739e0520]
    /lib/x86_64-linux-gnu/libc.so.6(+0x9659b) [0x7f4973a3459b]
    ./build/srsenb/src/srsenb(+0x3977b3) [0x561d027317b3]
    ./build/srsenb/src/srsenb(+0xe017d) [0x561d0247a17d]
    ./build/srsenb/src/srsenb(+0xd2416) [0x561d0246c416]
    ./build/srsenb/src/srsenb(+0xbf129) [0x561d02459129]
    ./build/srsenb/src/srsenb(+0x9de67) [0x561d02437e67]
    /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f49739c7d90]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f49739c7e40]
    ./build/srsenb/src/srsenb(+0xa0545) [0x561d0243a545]
srsRAN crashed. Please send this backtrace to the developers ...
---  exiting  ---
terminate called without an active exception
--- command='./build/srsenb/src/srsenb /home/user/Documents/local_confs/current_enb.conf' version=22.04.1 signal=6 date='24/08/2022 05:15:43' ---
    ./build/srsenb/src/srsenb(+0x37ac3a) [0x561d02714c3a]
    /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f49739e0520]
    /lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c) [0x7f4973a34a7c]
    /lib/x86_64-linux-gnu/libc.so.6(raise+0x16) [0x7f49739e0476]
    /lib/x86_64-linux-gnu/libc.so.6(abort+0xd3) [0x7f49739c67f3]
    /lib/x86_64-linux-gnu/libstdc++.so.6(+0xa2bfe) [0x7f4973d6fbfe]
    /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae28c) [0x7f4973d7b28c]
    /lib/x86_64-linux-gnu/libstdc++.so.6(+0xae2f7) [0x7f4973d7b2f7]
    /home/user/srsRAN/build/lib/src/phy/rf/libsrsran_rf_uhd.so(+0x19c69) [0x7f497386fc69]
    /home/user/srsRAN/build/lib/src/phy/rf/libsrsran_rf_uhd.so(+0x1afaa) [0x7f4973870faa]
    /lib/x86_64-linux-gnu/libc.so.6(__cxa_finalize+0xb6) [0x7f49739e3a56]
    /home/user/srsRAN/build/lib/src/phy/rf/libsrsran_rf_uhd.so(+0xe9b7) [0x7f49738649b7]
srsRAN crashed. Please send this backtrace to the developers ...
---  exiting  ---

Additional Information

It doesn't crash when running with sudo or when changing the ulimit -r

andrepuschmann commented 2 years ago

Thanks for the bug report @matan1008 . We are currently testing a possible solution internally and will share it here once it's verified on our end.