From owner-freebsd-hackers@freebsd.org Sun Jan 21 23:33:26 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6192FEC1899 for ; Sun, 21 Jan 2018 23:33:26 +0000 (UTC) (envelope-from yuripv@icloud.com) Received: from pv33p00im-asmtp003.me.com (pv33p00im-asmtp003.me.com [17.142.194.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 44ECC81310; Sun, 21 Jan 2018 23:33:26 +0000 (UTC) (envelope-from yuripv@icloud.com) Received: from process-dkim-sign-daemon.pv33p00im-asmtp003.me.com by pv33p00im-asmtp003.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0P2X00F00I0ZSV00@pv33p00im-asmtp003.me.com>; Sun, 21 Jan 2018 23:33:18 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=04042017; t=1516577598; bh=rOppae8Tlmnddz2Zvmhas+EpnEcqp5vslH24Lc/Tbio=; h=Subject:To:From:Message-id:Date:MIME-version:Content-type; b=WmhxUPAkViWmLKVa0KF5WZmB5SbWhm63RSMwiAt/ur3kouBlWbcdD8ua4hCYY/8j/ bfsDPRE/fc0Nk7fi0fOFgRyTuXTF5WWBNfCJ8sr/Fy/QwvBgkmc4cBJPFWoFsVOzT2 kY0Rtmik+xmk9F7Jo4SdJB9YO696y4RfU4GcLANDD6CIWgNgKMfZEEenUImAz2jtt/ R3CC/EEdcL2gFvvp3OgTHWxSBoAD17kem2+lDCQT+vhBklFWL1CRT6ibLWmFjmJfqj 10WT0Ugog0+ZNXkkQ1B/RCGFzbC3OVf2YkM8Yzoj9bUy9Y9kCVkyQBIX8DsjrAGvKx zWPO+rp2k72xw== Received: from icloud.com ([127.0.0.1]) by pv33p00im-asmtp003.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0P2X001FMIRCMR10@pv33p00im-asmtp003.me.com>; Sun, 21 Jan 2018 23:33:16 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-21_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1801210338 Subject: Re: Calling getaddrinfo(3) in 32-bit binary on 64-bit host To: Li-Wen Hsu , freebsd-hackers@freebsd.org References: From: Yuri Pankov Message-id: <8c6dc5b5-7640-61fc-b687-08efd1e621ee@icloud.com> Date: Mon, 22 Jan 2018 02:33:12 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-language: en-US Content-transfer-encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jan 2018 23:33:26 -0000 On Mon, Jan 22, 2018 at 05:14:59AM +0800, Li-Wen Hsu wrote: > Hi all, > > Recently I found a strange case: calling getaddrinfo(3) cannot resolve IPv6 > address in 32-bit binary on 64-bit host. > It happens on vanilla installed 11.1-R and also on r327788 snapshot build. > > For a program like this: > https://gist.github.com/lwhsu/1288aa5be90b9e7da934a3e2bfc55aa3 > > It works fine when compiled as a 32-bit binary and run on a 32-bit host. > As expected, It is also works fine when compiled as a 64-bit binary and run > on a 64-bit host > > However, when taking the 32-bit binary and run on a 64 bit system (with > /usr/lib32 installed), > getaddrinfo(3) just returns: "Non-recoverable failure in name resolution" Apparently, it goes through addrconfig() down to getifaddrs() returning bogus data for IPv6 addresses. This most likely has to with SALIGN being incorrect for 32-bit binary trying to parse route messages from 64-bit kernel. I'm not sure about proper fix here, but changing SALIGN to be 7 (that is, "sizeof(long) - 1" on amd64 platform) makes your test case return correct data.