Bug 46647

Summary: Aborted
Product: Sisyphus Reporter: Anton Zhukharev <ancieg>
Component: fakechrootAssignee: Vitaly Chikunov <vt>
Status: NEW --- QA Contact: qa-sisyphus
Severity: normal    
Priority: P5 CC: aen, vt
Version: unstable   
Hardware: x86_64   
OS: Linux   
See Also: https://github.com/racket/racket/issues/4673#issuecomment-1602825804

Description Anton Zhukharev 2023-06-26 09:17:59 MSK
Packages:
=========

* fakechroot-2.20.1-alt3.x86_64



Steps to reproduce:
===================

# apt-get install fakechroot gcc
# adduser user && su - user

$ for pkg_filename in $(rpm -ql bash); do
      install -D "$pkg_filename" "chrootdir/$pkg_filename"
  done

$ cat << EOF > sample.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv) {
  ssize_t len, blen = 256;
  char *s = malloc(blen);

  while (1) {
    printf("get\n");
    len = readlink("/proc/self/exe", s, blen-1);
    printf("got\n");
    if (len == (blen-1)) {
      free(s);
      blen *= 2;
      s = malloc(blen);
    } else
      abort();
  }
  s[len] = 0;

  free(s);

  return 0;
}
EOF

$ gcc sample.c -o sample
$ cp sample chrootdir/usr/bin/
$ fakechroot chroot chrootdir /bin/bash
$ sample



Actual result:
==============

$ sample
get
got
Aborted



Expected result:
================

abort() isn't called



Extra info:
===========

* The bug is actual for p10 (fakechroot-2.20.1-alt2.x86_64).
* The bug reproduces in openSUSE Tumbleweed too (at least in a docker container).



See also:
=========
https://github.com/racket/racket/issues/4673#issue-1762310224