From owner-freebsd-arm@FreeBSD.ORG Sat Dec 21 17:24:21 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6A48F82F for ; Sat, 21 Dec 2013 17:24:21 +0000 (UTC) Received: from mail-ob0-x243.google.com (mail-ob0-x243.google.com [IPv6:2607:f8b0:4003:c01::243]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 332FF1346 for ; Sat, 21 Dec 2013 17:24:21 +0000 (UTC) Received: by mail-ob0-f195.google.com with SMTP id gq1so1060591obb.6 for ; Sat, 21 Dec 2013 09:24:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=seExFxcXaA9S/hCZXx57p2kZC/Y0P4pohaCRqs1WF20=; b=hfygTy76/FE2g0dGOvb0Id/AzWqs9yT4QzmxRG21uP5rTYOy2bzbthut4X/7JRpB0S FxWQXFIXCD3HpRI67prbMUUFLEXuNvcQdThAL9Uz4iJQNOig2z+uRs5LyW15E+xM5WSG B47lLxG1Eqol7QdjUaJ0/pfBnXf+tnh7yURUXXRw6vTCAJ41PGtfcRMUzMnkVtrnG2UV 6Pn+AQmtmdD2/rABKRHm8LKSQ/HXNXqLXBg+86SDc/QDWqpVAFRXK5oWaE4moanhwiMU eAWxN3C8P377jGaCfJ9iYfnKMYhvGmI8ynaZWayr4+Fh57rRnvLwMedGiAEJBFqh50Y2 4I6w== MIME-Version: 1.0 X-Received: by 10.60.54.168 with SMTP id k8mr5924868oep.56.1387646660010; Sat, 21 Dec 2013 09:24:20 -0800 (PST) Received: by 10.76.20.82 with HTTP; Sat, 21 Dec 2013 09:24:19 -0800 (PST) Date: Sat, 21 Dec 2013 19:24:19 +0200 Message-ID: Subject: 10.0-RC1: net/mpd5 crashes in NgMkSockNode due to stack alignment on ARM EABI From: Guy Yur To: freebsd-arm@freebsd.org Content-Type: multipart/mixed; boundary=089e011606003e923e04ee0eaac1 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Dec 2013 17:24:21 -0000 --089e011606003e923e04ee0eaac1 Content-Type: text/plain; charset=UTF-8 Hi, I am running 10.0-RC1 on the BeagleBone Black and the net/mpd5 port is crashing in libnetgraph NgMkSockNode due to stack alignment. 10.0-RC1 World and kernel were compiled in a VirtualBox VM running 9.2-RELEASE-p2 i386. clang and ARM_EABI used as the default make options. Added prints in NgMkSockNode show rbuf is aligned on 2-byte and not 4-byte which is needed to access ni->id (a uint32_t). ni = 0xbfffe87a rbuf = 0xbfffe842 sizeof(resp->header) = 56 (gdb) bt #0 0x201529a0 in NgMkSockNode (name=, csp=0xbfffe95c, dsp=0xbfffe958) at /usr/src/lib/libnetgraph/sock.c:134 #1 0x00037b9c in MppcTestCap () at ccp_mppc.c:754 #2 0x0007c1f4 in main (ac=4, av=0xbfffeb90) at main.c:248 #3 0x0000d1b0 in __start (argc=4, argv=0xbfffeb90, env=0xbfffeba4, ps_strings=, obj=, cleanup=) at /usr/src/lib/csu/arm/crt1.c:115 #4 0x203e9dc0 in _thr_ast (curthread=0x200fd000) at /usr/src/lib/libthr/thread/thr_sig.c:265 Putting rbuf in a union with struct ng_mesg sorted the alignment to 4-byte and mpd5 didn't crash. I attached the changes I used to test mpd5 doesn't crash with correct alignment. Regards, Guy --089e011606003e923e04ee0eaac1 Content-Type: application/octet-stream; name="sock-NgMkSockNode.patch" Content-Disposition: attachment; filename="sock-NgMkSockNode.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hph47tdv0 SW5kZX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