Hello,
I'm having an issue with running a 32-bit executable built with GCC inside a Bitbucket pipeline using the atlassian/default-image:2 image:
+ file /usr/local/bin/pawncc
/usr/local/bin/pawncc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=1df4edb3e7046c89aaac29df60750a897c3e0540, not stripped
+ ldd /usr/local/bin/pawncc
not a dynamic executable
LDD says that it's "not a dynamic executable".
Do I need to install some extra packages to run 32-bit programs? I currently have the following:
+ apt-get install -y libc6:i386 linux-libc-dev:i386 cmake gcc-multilib gcc-4.8 gcc-4.8-multilib g++-4.8 g++-4.8-multilib cmake snapd
Update:
Sample bitbucket-pipelines.yml that reproduces the issue:
image: atlassian/default-image:2
pipelines:
default:
- step:
name: Build
script:
- uname -a
- cat /etc/lsb-release
- dpkg --add-architecture i386
- apt-get update -qq
- apt-get install -y binfmt-support file wget libc6-i386 linux-libc-dev:i386 gcc gcc-multilib
- echo 'int main() { printf("Hello, world!"); }' >> test.c
- gcc -m32 test.c -o test
- ./test
Output:
bash: ./test: cannot execute binary file: Exec format error
If ldd is reporting it's not a valid executable, then it's been built incorrectly for the current architecture, or you are missing supporting libraries in the running environment.
While this running inside a bitbucket pipeline, it's not really a bitbucket question - there's something missing from the environment or the compile
Ok, that's one thing fixed or ruled out. The next question has to be what is the difference between your Travis environment and the Bitbucket pipeline environment?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've just tried using a i386 image of ubuntu (i386/ubuntu:xenial) and it failed as well, but this time during build initialization stage:
standard_init_linux.go:211: exec user process caused "exec format error"time="2021-05-14T13:04:46Z" level=error msg="init failed" error="standard_init_linux.go:211: exec user process caused \"exec format error\"" name=kata-agent pid=1 source=agentpanic: --this line should have never been executed, congratulations--goroutine 1 [running, locked to thread]:main.init.0() /go/src/github.com/kata-containers/agent/agent.go:1489 +0x10f+ umask 000+ GIT_LFS_SKIP_SMUDGE=1 retry 6 git clone --branch="master" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIRCloning into '/opt/atlassian/pipelines/agent/build'...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, it's the same answer - the environment you've got is different somehow, the one in your pipeline can't run the executable because it doesn't support that type of executable like the other test environments do.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suspect that Bitbucket runs some script that modifies the default environment of the container, because the same build scripts run PERFECTLY when I using Docker with the same image (atlassian/default-image). Or maybe Pipelines run docker with some weird options that prevent 32-bit support or something.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey all, the last post has been made quite a while ago, but since I found an easy solution for executing 32-bit applications on Bitbucket pipeline, I felt like sharing this info with you.
I ran into the same issue with my 32-bit binary of google protoc compiler "protoc.bin".
The solution is installing 2 packages to enable execution of 32-bit applications.
Below you can find an example .yaml which installs the 2 required packages:
image: ubuntu:latest
pipelines:
default:
- step:
script:
- apt-get update && apt-get install -y gcc-multilib g++-multilib
- # Add your build commands here
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Zeex @mfkenney Did you find a solution or workaround for this?
I've run into exactly the same issue and have come to the same conclusion. Bitbucket Pipelines must run the docker containers with a different configuration or in an environment that doesn't support 32-bit executables.
We've created our own docker image as follows:
FROM ubuntu:20.04
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y build-essential libc6-i386 libstdc++6 unzip git libgit2-dev python3 python3-pip python3-cffi
...
When running this docker image on Windows using WSL then the build script works fine.
However, when running the same scripts inside Bitbucket Pipelines then there is an error:
bash: /opt/mspgcc/bin/msp430-gcc: cannot execute binary file: Exec format error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Zeex Just FYI, I ran into the same problem. I have a 64-bit Debian container image with some 32-bit executables (an old GCC cross compiler). The image works on every Docker installation I've tried except Bitbucket. My work-around is to use a self-hosted pipeline runner -- the image runs fine.
I have no idea how Bitbucket is running the images in their Cloud but they must be doing something non-standard ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.