Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bugzilla DB migration completed. Please report issues to Infra team via email via infra@gentoo.org or IRC

Bug 687282

Summary: net-misc/openssh-7.9_p1-r4: ssh-add hangs when lto enabled
Product: Gentoo Linux Reporter: fkater <fkater>
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: UNCONFIRMED ---    
Severity: normal CC: jstein, robbat2
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description fkater 2019-06-03 15:38:52 UTC
Recently, ssh-agent stopped working.

- I boot like this: systemd-242 (+pam) / lightdm / openbox.
- ssh-agent does not appear automatically anymore.
- When run manually, ssh-add cannot find a socket.
- I cannot find a proper Gentoo way/doc on a proper setup.
- I tried all openssh versions in portage up to 8.x.

What I've tried so far:

- I followed [1] to configure a systemd user process for ssh-agent; this
  brought back the ssh-agent on next reboot.

- ~/.ssh/config has: AddKeysToAgent yes.

- Setting ~/.pam_environment to 

  >
  > SSH_AUTH_SOCK DEFAULT="${XDG_RUNTIME_DIR}/ssh-agent.socket"
  >

  does not seem to be correct for Gentoo as env will then show
  SSH_AUTH_SOCK=/ssh-agent.socket (as if XDG_RUNTIME_DIR was empty). In turn,
  calling ssh-add still can't find the socket.

- When instead, after boot, doing manually

  > 
  > export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket
  >

  then ssh-add seems to find the socket, asks for a password but then hangs
  forever with one CPU at 100%.
  
Hm...

[1] https://unix.stackexchange.com/questions/339840/how-to-start-and-use-ssh-agent-as-systemd-service
Comment 1 Jonas Stein gentoo-dev 2019-06-03 17:34:53 UTC
It is sad to read that you have problems with the software. The situation seems to be a bit more complicate and requires some analysis.
We can not help you efficiently via bug tracker. The bug tracker aims rather on specific problems in .ebuilds and less on individual systems. 

I have had very good experience on the gentoo IRC [1] with questions like this. Of course there are also forums and mailing lists [2,3].
I hope you understand, that I will close the bug here therefore and wish you good luck on one of the mentioned channels [4].
Please reopen the ticket in order to provide an indication for an specific error in an ebuild or any gentoo related product.

[1] https://www.gentoo.org/get-involved/irc-channels/
[2] https://forums.gentoo.org/
[3] https://www.gentoo.org/get-involved/mailing-lists/all-lists.html
[4] https://www.gentoo.org/support/
Comment 2 fkater 2019-06-04 09:23:48 UTC
I've edited this issue since it became clearer now.

openssh compiled with lto makes ssh-add to hang at 100% CPU.

I've tried up to openssh-7.7.x, 7.9.x, 8.0.x.

A simple test case:

- run ssh-agent manually, into new shell: ssh-agent /bin/bash
- ssh-add (brings PW entry)
- type PW + enter

Hangs, CPU at 100%.
Comment 3 Mike Gilbert gentoo-dev 2019-06-04 19:30:07 UTC
I am unable to reproduce this problem with the following config:

CFLAGS="-O2 -pipe -march=amdfam10 -flto"
LDFLAGS="-flto"

net-misc/openssh-8.0_p1-r1
sys-apps/systemd-242-r1
Comment 4 fkater 2019-06-05 06:30:46 UTC
Ok, so a bit more info from my test case:

gcc-8.3.0-r1
net-misc/openssh-8.0_p1-r1
/proc/cpuinfo: model name: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz

(1) This makes ssh-add hang:

CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=native -g0 -O3 -pipe -fomit-frame-pointer -mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register"
CFLAGS="${CFLAGS} -flto=5 -fuse-linker-plugin"
LDFLAGS="${LDFLAGS} -Wl,--as-needed -Wl,-O2 ${CFLAGS}"
AR=gcc-ar
RANLIB=gcc-ranlib
NM=gcc-nm

(2) This is my no-lto.conf what makes it work when applied:

CFLAGS="${CFLAGS} -fno-lto -fno-use-linker-plugin"
CXXFLAGS="${CXXFLAGS} -fno-lto -fno-use-linker-plugin"
LDFLAGS="${LDFLAGS} -fno-lto -fno-use-linker-plugin"