Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

../../runtime/vm/os_linux.cc: 464: error: unreachable code when compiling AOT binary inside Docker on Armv7 #48366

Closed
cpswan opened this issue Feb 10, 2022 · 3 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@cpswan
Copy link
Contributor

cpswan commented Feb 10, 2022

  • Dart SDK Version (dart --version)
    Dart SDK version: 2.16.1 (stable) (Tue Feb 8 12:02:33 2022 +0100) on "linux_arm"
  • Whether you are using Windows, MacOSX, or Linux (if applicable)
    Linux: Linux hostname 5.10.63-v7l+ #1496 SMP Wed Dec 1 15:58:56 GMT 2021 armv7l GNU/Linux

$ cat /etc/os-release

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

$ docker --version
Docker version 20.10.12, build e91ed57

I have a very simple Dart program that outputs much the same as dart --version:

import 'dart:io' show Platform, stdout;

void main() {
  print(Platform.version);
}

This compiles and runs just fine when not using Docker.

But when I run:

export ARCH="arm"
export DART_VERSION="2.16.1"
sudo docker build -t atsigncompany/dartshowplatform:"$DART_VERSION"-"$ARCH" \
  --build-arg DART_VERSION="$DART_VERSION" -f dartshowplatform/Dockerfile .

against dartshowplatform/Dockerfile:

ARG DART_VERSION="2.14.4"
FROM dart:${DART_VERSION} AS build
WORKDIR /app
COPY ./dartshowplatform/showplatform.dart .
RUN dart compile exe /app/showplatform.dart -o /app/dartshowplatform

FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/dartshowplatform /app/dartshowplatform
ENTRYPOINT ["/app/dartshowplatform"]

It fails like this:

Sending build context to Docker daemon  4.129MB
Step 1/9 : ARG DART_VERSION="2.14.4"
Step 2/9 : FROM dart:${DART_VERSION} AS build
 ---> d01ea6894cbd
Step 3/9 : WORKDIR /app
 ---> Using cache
 ---> ddde485ca4ad
Step 4/9 : COPY ./dartshowplatform/showplatform.dart .
 ---> Using cache
 ---> bc344772b410
Step 5/9 : RUN dart compile exe /app/showplatform.dart -o /app/dartshowplatform
 ---> Running in 81af19056609
../../runtime/vm/os_linux.cc: 464: error: unreachable code

===== CRASH =====
si_signo=Segmentation fault(11), si_code=1, si_addr=0xc
Aborting re-entrant request for stack trace.
Aborted (core dumped)
The command '/bin/sh -c dart compile exe /app/showplatform.dart -o /app/dartshowplatform' returned a non-zero code: 134

NB ARG DART_VERSION="2.14.4" is simply a default that's overridden to 2.16.1 by DART_VERSION="$DART_VERSION"

Full source etc. at https://github.com/atsign-company/at_dockerfiles

The error was first seen on a MiniNode hosted Raspberry Pi used as part of the GitHub Actions workflow, and has been replicated on another Pi4 running the commands by hand.

This was running just fine yesterday with Dart 2.16.0

@lrhn lrhn added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Feb 11, 2022
@a-siva
Copy link
Contributor

a-siva commented Feb 11, 2022

The line number 464 shown above corresponds to this code

  if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
    UNREACHABLE();
    return 0;
  }

clock_gettime is not supported in the docker version ?

@cpswan
Copy link
Contributor Author

cpswan commented Feb 12, 2022

Thanks @a-siva

That led me to Raspberry Pi: clock_gettime(CLOCK_MONOTONIC, _) failed: Operation not permitted (1) and from there to Fix/Workaround - libseccomp2. So I've installed the backported libseccomp2 and now my Dart app is building OK again with Dart 2.16.1 inside Docker on Raspberry Pi OS 10 Buster.

# Get signing keys to verify the new packages, otherwise they will not install
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC 648ACFD622F3D138

# Add the Buster backport repository to apt sources.list
echo 'deb http://httpredir.debian.org/debian buster-backports main contrib non-free' \
 | sudo tee -a /etc/apt/sources.list.d/debian-backports.list

sudo apt update
sudo apt install libseccomp2 -t buster-backports

Seems like a Raspberry Pi OS thing more than a Dart thing, so closing this issue. But hopefully other people who trip across the problem will find the workaround here.

@a-siva
Copy link
Contributor

a-siva commented Feb 14, 2022

thanks for the update @cpswan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

3 participants