From owner-freebsd-current@freebsd.org Wed Jun 10 16:41:59 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E49483393F7 for ; Wed, 10 Jun 2020 16:41:59 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from drew.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.franken.de", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49ht7B3R2cz4Fhl for ; Wed, 10 Jun 2020 16:41:57 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from [IPv6:2a02:8109:1140:c3d:7000:7152:c399:835] (unknown [IPv6:2a02:8109:1140:c3d:7000:7152:c399:835]) (Authenticated sender: macmic) by drew.franken.de (Postfix) with ESMTPSA id EC1EC7220B802 for ; Wed, 10 Jun 2020 18:41:51 +0200 (CEST) From: Michael Tuexen Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: gcc versus clang issue for 32-bit binaries Message-Id: <128AB51F-0950-448F-8463-12C573C1AA38@freebsd.org> Date: Wed, 10 Jun 2020 18:41:50 +0200 To: "freebsd-current@FreeBSD.org" X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail-n.franken.de X-Rspamd-Queue-Id: 49ht7B3R2cz4Fhl X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; ASN(0.00)[asn:680, ipnet:2001:638::/32, country:DE]; local_wl_from(0.00)[freebsd.org] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jun 2020 16:42:00 -0000 Dear all, consider the following program test.c: #include #include int=20 main(void) { void *p; =09 p =3D mmap((void *)0x20000000, 0x1000000, PROT_READ | PROT_WRITE = | PROT_EXEC, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); printf("p=3D %p\n", p); return (0); } On i386 the following happens: * when compiling it with cc and running it, it crashes. * when compiling it with gcc it runs fine. On amd64 the following happens: * when compiling it with cc -m64 it runs fine. * when compiling it with cc -m32 is crashes. * when compiling it with gcc -m64 it runs fine. * when compiling it with gcc -m32 it runs fine. So why does the above program crash when compiled for 32-bit when using = clang, but runs fine when compiled with gcc. I'm testing this on 32-bit and 64-bit head systems. gcc is from ports. The reason I'm looking into it is that I want to get syzkaller working = on 32-bit with clang. Best regards Michael