Unable to run 32-bit executable on Ubuntu 16.04 on Pipelines

Zeex May 8, 2021

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

4 answers

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 8, 2021

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

Zeex May 8, 2021

The executable is built correctly - I'm using the same script on Travis CI and it's working

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 8, 2021

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?

Zeex May 8, 2021

No idea... I even ran the same Docker image as Pipelines uses on my computer with the same set of commands, and it worked for me there

Zeex May 14, 2021

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:211exec user process caused "exec format error"time="2021-05-14T13:04:46Z" level=error msg="init failed" error="standard_init_linux.go:211exec 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'... 

Zeex May 14, 2021

@Nic Brough -Adaptavist-any other ideas?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 14, 2021

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.

Zeex May 15, 2021

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.

0 votes
Thomas Rosenberger
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 27, 2024

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".

Consulting chatGPT4, led to the solution of installing 2 packages to enable execution of 32-bit applications.

Below you can find an example .yaml which installs the 2 required packages:

  • gcc-multilib
  • g++-multilib
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.

0 votes
Jason January 16, 2022

@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
Zeex January 18, 2022

Yes, I emailed Bitbucket support and they were able to enable 32-bit for my pipeline

Like Jason likes this
0 votes
mfkenney November 9, 2021

@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 ...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events