From nobody@FreeBSD.org  Sun Apr  7 09:15:09 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id D9CA4288
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Apr 2013 09:15:09 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id C9AA91F3D
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Apr 2013 09:15:09 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r379F8uJ096495
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 7 Apr 2013 09:15:08 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r379F83s096494;
	Sun, 7 Apr 2013 09:15:08 GMT
	(envelope-from nobody)
Message-Id: <201304070915.r379F83s096494@red.freebsd.org>
Date: Sun, 7 Apr 2013 09:15:08 GMT
From: Ralf Wenk <iz-rpi03@hs-karlsruhe.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: assertion failed in ld-elf.so.1 when invoking telnet with parameters (clang, EABI)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         177686
>Category:       arm
>Synopsis:       assertion failed in ld-elf.so.1 when invoking telnet with parameters (clang, EABI)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-arm
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 07 09:20:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Mon Apr  8 06:30:00 UTC 2013
>Originator:     Ralf Wenk
>Release:        FreeBSD 10.0-CURRENT arm
>Organization:
Hochschule Karlsruhe, University of Applied Sciences
>Environment:
FreeBSD raspberry-pi 10.0-CURRENT FreeBSD 10.0-CURRENT #8 r249220: Sun Apr  7 10:16:15 CEST 2013     root@home:/usr/obj/arm.armv6/home/rpi/src/sys/RPI-Bsc  arm
>Description:
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.
>Fix:


>Release-Note:
>Audit-Trail:

From: Tim Kientzle <tim@kientzle.com>
To: Ralf Wenk <iz-rpi03@hs-karlsruhe.de>, freebsd-arm@freebsd.org
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: arm/177686: assertion failed in ld-elf.so.1 when invoking telnet with parameters (clang, EABI)
Date: Sun, 7 Apr 2013 08:42:39 -0700

 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
 

From: Andrew Turner <andrew@fubar.geek.nz>
To: Ralf Wenk <iz-rpi03@hs-karlsruhe.de>
Cc: freebsd-gnats-submit@FreeBSD.org, freebsd-arm@freebsd.org
Subject: Re: arm/177686: assertion failed in ld-elf.so.1 when invoking
 telnet with parameters (clang, EABI)
Date: Mon, 8 Apr 2013 18:24:00 +1200

 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
>Unformatted:
