Simulator crashes (SIGSEGV) on first CCC control: JSON_DIAGNOSTICS define in ccc-message.h causes nlohmann::json layout mismatch

Open Beginner friendly
#55 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, json

Research direction

Open contrib/oran-interface/model/ccc-message.h and look at the two #define lines immediately above #include <nlohmann/json.hpp>; grep the tree for other uses of JSON_DIAGNOSTICS/JSON_NO_IO before deleting them. Rebuild the oran-interface and nr modules so both sides of the E2 control path agree on the nlohmann::json layout. Done looks like the reproduction steps in the issue (nearRT-RIC, scratch/RF_Reconfiguration.cc, xapp_rf_reconfiguration) running 60 s without SIGSEGV, with CCC controls acknowledged instead of the xApp timing out.

Written by the indexing model from the issue text.

Description

Hi, and thank you for RIC-TaaP. It has been very useful for my research on xApp testing.

I ran into a crash with the RF Channel Reconfiguration xApp and found what I think is the cause, with a simple fix.

Environment

  • Ubuntu 22.04.5, aarch64 (VM on Apple Silicon), ns-3.42, gcc 11.4
  • FlexRIC f56d4487507c7ace392f1ec3f598e7eeda670acc
  • oran-interface: MinaYonan123/oran-interface @ 95fba5a (branch add-CCC, MinaYonan123/oran-interface#11)
  • nr: MinaYonan123/ns3-oran-lena-nr @ 35eeab6 (branch CCC-on-Lena, MinaYonan123/ns3-oran-lena-nr#7)

Steps to reproduce

  1. ./nearRT-RIC
  2. ./ns3 run "scratch/RF_Reconfiguration.cc --report_to_db=false --simTime=60s --indicationPeriodicity=0.1"
  3. ./xapp_rf_reconfiguration

What happens

The simulator crashes with SIGSEGV on the first CCC control message (with any antenna mask). No CONTROL ACK is sent, so the xApp aborts with Timeout. No response from the E2 Node and the RIC keeps printing Pending event timeout happened.

The crash is in NrGnbNetDevice::CCCcontrolMessageReceivedCallback, called from e2ap_handle_RICControlRequest, when it first reads the decoded message (first in PrintControlMessage; with the print disabled, in the name == "O-NESPolicy" comparison).

Cause

contrib/oran-interface/model/ccc-message.h has these lines before #include <nlohmann/json.hpp>:

#define JSON_DIAGNOSTICS 1
#define JSON_NO_IO 1

JSON_DIAGNOSTICS adds a hidden field to every nlohmann::json, which changes its size. Code that includes ccc-message.h first gets the larger type, and code that includes nlohmann/json.hpp without the define gets the normal one. So the same type has two layouts in one program.

In the disassembly, the decoder steps through the cell list in 0x320-byte items, but the callback in the nr module uses 0x310-byte items. The callback then reads the wrong memory and crashes.

I only tested on ARM, but the cause does not depend on the architecture.

Fix

Removing the two defines from ccc-message.h and rebuilding fixed it. Both sides then use the same item size (0x310). A full 60 s run completed with no crash, and 116 CCC controls were sent, acknowledged and applied. The antenna ports followed the traffic as expected (4 → 2 → 1 → 2 → 4).

Other notes

I also have two small fixes, one for a thread race in the CCC callback and one for the end-of-run Bad file descriptor error (as in discussion #10). I'm happy to share them separately if useful.

Thanks again for your work on this project.

Dominant language
No language data
Stars
78
Forks
38
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Orange-OpenSource/ns-O-RAN-flexric

All issues in Orange-OpenSource/ns-O-RAN-flexric

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.