From owner-svn-src-all@freebsd.org Fri Sep 18 11:22:35 2020 Return-Path: Delivered-To: svn-src-all@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 3D7D93E0607; Fri, 18 Sep 2020 11:22:35 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BtBJW0hsnz4RGP; Fri, 18 Sep 2020 11:22:35 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFBC51A33D; Fri, 18 Sep 2020 11:22:34 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08IBMYtt032316; Fri, 18 Sep 2020 11:22:34 GMT (envelope-from arichardson@FreeBSD.org) Received: (from arichardson@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08IBMYpo032313; Fri, 18 Sep 2020 11:22:34 GMT (envelope-from arichardson@FreeBSD.org) Message-Id: <202009181122.08IBMYpo032313@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arichardson set sender to arichardson@FreeBSD.org using -f From: Alex Richardson Date: Fri, 18 Sep 2020 11:22:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365876 - in head/lib/libarchive: . tests X-SVN-Group: head X-SVN-Commit-Author: arichardson X-SVN-Commit-Paths: in head/lib/libarchive: . tests X-SVN-Commit-Revision: 365876 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2020 11:22:35 -0000 Author: arichardson Date: Fri Sep 18 11:22:34 2020 New Revision: 365876 URL: https://svnweb.freebsd.org/changeset/base/365876 Log: libarchive: fix mismatch between library and test configuration I was investigating libarchive test failures on CheriBSD and it turns out we get a reproducible SIGBUS for test_archive_m5, etc. Debugging this shows that libarchive and the tests disagree when it comes to the definition of archive_md5_ctx: libarchive assumes it's the OpenSSL type whereas the test use the libmd type. The latter is not necessarily aligned enough to store a pointer (16 bytes for CHERI RISC-V), so we were crashing when storing EVP_MD_CTX* to an 8-byte-aligned archive_md5_ctx. To avoid problems like this in the future, factor out the common compiler flags into a Makefile.inc and include that from the tests Makefile. Reviewed By: lwhsu Differential Revision: https://reviews.freebsd.org/D26469 Added: head/lib/libarchive/Makefile.inc (contents, props changed) Modified: head/lib/libarchive/Makefile head/lib/libarchive/tests/Makefile Modified: head/lib/libarchive/Makefile ============================================================================== --- head/lib/libarchive/Makefile Fri Sep 18 11:04:16 2020 (r365875) +++ head/lib/libarchive/Makefile Fri Sep 18 11:22:34 2020 (r365876) @@ -6,29 +6,13 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive LIB= archive -LIBADD= z bz2 lzma bsdxml zstd -CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 -DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1 - # FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system. # It has no real relation to the libarchive version number. SHLIB_MAJOR= 7 -CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\" CFLAGS+= -I${.OBJDIR} CFLAGS+= -I${SRCTOP}/sys/contrib/zstd/lib - -.if ${MK_OPENSSL} != "no" -CFLAGS+= -DWITH_OPENSSL -LIBADD+= crypto -.else -LIBADD+= md -.endif - -.if ${MK_ICONV} != "no" -# TODO: This can be changed back to CFLAGS once iconv works correctly -# with statically linked binaries. -SHARED_CFLAGS+= -DHAVE_ICONV=1 -DHAVE_ICONV_H=1 -DICONV_CONST= -.endif +.include "Makefile.inc" .if ${MACHINE_ARCH:Marm*} != "" || ${MACHINE_ARCH:Mmips*} != "" || \ ${MACHINE_ARCH:Mpowerpc*} != "" Added: head/lib/libarchive/Makefile.inc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libarchive/Makefile.inc Fri Sep 18 11:22:34 2020 (r365876) @@ -0,0 +1,21 @@ +# $FreeBSD$ +# These defines are needed for both libarchive and the tests. If we don't keep +# them in sync we can get run-time crashes while running tests due to mismatches +# between structures such as archive_md5_ctx, etc. + +LIBADD= z bz2 lzma bsdxml zstd +CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 -DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1 +CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\" + +.if ${MK_OPENSSL} != "no" +CFLAGS+= -DWITH_OPENSSL +LIBADD+= crypto +.else +LIBADD+= md +.endif + +.if ${MK_ICONV} != "no" +# TODO: This can be changed back to CFLAGS once iconv works correctly +# with statically linked binaries. +SHARED_CFLAGS+= -DHAVE_ICONV=1 -DHAVE_ICONV_H=1 -DICONV_CONST= +.endif Modified: head/lib/libarchive/tests/Makefile ============================================================================== --- head/lib/libarchive/tests/Makefile Fri Sep 18 11:04:16 2020 (r365875) +++ head/lib/libarchive/tests/Makefile Fri Sep 18 11:22:34 2020 (r365876) @@ -1,4 +1,5 @@ # $FreeBSD$ +.include PACKAGE= tests @@ -15,7 +16,7 @@ PROGS+= libarchive_test CFLAGS+= -I${.CURDIR} -I${.CURDIR:H} -I${.OBJDIR} CFLAGS+= -I${_LIBARCHIVEDIR}/libarchive -I${_LIBARCHIVEDIR}/libarchive/test CFLAGS+= -I${_LIBARCHIVEDIR}/test_utils -CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 +.include "../Makefile.inc" # Uncomment to link against dmalloc #LDADD+= -L/usr/local/lib -ldmalloc @@ -298,10 +299,6 @@ TESTS_SRCS= \ test_zip_filename_encoding.c # Deterministic failures: -# Crashes with SIGBUS -BROKEN_TESTS+= test_archive_rmd160 -# Fails with `libarchive/test/test_archive_crypto.c:121: md != actualmd` -BROKEN_TESTS+= test_archive_sha384 # Fails with `test_read_disk_directory_traversals.c:1094: File at has atime 886622, 1443306049 seconds ago` BROKEN_TESTS+= test_read_disk_directory_traversals