Failed Chroot after Pacstrap

I’m trying to arch-chroot after performing a pacstrap and it is leading to a segmentation fault.
This is happening on pacstraps on mounted folders, loop devices and even micro SD cards.
The issue occurs on both arm and x64.
Here are the steps to reproduce. You need the arch-install-scripts package to run these commands. The package provides both pacstrap and arch-chroot commands.

mkdir -p MP
sudo mount --bind MP MP
sudo pacstrap -G MP base linux
sudo arch-chroot MP

Here is the error message. This didn’t happen a few weeks ago.

/usr/bin/arch-chroot: line 457: 23599 Segmentation fault      (core dumped) SHELL=/bin/bash $pid_unshare chroot "${chroot_args[@]}" -- "$chrootdir" "${args[@]}"

I’ve even tried downgrading arch-install-scripts, and the error still occurs.
arch-chroot is still working on existing installs and chroots created via systemd-nspawn.

I’m looking for the reason this is occurring and any possible fixes.

What is on this line?

2 Likes

Line 457 starts here:

arch-chroot() {
  (( EUID == 0 )) || die 'This script must be run with root privileges'

  [[ -d $chrootdir ]] || die "Can't create chroot on non-directory %s" "$chrootdir"

  $setup "$chrootdir" || die "failed to setup chroot %s" "$chrootdir"
  chroot_add_resolv_conf "$chrootdir" || die "failed to setup resolv.conf"

  if ! mountpoint -q "$chrootdir"; then
    warning "$chrootdir is not a mountpoint. This may have undesirable side effects."
  fi

  chroot_args=()
  [[ $userspec ]] && chroot_args+=(--userspec "$userspec")

  SHELL=/bin/bash $pid_unshare chroot "${chroot_args[@]}" -- "$chrootdir" "${args[@]}"
}

I assume this line is the problem:

sudo mount --bind MP MP

What is it trying to do?

EDIT: I tried the commands (in a fully updated VirtualBox VM) you wrote and it does not cause core dump, but seems to work.

1 Like

You can’t chroot directly into a folder. It causes issues with pacman etc, and also throws an error when you try to do so.
It’s to create a mount point from a folder.

I don’t think that’s the problem since I tried it on an external storage device (micro SD card) and loop device which doesn’t need that line.

I did the same a few hours ago and it didn’t work and @joekamprad tried it yesterday and had the same error.
Let me update and try again now.
(Same error)
Here is the output of strace arch-chroot MP. I don’t know how to interpret it:
https://0x0.st/oY3l.txt

The error is also occurring on a fresh install in VBox VM I did on Saturday too.

Could this be the issue? @dalto @manuel @joekamprad ??

Maybe, and easy to test by installing it from the testing repo.

Apparently the solution is this (its working for me):

sudo env LC_ALL=C arch-chroot MP     
1 Like

so only happen if you do not use en_us?

I’m confused.
This is apparently a readline bug as I’ve mentioned before.

An update to readline landed on arch x64 and it fixed the issue.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.