Bug#761300: libc6: Printf("%c",'x') does not follow stdio

2018-10-13 Thread Sven Joachim
Control: retitle -1 libc6: putchar does not follow stdio

On 2014-09-12 09:10 -0700, Thomas D. Dean wrote:

> Package: libc6
> Version: 2.13-38+rpi2+deb7u3
> Severity: normal
>
> Dear Maintainer,
>
>* What led up to the situation?
>
> Redirecting stdout in C code does not work for printf("%c",'x')
> I ssh into the system.  I want to redirect all output to stdout to
> the local terminal.  This works as expected for everything except
> when printing a single character.
>
>* What exactly did you do (or not do) that was effective (or
>  ineffective)?
>
>   FILE *display_fp;
>   if ((display_fp = fopen("/dev/tty1","r+")) == NULL) {
>  perror("Open /dev/tty1");
>  return -1;
>   }
>   stdout = display_fp;
>
> Then,
>
> printf("%s","asdfasdf"); /* output to /dev/tty1 */
> printf("%c",'x'); /* output to original terminal */
>
>* What was the outcome of this action?
>
> All the output except for the "%c" case went to /dev/tty1.  The
> output in the "%c" case went to the ssh terminal

It is actually a bit more subtle than that, as gcc has its own printf
builtin function which comes into play.  Compiling the program with
-fno-builtin in fact makes it work as intended (at least with glibc
2.27-6).

Looking closer, I found that with -fno-builtin

printf("%c",'x');   works
putc('x', stdout);  works
putchar('x');   exhibits the bug

This result is rather surprising.  After all, "putchar('x')" is supposed
to do the same as "putc('x', stdout)", but here it does not.

I'm attaching the whole program, so that future researchers have less to
copy and paste.

Cheers,
   Sven

#include 
#include 

int main (int argc, char** argv)
{
  FILE *display_fp;
  if ((display_fp = fopen("/dev/tty1","r+")) == NULL) {
perror("Open /dev/tty1");
return -1;
  }
  stdout = display_fp;
  printf("%s","asdfasdf"); /* output to /dev/tty1 */
  putchar('x'); /* output to original terminal */
}


Processed: Re: Bug#761300: libc6: Printf("%c",'x') does not follow stdio

2018-10-13 Thread Debian Bug Tracking System
Processing control commands:

> retitle -1 libc6: putchar does not follow stdio
Bug #761300 [libc6] libc6: Printf("%c",'x') does not follow stdio
Changed Bug title to 'libc6: putchar does not follow stdio' from 'libc6: 
Printf("%c",'x') does not follow stdio'.

-- 
761300: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=761300
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#910923: $PLATFORM is no longer expanded.

2018-10-13 Thread Roman Lebedev
Source: glibc
Version: 2.27-6
Severity: important

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Reproduction:
$ strace -ELD_PRELOAD='/sss/${PLATFORM}/'  -s300  /bin/cat
execve("/bin/cat", ["/bin/cat"], 0x55ddc6b820f0 /* 64 vars */) = 0
brk(NULL)   = 0x56046d9c1000
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or directory)
readlink("/proc/self/exe", "/bin/cat", 4096) = 8
openat(AT_FDCWD, "/sss/x86_64/", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such 
file or directory)
writev(2, [{iov_base="ERROR: ld.so: object '", iov_len=22}, 
{iov_base="/sss/${PLATFORM}/", iov_len=21}, {iov_base="' from ", 
iov_len=7}, {iov_base="LD_PRELOAD", iov_len=10}, {iov_base=" cannot be 
preloaded (", iov_len=22}, {iov_base="cannot open shared object file", 
iov_len=30}, {iov_base="): ignored.\n", iov_len=12}], 7ERROR: ld.so: object 
'/sss/${PLATFORM}/' from LD_PRELOAD cannot be preloaded (cannot open shared 
object file): ignored.
) = 124

So $PLATFORM is not expanded. This is a regression from 2.24
According to
https://sourceware.org/bugzilla/show_bug.cgi?id=22299
it *should* be fixed in 2.27, but it is clerly still reproducible in
debian testing/sid.

This is causing the following problem for me:
https://community.sonarsource.com/t/sonarqube-c-ubuntu-build-wrapper-ld-preload-error/300/2

Roman.

- -- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'unstable-debug'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.18.0-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

-BEGIN PGP SIGNATURE-

iQIzBAEBCgAdFiEEjkF6151RK40WXe2HCDw+u0oWieAFAlvB74kACgkQCDw+u0oW
ieC64A/+NJUBom7TnJ2IDVydGFTAtoEpBU/ShodqYPuZ/Yh020UHL/xQ6Y/XEeGk
/hjR0VadQFxJlIQcCygUVb10+q1JslT2FMWAtL4nyfD3FhSHjzBgzKthqbd0Gj4X
9SY4eZ6J85zUv+V505sAu550oUgGI9HQmxsVPa4yZqkAvL5Q6bZTW6w8vKZUH7ix
yaInTC7KXT9n0GCyoGiiLoW3hmH0JYcw99Emt26HaTyHCbMiMMZlPYxAp5UnxAFF
1VTZp69rYxePLQvuCi+wv452WVSdA8xeN6LO1uxvpkHuHefNj2v6XGmzmLEE8LWU
zTMFyyNu29bX7YYKNVLLUA3gPz9hqgTysEK3tLotLho0gTwYUt//RBiJD8/XktHP
pC0TDVbhMO/gqfsSLWLwHx5OOMXv+Xif5Z5OyQS/RI7O2deF2lsBDXGFmghUPGh2
nsZ/gTqdK/37UvtL4UgnSg5AOd4+VE6rI6XuLUrbbGsJ/OBDTj+HbriaSgStDo/k
O82reGp8M/33iyR0UN5YjqBgcVL27KtcJdDZKUmnQFcVfkbE3iFp44EMSOY0180A
QTZXYw4xA2yTdrq7JdfQqAws6f3X+e4S9JHoWIp5rRqpjRlH9HLwWzQ/+j9cR32U
eAvtOowmWRSoQbRO5muoGd96aRGeqcLwHHv4GYLBqR/Xziu6NFE=
=8rcH
-END PGP SIGNATURE-