Bug 177686 - assertion failed in ld-elf.so.1 when invoking telnet with parameters (clang, EABI)
Summary: assertion failed in ld-elf.so.1 when invoking telnet with parameters (clang, ...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: 10.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-07 10:20 UTC by rz-rpi03
Modified: 2019-01-21 14:46 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rz-rpi03 2013-04-07 10:20:00 UTC
Invoking telnet with parameters triggers an assertion failure:

# telnet www.belwue.de 80
ld-elf.so.1: assert failed: /home/rpi/src/libexec/rtldelf/rtld_lock.c:233
Abort (core dumped)

While invoking without parameters does not:

# telnet
telnet> open www.belwue.de 80
Trying 2001:7c0:0:1100::a...
Trying 129.143.232.10...
Connected to www1.belwue.de.
..

Kernel and world are build on a i386 9.1-STABLE revision 248965 with:

make -C $SRCROOT -DWITH_ARM_EABI kernel-toolchain
make -C $SRCROOT MALLOC_PRODUCTION=yes -DWITH_ARM_EABI buildworld
make -C $SRCROOT KERNCONF=$KERNCONF WITH_FDT=yes -DWITH_ARM_EABI buildkernel

KERNCONF is RPI-B with serial console enabled (RPI-Bsc).

clang is FreeBSD clang version 3.2 (tags/RELEASE_32/final 170710) 20121221

How-To-Repeat: Build a system like mentioned in the description and invoke telnet with a parameter.
Comment 1 tim 2013-04-07 16:42:39 UTC
On Apr 7, 2013, at 2:15 AM, Ralf Wenk wrote:

> Invoking telnet with parameters triggers an assertion failure:
> 
> # telnet www.belwue.de 80
> ld-elf.so.1: assert failed: /home/rpi/src/libexec/rtldelf/rtld_lock.c:233
> Abort (core dumped)

I've also seen this quite a bit with a number of different
programs.  Seems to have arisen since I switched
to clang & EABI though I don't know for sure that either
of those is related.

Has anyone tracked this down?

Tim
Comment 2 Andrew Turner 2013-04-08 07:24:00 UTC
On Sun, 7 Apr 2013 09:15:08 GMT
Ralf Wenk <iz-rpi03@hs-karlsruhe.de> wrote:
> Invoking telnet with parameters triggers an assertion failure:
> 
> # telnet www.belwue.de 80
> ld-elf.so.1: assert
> failed: /home/rpi/src/libexec/rtldelf/rtld_lock.c:233 Abort (core
> dumped)

This is an issue with either llvm or out dynamic linker, I haven't
yet decided.

Normally llvm aligns the stack to an 8 byte boundary and generates code
that relies on this alignment, however for leaf functions the compiler
is allowed to only align to a 4 byte boundary.

The problem is when there are functions that, from the C code, appear to
be a leaf function however are not due to them calling other functions,
for example __aeabi_read_tp(). With a static binary this would not be
an issue, however with a dynamic libc it means, on the first call, we
enter the dynamic linker which assumes the stack is aligned.

One solution is to ensure the stack is aligned in the dynamic linker,
however I'm leaning towards llvm being broken in this case as it should
have aligned the stack correctly before calling another function as per
the ABI documentation, as the stack pointer must be 8 byte aligned at
any public interface.

Andrew
Comment 3 v1ne2go 2014-07-14 21:16:29 UTC
As a quick workaround, setting LD_BIND_NOW helps.
I tried this on gmp, which passes make check with this flag -- except C++ tests due to broken exceptions.
Without this, I also got some
  ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/rtld_lock.c:233
messages.

So, what exactly is the difference when lazy binding comes into play?
From my underständing, if a symbol is not bound, the process is as follows:
- I call some function func(), stack is 8-byte aligned
- func points to an rtld handler that loads the function and patches the function table, stack is 8-byte aligned at the start and we crash somewhere in rtld.
- rtld calls func()

vs.
- I call func(), stack is 8-byte aligned at this point
- func is being called

Was there any progress since the last year?
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:41:45 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 5 rz-rpi03 2019-01-21 14:46:13 UTC
I can not reproduce this any more. So it is fixed.
Tank you.