Golang so library ->> Getting fatal error: failed to get system page size

Hi, I am trying to implement my own features on webfilter-ng program.

The program works with its original code and there is no problem.
but i wrote a simple request library with golang and compiled for arm architecture with c-shared option to use this library on webfilter-ng.

CGO_ENABLED=1 CC=arm-openwrt-linux-muslgnueabi-gcc GOOS=linux GOARCH=arm go build -trimpath -ldflags="-s -w" -o librequestgo.so -buildmode=c-shared librequestgo.go

and i created Makefile for packaging both webfilter-ng and librequestgo.so . They successfully compiled and installed on device

webfilkter-ng installed on /usr/bin
librequestgo.so installed on /usr/lib directories

when i attempted to run webfilter-ng i got fatal error shown below

root@OpenWrt:~# webfilter-ng 
fatal error: failed to get system page size
runtime: panic before malloc heap initialized

runtime stack:
runtime.throw({0xb6c99d46, 0x1e})
	runtime/panic.go:1047 +0x50 fp=0xb6776c94 sp=0xb6776c80 pc=0xb6a669cc
runtime.mallocinit()
	runtime/malloc.go:367 +0x55c fp=0xb6776cc0 sp=0xb6776c94 pc=0xb6a34d7c
runtime.schedinit()
	runtime/proc.go:712 +0xb8 fp=0xb6776cf0 sp=0xb6776cc0 pc=0xb6a6b390
runtime.rt0_go()
	runtime/asm_arm.s:168 +0x84 fp=0xb6776d30 sp=0xb6776cf0 pc=0xb6a9dd4c

I thought the problem caused by the lack of swap space

root@OpenWrt:~# free
              total        used        free      shared  buff/cache   available
Mem:         119832       28436       71008         236       20388       56512
Swap:       0           0     0

then i followed this guide to add swap on OpenWrt

              total        used        free      shared  buff/cache   available
Mem:         119832       28436       71008         236       20388       56512
Swap:       1048572           0     1048572

Now i had 1GB swap space but still getting the same error.

Thanks in advance!

I'd say it's lack of RAM ...

1 Like

but for now i built webfilter-ng and librequestgo.so for Ubuntu x86/amd64 machine It worked as expected and it uses just 1- 5MB of RAM

thanks for any help