NGAP gNB crashes on PDU Session Resource Setup Request when optional pDUSessionNAS_PDU is absent
The gNB crashes with a segmentation fault while processing an NGAP `PDUSESSIONSetup` initiating message inside:
ngap_gNB_handle_pdusession_setup_request()
The crash occurs when handling `PDUSessionResourceSetupListSUReq` items if the optional IE `pDUSessionNAS_PDU` is not present.
---
**Observed Behavior**
Thread `TASK_NGAP` receives `SIGSEGV`:
\[NGAP\] PDUSESSIONSetup initiating message\
\
Thread 5 "TASK_NGAP" received signal SIGSEGV, Segmentation fault.
Backtrace:
"#0 ngap_gNB_handle_pdusession_setup_request(...)
#1ngap_gNB_handle_message(...)
#2ngap_gNB_handle_sctp_data_ind(...)"
Crash line:
msg-\>pdusession\[i\].nas_pdu = create_byte_array(item_p-\>pDUSessionNAS_PDU-\>size,\
item_p-\>pDUSessionNAS_PDU-\>buf);
---
**Root Cause**
`pDUSessionNAS_PDU` is an **optional** NGAP IE. In some valid messages, the ASN.1 decoder sets:
item_p-\>pDUSessionNAS_PDU = NULL;
Current code dereferences it without checking for `NULL`, causing a segmentation fault.
Example from gdb:
pDUSessionID = 2\
pDUSessionNAS_PDU = 0x0
issue