Skip to content

Open5GS: MongoDB crashes on RPi CM4 in Docker build due to unsupported ARM64 instructions #1

@dtv-comp

Description

@dtv-comp

Open5GS: MongoDB crashes on RPi CM4 in Docker build due to unsupported ARM64 instructions

Description

When running the Docker build of Open5GS on a Raspberry Pi Compute Module 4 (RPi CM4), MongoDB crashes immediately.

waiting for mongodb
./open5gs_entrypoint.sh: line 26:    77 Illegal instruction     (core dumped) mongod --logpath /tmp/mongodb.log

The root cause is that the official MongoDB ARM64 build uses CPU instructions not supported by the ARM Cortex-A72 (ARMv8-A) processor used in RPi CM4.

Steps to Reproduce

  1. Go to the directory with srsRAN_Project
  2. Build and run Open5GS in Docker on a RPi CM4 (arm64):
cd ./docker/open5gs
docker network create --subnet=10.53.1.0/24 open5gsnet
docker build --target open5gs -t open5gs-docker .
  1. Start MongoDB container:
docker run --net open5gsnet --ip 10.53.1.2 --env-file open5gs.env --privileged --publish 9999:9999 open5gs-docker ./build/tests/app/5gc -c open5gs-5gc.yml
  1. Observe immediate crash:
waiting for mongodb
./open5gs_entrypoint.sh: line 26:    77 Illegal instruction     (core dumped) mongod --logpath /tmp/mongodb.log

Observed Behavior

  • MongoDB process crashes on startup.
  • Backtrace shows illegal instruction.
  • Confirmed that the crash is due to unsupported ARMv8 instructions in the official MongoDB ARM64 binaries.

Expected Behavior

MongoDB should run normally on RPi CM4 inside the Docker environment.

Workaround / Fix

The issue was resolved by installing MongoDB from an unofficial repository that provides binaries compatible with Raspberry Pi CM4.
Below is a patch to the Dockerfile showing the change:

diff --git a/docker/open5gs/Dockerfile b/docker/open5gs/Dockerfile
index b36d78a62d..c15a7b4e5c 100644
--- a/docker/open5gs/Dockerfile
+++ b/docker/open5gs/Dockerfile
@@ -53,12 +53,19 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update \
     cmake \
     && rm -rf /var/lib/apt/lists/*
 
-ARG MONGO_MAJOR_VERSION=6
+#ARG MONGO_MAJOR_VERSION=6
+#RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends wget gnupg \
+#    && wget -qO - https://www.mongodb.org/static/pgp/server-${MONGO_MAJOR_VERSION}.0.asc | apt-key add \
+#    && . /etc/os-release \
+#    && echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $UBUNTU_CODENAME/mongodb-org/${MONGO_MAJOR_VERSION}.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-${MONGO_MAJOR_VERSION}.0.list \
+#    && DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends mongodb-org \
+#    && apt-get autoremove && apt-get clean
+
 RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends wget gnupg \
-    && wget -qO - https://www.mongodb.org/static/pgp/server-${MONGO_MAJOR_VERSION}.0.asc | apt-key add \
-    && . /etc/os-release \
-    && echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $UBUNTU_CODENAME/mongodb-org/${MONGO_MAJOR_VERSION}.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-${MONGO_MAJOR_VERSION}.0.list \
-    && DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends mongodb-org \
+    && mkdir -p /root/.gnupg \
+    && gpg --no-default-keyring --keyring /etc/apt/keyrings/wcyat.gpg --keyserver keyserver.ubuntu.com --recv-keys 968AEE35DEBD51DB3769CD0FB10D363E72255CCA \
+    && echo "deb [signed-by=/etc/apt/keyrings/wcyat.gpg] https://gitlab.com/metahkg/bin/mongodb-arm64-bin/-/raw/master/repo/apt/debian bookworm/mongodb-org/6.0 main" | tee /etc/apt/sources.list.d/mongodb-6.0.list \
+    && apt update && apt install mongodb-org-server mongodb-org-mongos mongodb-database-tools mongodb-mongosh -y \
     && apt-get autoremove && apt-get clean
 
 # To set a fixed version of open5gs use

Additional Information

  • Crash logs with backtrace:
root@e4115eeede52:/open5gs# gdb mongod
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from mongod...
(No debugging symbols found in mongod)
(gdb) r
Starting program: /usr/bin/mongod 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x000000555dc539b8 in tcmalloc::tcmalloc_internal::Sampler::RecordAllocationSlow(unsigned long) ()
(gdb) bt
#0  0x000000555dc539b8 in tcmalloc::tcmalloc_internal::Sampler::RecordAllocationSlow(unsigned long) ()
#1  0x000000555dc15f10 in tcmalloc::tcmalloc_internal::TCMallocPolicy<tcmalloc::tcmalloc_internal::MallocOomPolicy, tcmalloc::tcmalloc_internal::MallocAlignPolicy, tcmalloc::tcmalloc_internal::AllocationAccessHotPolicy, tcmalloc::tcmalloc_internal::InvokeHooksPolicy, tcmalloc::tcmalloc_internal::NonSizeReturningPolicy, tcmalloc::tcmalloc_internal::LocalNumaPartitionPolicy>::pointer_type tcmalloc::tcmalloc_internal::slow_alloc_small<tcmalloc::tcmalloc_internal::TCMallocPolicy<tcmalloc::tcmalloc_internal::MallocOomPolicy, tcmalloc::tcmalloc_internal::MallocAlignPolicy, tcmalloc::tcmalloc_internal::AllocationAccessHotPolicy, tcmalloc::tcmalloc_internal::InvokeHooksPolicy, tcmalloc::tcmalloc_internal::NonSizeReturningPolicy, tcmalloc::tcmalloc_internal::LocalNumaPartitionPolicy> >(unsigned long, unsigned int, tcmalloc::tcmalloc_internal::TCMallocPolicy<tcmalloc::tcmalloc_internal::MallocOomPolicy, tcmalloc::tcmalloc_internal::MallocAlignPolicy, tcmalloc::tcmalloc_internal::AllocationAccessHotPolicy, tcmalloc::tcmalloc_internal::InvokeHooksPolicy, tcmalloc::tcmalloc_internal::NonSizeReturningPolicy, tcmalloc::tcmalloc_internal::LocalNumaPartitionPolicy>) [clone .constprop.0] ()
#2  0x000000555dd6c5c4 in malloc ()
#3  0x0000007ff77f38bc in __newlocale (category_mask=8127, locale=<optimized out>, base=0x0) at ./locale/newlocale.c:199
#4  0x0000007ff6c48a4c in ?? () from /lib/aarch64-linux-gnu/libp11-kit.so.0
#5  0x0000007ff7fc7624 in call_init (env=0x7ffffff548, argv=0x7ffffff538, argc=1, l=<optimized out>) at ./elf/dl-init.c:70
#6  call_init (l=<optimized out>, argc=1, argv=0x7ffffff538, env=0x7ffffff548) at ./elf/dl-init.c:26
#7  0x0000007ff7fc772c in _dl_init (main_map=0x7ff7fff370, argc=1, argv=0x7ffffff538, env=0x7ffffff548) at ./elf/dl-init.c:117
#8  0x0000007ff7fd9cc8 in _dl_start_user () from /lib/ld-linux-aarch64.so.1
  • lscpu output of the RPi CM4:
Architecture:                aarch64
  CPU op-mode(s):            32-bit, 64-bit
  Byte Order:                Little Endian
CPU(s):                      4
  On-line CPU(s) list:       0-3
Vendor ID:                   ARM
  Model name:                Cortex-A72
    Model:                   3
    Thread(s) per core:      1
    Core(s) per cluster:     4
    Socket(s):               -
    Cluster(s):              1
    Stepping:                r0p3
    CPU(s) scaling MHz:      40%
    CPU max MHz:             1500.0000
    CPU min MHz:             600.0000
    BogoMIPS:                108.00
    Flags:                   fp asimd evtstrm crc32 cpuid
Caches (sum of all):         
  L1d:                       128 KiB (4 instances)
  L1i:                       192 KiB (4 instances)
  L2:                        1 MiB (1 instance)
NUMA:                        
  NUMA node(s):              1
  NUMA node0 CPU(s):         0-3
Vulnerabilities:             
  Gather data sampling:      Not affected
  Indirect target selection: Not affected
  Itlb multihit:             Not affected
  L1tf:                      Not affected
  Mds:                       Not affected
  Meltdown:                  Not affected
  Mmio stale data:           Not affected
  Reg file data sampling:    Not affected
  Retbleed:                  Not affected
  Spec rstack overflow:      Not affected
  Spec store bypass:         Vulnerable
  Spectre v1:                Mitigation; __user pointer sanitization
  Spectre v2:                Vulnerable
  Srbds:                     Not affected
  Tsx async abort:           Not affected
lime@limenet-pink:~/develop/srsRAN_Project/docker/open5gs $ cat /proc/cpuinfo
processor  : 0
BogoMIPS  : 108.00
Features  : fp asimd evtstrm crc32 cpuid
CPU implementer  : 0x41
CPU architecture: 8
CPU variant  : 0x0
CPU part  : 0xd08
CPU revision  : 3

processor  : 1
BogoMIPS  : 108.00
Features  : fp asimd evtstrm crc32 cpuid
CPU implementer  : 0x41
CPU architecture: 8
CPU variant  : 0x0
CPU part  : 0xd08
CPU revision  : 3

processor  : 2
BogoMIPS  : 108.00
Features  : fp asimd evtstrm crc32 cpuid
CPU implementer  : 0x41
CPU architecture: 8
CPU variant  : 0x0
CPU part  : 0xd08
CPU revision  : 3

processor  : 3
BogoMIPS  : 108.00
Features  : fp asimd evtstrm crc32 cpuid
CPU implementer  : 0x41
CPU architecture: 8
CPU variant  : 0x0
CPU part  : 0xd08
CPU revision  : 3

Revision  : d03141
Serial    : 10000000044a6f74
Model    : Raspberry Pi Compute Module 4 Rev 1.1

Suggestion

  • Document this incompatibility for ARM64 users (RPi CM4 and similar)
  • Optionally provide an alternative Dockerfile that pulls a MongoDB build compatible with RPi CM4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions