Solved Erlang NIF not working 'unsupported file layout'. Why?

Hello all!

Got problem with deploying prebuilt applications that is using NIF.
My application build on VBox virtual machine undef FreeBSD OS. When distributing on other VBox machines all is working. When distributing on physical server have troubles:


(test@001.test.service)2> exec:start().
exec: /usr/local/lib/erlang/lib/erlexec/priv/x86_64-unknown-freebsd14.0/exec-port: Exec format error
{error,{port_exited_with_status,126}}
(test@001.test.service)3> =CRASH REPORT==== 11-Oct-2024::15:46:01.357352 ===
crasher:
initial call: exec:init/1
pid: <0.93.0>
registered_name: []
exception exit: {port_exited_with_status,126}
in function gen_server:init_it/6 (gen_server.erl, line 835)
ancestors: [<0.91.0>]
message_queue_len: 1
messages: [{'EXIT',#Port<0.7>,normal}]
links: []
dictionary: []
trap_exit: true
status: running
heap_size: 2586
stack_size: 28
reductions: 2114
neighbours:


It's happening with Erlexec project https://github.com/saleyn/erlexec
When trying to use this project https://github.com/ArboreusSystems/arboreus_library having this troubles:


(test@001.test.service)1> a_time_now:microseconds().
=WARNING REPORT==== 11-Oct-2024::15:45:34.402367 ===
The on_load function for module a_time_now returned:
{error,{load_failed,"Failed to load NIF library: '/usr/local/lib/erlang/lib/arboreus_library/priv/a_time_now.so: unsupported file layout'"}}


This applications added to Erlang 'lib' folder by symlinks to another locations.
The folders schema totally the same like on VBox machines, it's everything identical.
How to fix it? Maybe questions isn't ok for this forum. But there are some similar errors mentioned on this forum with other libraries.

The system setting totally identical it's distributed with Rex/Perl automation procedures. No any manual settings added.

The file command showing this:


$ file /usr/local/lib/erlang/lib/arboreus_library/priv/a_time_now.so
/usr/local/lib/erlang/lib/arboreus_library/priv/a_time_now.so: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD), dynamically linked, for FreeBSD 14.0 (1400097), with debug_info, not stripped

$ file /usr/local/lib/erlang/lib/erlexec/priv/x86_64-unknown-freebsd14.0/exec-port
/usr/local/lib/erlang/lib/erlexec/priv/x86_64-unknown-freebsd14.0/exec-port: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 14.0 (1400097), FreeBSD-style, with debug_info, not stripped


Everything compiled with Rebar3. The modules that not using NIFs working perfectly.
 
Exec format error
usually means you're trying to run an ARM binary on x86 or vice-versa. What hardware are you emulating in Vbox? What is your deployment hardware?

I just tried (and failed) to emulate aarch64 on Vbox, so I'm guessing that's not it.
 
usually means you're trying to run an ARM binary on x86 or vice-versa. What hardware are you emulating in Vbox? What is your deployment hardware?

I just tried (and failed) to emulate aarch64 on Vbox, so I'm guessing that's not it.
VirtualBox 7.0 on MacOS x86 inside of it FreeBSD 14.0 like builder.

The builder inside of VBox:

$ uname -a
FreeBSD builder.test.service 14.0-RELEASE-p11 FreeBSD 14.0-RELEASE-p11 #0: Wed Sep 18 23:01:59 UTC 2024 root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64


The target server:

$ uname -a
FreeBSD server.test.itra 14.0-RELEASE FreeBSD 14.0-RELEASE #0 releng/14.0-n265380-f9716eee8ab4: Fri Nov 10 05:51:26 UTC 2023 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/i386.i386/sys/GENERIC i386


There are difference.
 
Yeah, your deployment hardware is 32-bit and your compilation hardware is 64-bit. That's never going to work. The 14.0 release has been EOL for quite some time now, BTW.
 
The cause of trouble were in i386 FreeBSD version. The Server Administrator, because of his own reasons decided to use 32bit version on server with 64bit architecture. From my side were organized automation on amd64 version of FreeBSD (64bit) and that were the difference. On my question about why he did it in 2024, got reply that Erlang equipped with C++ NIFS is 32bit language … It made me loosing any abilities to say anything …

Problem solved … Reinstalling whole environment with FreeBSD amd64 version.
 
Yeah, your deployment hardware is 32-bit and your compilation hardware is 64-bit. That's never going to work. The 14.0 release has been EOL for quite some time now, BTW.
Reinstalling with 14.1 Already did for automation and build/test environment. Servers is in progress. Huge thanks ...
 
...The Server Administrator, because of his own reasons decided to use 32bit version on server with 64bit architecture. From my side were organized automation on amd64 version of FreeBSD (64bit) and that were the difference. On my question about why he did it in 2024, got reply that Erlang equipped with C++ NIFS is 32bit language … It made me loosing any abilities to say anything …
Yeah, I sometimes find the best thing I can say is nothing at all. Glad you've solved your problems! Well, at least the technical ones.
 
Back
Top