f3d-app / f3d

Fast and minimalist 3D viewer.
https://f3d.app
BSD 3-Clause "New" or "Revised" License
2.83k stars 204 forks source link

Unable to use f3d 2.4.0 inside Ubuntu Docker container from macOS host #1425

Open p4charu opened 5 months ago

p4charu commented 5 months ago

Unable to use f3d 2.4.0 inside Ubuntu Docker container. It fails to run saying "Illegal Instruction". Here's the strace output.

newfstatat(AT_FDCWD, "/usr/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0 munmap(0x7f299ceaa000, 22583) = 0 openat(AT_FDCWD, "/f3d/f3d-2.4.0-linux/libtcm.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) readlink("/proc/self/exe", "/f3d"..., 4096) = 52 openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY) = 3 newfstatat(3, "", {st_mode=S_IFREG|0444, st_size=0, ...}, AT_EMPTY_PATH) = 0 read(3, "processor\t: 0\nvendor_id\t: Genuin"..., 1024) = 1024 close(3) = 0 --- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPN, si_addr=0x7f299b7f6273} --- +++ killed by SIGILL +++ Illegal instruction

To Reproduce Steps to reproduce the behavior:

  1. Create an Ubuntu:jammy Docker container.
  2. Install f3d 2.4.0. (Irrespective of how you install f3d viz .deb, .tar.gz, headless, etc the issue is persistant)
  3. Run the command ./f3d --help

Expected behavior Should display help

System Information:

F3D Information Paste the content of f3d --version: root@search:/f3d/f3d-2.4.0-linux# ./f3d --version Illegal instruction

Meakk commented 5 months ago

Not sure what's libtcm.so.1.
@mwestphal any idea?

p4charu commented 5 months ago

To us libtcm.so.1 looks unrelated to the actual problem here. We saw the same errors in a successful run too (F3D on Ubuntu with GUI).

p4paul commented 5 months ago

I attempted to debug (without symbols)...

(gdb) r --version
Starting program: /f3d/bin/f3d --version
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x00007ffff0706273 in pxrInternal_v0_23__pxrReserved__::ArchMeasureExecutionTime<pxrInternal_v0_23__pxrReserved__::Arch_InitTickTimer()::{lambda()#1}>(pxrInternal_v0_23__pxrReserved__::Arch_InitTickTimer()::{lambda()#1} const&, unsigned long, bool*)::{lambda(void const*, int)#2}::_FUN(void const*, int) () from /f3d/lib/libusd_ms.so
(gdb) 

Could be failing in the USD library libusd_ms with a call to ArchMeasureExecutionTime(std::chrono::steady_clock::now)

mwestphal commented 5 months ago

Install f3d 2.4.0. (Irrespective of how you install f3d viz .deb, .tar.gz, headless, etc the issue is persistant)

Did you try compiling ?

mwestphal commented 5 months ago

pxrInternal_v0_23pxrReserved

This is USD, not sure what it would fail though

mwestphal commented 5 months ago

I'm unable to reproduce with the following, simple, dockerfile

FROM ubuntu:latest

RUN apt update && apt install -y \
  wget \
  xz-utils \
  libopengl0 \ 
  libegl1

RUN wget https://github.com/f3d-app/f3d/releases/download/v2.4.0/F3D-2.4.0-Linux-x86_64-headless.tar.xz && tar -xvf ./F3D-2.4.0-Linux-x86_64-headless.tar.xz && ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version
[...]
F3D - A fast and minimalist 3D viewer
Version: 2.4.0.
Build date: 2024-04-03 14:12:03.
Build system: Linux 64-bits.
Compiler: GNU 8.4.0.
External rendering module: ON.
Raytracing module: OFF.
VTK version: 9.3.0-2200-g1312f8a726 (date: 20240312).
Copyright (C) 2019-2021 Kitware SAS.
Copyright (C) 2021-2024 Michael Migliore, Mathieu Westphal.
License BSD-3-Clause.
By Michael Migliore, Mathieu Westphal and Joachim Pouderoux.
p4paul commented 5 months ago

I get an error?

FROM ubuntu:latest
RUN apt update && apt install -y wget xz-utils libopengl0 libegl1
RUN wget https://github.com/f3d-app/f3d/releases/download/v2.4.0/F3D-2.4.0-Linux-x86_64-headless.tar.xz
RUN tar -xvf ./F3D-2.4.0-Linux-x86_64-headless.tar.xz
RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version

output:

docker build -t f3d .
[+] Building 0.7s (8/8) FINISHED                                                                                                                                                                                                                                                                   docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                               0.0s
 => => transferring dockerfile: 337B                                                                                                                                                                                                                                                                               0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest                                                                                                                                                                                                                                                   0.4s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                    0.0s
 => [1/5] FROM docker.io/library/ubuntu:latest@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15                                                                                                                                                                                             0.0s
 => CACHED [2/5] RUN apt update && apt install -y wget xz-utils libopengl0 libegl1                                                                                                                                                                                                                                 0.0s
 => CACHED [3/5] RUN wget https://github.com/f3d-app/f3d/releases/download/v2.4.0/F3D-2.4.0-Linux-x86_64-headless.tar.xz                                                                                                                                                                                           0.0s
 => CACHED [4/5] RUN tar -xvf ./F3D-2.4.0-Linux-x86_64-headless.tar.xz                                                                                                                                                                                                                                             0.0s
 => ERROR [5/5] RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version                                                                                                                                                                                                                                            0.2s
------                                                                                                                                                                                                                                                                                                                  
 > [5/5] RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version:
0.178 Illegal instruction
------
Dockerfile:5
--------------------
   3 |     RUN wget https://github.com/f3d-app/f3d/releases/download/v2.4.0/F3D-2.4.0-Linux-x86_64-headless.tar.xz
   4 |     RUN tar -xvf ./F3D-2.4.0-Linux-x86_64-headless.tar.xz
   5 | >>> RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version
--------------------
ERROR: failed to solve: process "/bin/sh -c ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version" did not complete successfully: exit code: 132

I'm using macOS Intel 13.6.6 with Docker Desktop 4.29.0 (145265)

p4paul commented 5 months ago

Tried it on my M3 Max (with --platform flag)...

docker build --platform linux/amd64 -t f3d .
[+] Building 59.9s (9/9) FINISHED                                                                                                                                                          docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                       0.0s
 => => transferring dockerfile: 337B                                                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest                                                                                                                                           2.2s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                                                                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                                                                            0.0s
 => [1/5] FROM docker.io/library/ubuntu:latest@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15                                                                                    10.7s
 => => resolve docker.io/library/ubuntu:latest@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15                                                                                     0.0s
 => => sha256:d21429c4635332e96a4baae3169e3f02ac8e24e6ae3d89a86002d49a1259a4f7 424B / 424B                                                                                                                 0.0s
 => => sha256:bf3dc08bfed031182827888bb15977e316ad797ee2ccb63b4c7a57fdfe7eb31d 2.30kB / 2.30kB                                                                                                             0.0s
 => => sha256:49b384cc7b4aa0dfd16ff7817ad0ea04f1d0a8072e62114efcd99119f8ceb9ed 28.87MB / 28.87MB                                                                                                          10.1s
 => => sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15 1.13kB / 1.13kB                                                                                                             0.0s
 => => extracting sha256:49b384cc7b4aa0dfd16ff7817ad0ea04f1d0a8072e62114efcd99119f8ceb9ed                                                                                                                  0.6s
 => [2/5] RUN apt update && apt install -y wget xz-utils libopengl0 libegl1                                                                                                                               32.4s
 => [3/5] RUN wget https://github.com/f3d-app/f3d/releases/download/v2.4.0/F3D-2.4.0-Linux-x86_64-headless.tar.xz                                                                                         12.6s 
 => [4/5] RUN tar -xvf ./F3D-2.4.0-Linux-x86_64-headless.tar.xz                                                                                                                                            1.8s 
 => ERROR [5/5] RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version                                                                                                                                    0.1s 
------                                                                                                                                                                                                          
 > [5/5] RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version:                                                                                                                                               
0.133  ArchError: Could not find 'cpu MHz' in /proc/cpuinfo                                                                                                                                                     
0.133   Function: Arch_ComputeNanosecondsPerTick
0.133       File: /__w/f3d-superbuild/f3d-superbuild/build/superbuild/openusd/src/pxr/base/arch/timing.cpp
0.133       Line: 150
0.134 Aborted
------
Dockerfile:5
--------------------
   3 |     RUN wget https://github.com/f3d-app/f3d/releases/download/v2.4.0/F3D-2.4.0-Linux-x86_64-headless.tar.xz
   4 |     RUN tar -xvf ./F3D-2.4.0-Linux-x86_64-headless.tar.xz
   5 | >>> RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version
--------------------
ERROR: failed to solve: process "/bin/sh -c ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version" did not complete successfully: exit code: 134
mwestphal commented 5 months ago

Works fine here:

Step 5/5 : RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version
 ---> Running in 848468982bf9
F3D 2.4.0

F3D - A fast and minimalist 3D viewer
Version: 2.4.0.
Build date: 2024-04-03 14:12:03.
Build system: Linux 64-bits.
Compiler: GNU 8.4.0.
External rendering module: ON.
Raytracing module: OFF.
VTK version: 9.3.0-2200-g1312f8a726 (date: 20240312).
Copyright (C) 2019-2021 Kitware SAS.
Copyright (C) 2021-2024 Michael Migliore, Mathieu Westphal.
License BSD-3-Clause.
By Michael Migliore, Mathieu Westphal and Joachim Pouderoux.
 ---> Removed intermediate container 848468982bf9
 ---> 6f510ac3e37a
Successfully built 6f510ac3e37a

I'm on ArchLinux. this may be host dependant.

mwestphal commented 5 months ago
0.133  ArchError: Could not find 'cpu MHz' in /proc/cpuinfo                                                                                                                                                     
0.133   Function: Arch_ComputeNanosecondsPerTick
0.133       File: /__w/f3d-superbuild/f3d-superbuild/build/superbuild/openusd/src/pxr/base/arch/timing.cpp
0.133       Line: 150
0.134 Aborted

Looks like a different error, in any case, this error seems to be macOS host specific.

p4paul commented 5 months ago
0.133  ArchError: Could not find 'cpu MHz' in /proc/cpuinfo                                                                                                                                                     
0.133   Function: Arch_ComputeNanosecondsPerTick
0.133       File: /__w/f3d-superbuild/f3d-superbuild/build/superbuild/openusd/src/pxr/base/arch/timing.cpp
0.133       Line: 150
0.134 Aborted

Looks like a different error.

Think this is a known bug on Rosetta https://github.com/docker/for-mac/issues/7080

p4paul commented 5 months ago

Running as native ARM on my M3 Max... docker build -t f3d .

 => ERROR [5/5] RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version                                                                                                                                    0.1s 
------                                                                                                                                                                                                          
 > [5/5] RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version:                                                                                                                                               
0.091 rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2                                                                                                                                          
0.091  Trace/breakpoint trap
------
Dockerfile:5
--------------------
   3 |     RUN wget https://github.com/f3d-app/f3d/releases/download/v2.4.0/F3D-2.4.0-Linux-x86_64-headless.tar.xz
   4 |     RUN tar -xvf ./F3D-2.4.0-Linux-x86_64-headless.tar.xz
   5 | >>> RUN ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version
--------------------
ERROR: failed to solve: process "/bin/sh -c ./F3D-2.4.0-Linux-x86_64-headless/bin/f3d --version" did not complete successfully: exit code: 133

(full house of exit codes... 132, 133 and 134)

p4paul commented 5 months ago

Works on a native Ubuntu machine: Linux host 5.4.0-172-generic #190-Ubuntu SMP Fri Feb 2 23:24:22 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

F3D 2.4.0

F3D - A fast and minimalist 3D viewer
Version: 2.4.0.
Build date: 2024-04-03 14:12:03.
Build system: Linux 64-bits.
Compiler: GNU 8.4.0.
External rendering module: ON.
Raytracing module: OFF.
VTK version: 9.3.0-2200-g1312f8a726 (date: 20240312).
Copyright (C) 2019-2021 Kitware SAS.
Copyright (C) 2021-2024 Michael Migliore, Mathieu Westphal.
License BSD-3-Clause.
By Michael Migliore, Mathieu Westphal and Joachim Pouderoux.
mwestphal commented 5 months ago

@p4charu @p4paul If you want to investigate this, I would first try to compile to see if it reproduce it in that case too, then tries USD (pxr) sample examples to see if this is a OpenUSD bug/limitations.

p4charu commented 5 months ago

Thank you for looking into this. This does seem like a host specific issue.

mwestphal commented 5 months ago

Thank you for looking into this.

To clarify, I will not look into this but suggested debugging step for anyone willing to look into it.