Skip to content

Installation on Fedora linux 42-beta: buffer overflow detected #881

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

Open
scottwcpg opened this issue Mar 24, 2025 · 3 comments
Open

Installation on Fedora linux 42-beta: buffer overflow detected #881

scottwcpg opened this issue Mar 24, 2025 · 3 comments

Comments

@scottwcpg
Copy link

Hi,
I do all my zephyr development on Fedora linux. Since F42-beta is released I wanted to check if they broke zephyr tools.
Looks like they did.
The first parts of zephyr development environment setup installed with no errors. The sdk install is generating a buffer overflow. The default python is 3.13.2. I also tried the SDK install in a python3.12 virtual environment and got the same failure.
Ran it this way to get some output:
$ ./zephyr-sdk-x86_64-hosttools-standalone-0.9.sh -S -D -y -d .
Zephyr Yocto Toolchain SDK installer version 0.9

  • '[' '' = 1 ']'
  • '[' . = '' ']'
    ++ echo .
    ++ sed 's/ /\ /g'
  • eval target_sdk_dir=.
    ++ target_sdk_dir=.
  • '[' -d . ']'
    ++ cd .
    ++ pwd
  • target_sdk_dir=/home/void/zephyr-sdk-0.17.0
  • '[' 28 -gt 2048 ']'
  • '[' '' = 1 ']'
    ++ echo /home/void/zephyr-sdk-0.17.0
    ++ grep ' '
  • '[' -n '' ']'
  • '[' -e /home/void/zephyr-sdk-0.17.0/environment-setup-core2-32-zephyr-linux ']'
  • printf 'You are about to install the SDK to "/home/void/zephyr-sdk-0.17.0". Proceed [Y/n]? '
    You are about to install the SDK to "/home/void/zephyr-sdk-0.17.0". Proceed [Y/n]? + default_answer=y
  • '[' Y = '' ']'
  • echo Y
    Y
  • '[' Y '!=' Y -a Y '!=' y ']'
  • mkdir -p /home/void/zephyr-sdk-0.17.0
  • '[' '!' -x /home/void/zephyr-sdk-0.17.0 -o '!' -w /home/void/zephyr-sdk-0.17.0 -o '!' -r /home/void/zephyr-sdk-0.17.0 ']'
  • printf 'Extracting SDK...'
    Extracting SDK...+ '[' tar.xz = zip ']'
  • tail -n +380 ./zephyr-sdk-x86_64-hosttools-standalone-0.9.sh
  • tar mxJ -C /home/void/zephyr-sdk-0.17.0 --checkpoint=.2500
    .................+ echo done
    done
  • printf 'Setting it up...'
    Setting it up...+ real_env_setup_script=
    ++ ls /home/void/zephyr-sdk-0.17.0/environment-setup-x86_64-pokysdk-linux
  • for env_setup_script in ls $target_sdk_dir/environment-setup-*
  • grep -q OECORE_NATIVE_SYSROOT= /home/void/zephyr-sdk-0.17.0/environment-setup-x86_64-pokysdk-linux
  • real_env_setup_script=/home/void/zephyr-sdk-0.17.0/environment-setup-x86_64-pokysdk-linux
  • sed -e s:/opt/zephyr-sdk/0.9:/home/void/zephyr-sdk-0.17.0:g -i /home/void/zephyr-sdk-0.17.0/environment-setup-x86_64-pokysdk-linux
  • '[' -n /home/void/zephyr-sdk-0.17.0/environment-setup-x86_64-pokysdk-linux ']'
  • env_setup_script=/home/void/zephyr-sdk-0.17.0/environment-setup-x86_64-pokysdk-linux
  • xargs --version
    ++ cat /home/void/zephyr-sdk-0.17.0/environment-setup-x86_64-pokysdk-linux
    ++ grep OECORE_NATIVE_SYSROOT=
    ++ cut -d= -f2
    ++ tr -d '"'
  • native_sysroot=/home/void/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux
    ++ find /home/void/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/lib -name 'ld-linux*'
  • dl_path=/home/void/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2
  • '[' /home/void/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2 = '' ']'
    ++ find /home/void/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux -type f '(' -perm -0100 -o -perm -0010 -o -perm -0001 ')' -printf ''''%h/%f''' '
  • executable_files=''''/home/void/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-mipsel'''
    ...
    ++ mktemp -d
  • tdir=/tmp/tmp.xog80vVumu
  • '[' x/tmp/tmp.xog80vVumu = x ']'
  • cat
  • mv /tmp/tmp.xog80vVumu/relocate_sdk.sh /home/void/zephyr-sdk-0.17.0/relocate_sdk.sh
  • chmod 755 /home/void/zephyr-sdk-0.17.0/relocate_sdk.sh
  • rm -rf /tmp/tmp.xog80vVumu
  • '[' 1 = 1 ']'
  • /home/void/zephyr-sdk-0.17.0/relocate_sdk.sh
    /home/void/zephyr-sdk-0.17.0/relocate_sdk.py:30: SyntaxWarning: invalid escape sequence '.'
    old_prefix = re.compile(b("/opt/zephyr-sdk/0.9"))
  • '[' 0 -ne 0 ']'
  • for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"
  • find /home/void/zephyr-sdk-0.17.0 -maxdepth 1 -type f
  • grep ':.*(ASCII|script|source).*text'
  • xargs -n100 file
  • awk '-F: ' '{printf ""%s"\n", $1}'
  • grep -Fv -e /home/void/zephyr-sdk-0.17.0/environment-setup- -e /home/void/zephyr-sdk-0.17.0/relocate_sdk -e /home/void/zephyr-sdk-0.17.0/post-relocate-setup -e /home/void/zephyr-sdk-0.17.0/zephyr-sdk-x86_64-hosttools-standalone-0.9.sh
  • xargs -n100 sed -i -e s:/opt/zephyr-sdk/0.9:/home/void/zephyr-sdk-0.17.0:g -e 's:^#! /usr/bin/perl.:#! /usr/bin/env perl:g' -e 's: /usr/bin/perl: /usr/bin/env perl:g'
  • for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"
  • find /home/void/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux -type f
    *** buffer overflow detected ***: terminated
    xargs: file: terminated by signal 6
    sed: no input files
  • '[' 123 -ne 0 ']'
  • echo 'Failed to replace perl. Relocate script failed. Abort!'
    Failed to replace perl. Relocate script failed. Abort!
  • exit 1
@scottwcpg
Copy link
Author

Examined zephyr-sdk-x64_64-hosttools-standalone-0.9.sh
Crash occurs when script runs find and then calls file for each found file
Manually ran F42b file on one of the found artifacts, $HOME/zephyr-sdk-0.17.0/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-mipsel. Something is wrong with the file utility or libmagic from glibc?
F42b has file-5.45 and glibc 2.41
Are there any instruction for building the SDK on a local machine?

@oryjkov
Copy link

oryjkov commented Apr 16, 2025

Running into the same error. I was able to workaround by using a smaller xargs buffer (-n10 instead of -n100) in the snippet below:

# replace /opt/zephyr-sdk/0.9 with the new prefix in all text files: configs/scripts/etc.
# replace the host perl with SDK perl.
for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do
	$SUDO_EXEC find $replace -type f
done | xargs -n100 file | grep ":.*\(ASCII\|script\|source\).*text" | \
    awk -F': ' '{printf "\"%s\"\n", $1}' | \
    grep -Fv -e "$target_sdk_dir/environment-setup-" \
             -e "$target_sdk_dir/relocate_sdk" \
             -e "$target_sdk_dir/post-relocate-setup" \
             -e "$target_sdk_dir/${0##*/}" | \
    xargs -n100 $SUDO_EXEC sed -i \
        -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" \
        -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" \
        -e "s: /usr/bin/perl: /usr/bin/env perl:g"

in zephyr-sdk-aarch64-hosttools-standalone-0.9.sh

@scottwcpg
Copy link
Author

@oryjkov Thanks for the work-around.
Had to use sed in binary mode and change -n100 to n1.
I also had to run the host tools script to save the intermediate scripts and edit relocate_sdk.py changing
old_prefix = re.compile(b("/opt/zephyr-sdk/0.9"))
to
old_prefix = re.compile(b("/opt/zephyr-sdk/0\.9"))
I have Python 3.13.3. I must be missing some Python backwards compatibility module or config on my system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants