From owner-dev-commits-ports-all@freebsd.org Thu Jun 10 16:59:54 2021 Return-Path: Delivered-To: dev-commits-ports-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 E7189650E6F; Thu, 10 Jun 2021 16:59:54 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G19FQ5wM0z3mgY; Thu, 10 Jun 2021 16:59:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B2B2513667; Thu, 10 Jun 2021 16:59:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15AGxsgd025527; Thu, 10 Jun 2021 16:59:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15AGxsBR025526; Thu, 10 Jun 2021 16:59:54 GMT (envelope-from git) Date: Thu, 10 Jun 2021 16:59:54 GMT Message-Id: <202106101659.15AGxsBR025526@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Dimitry Andric Subject: git: 3217bf995f89 - main - cad/brlcad: fix null pointer accesses during build MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3217bf995f8966f12f71127472e95b581eb36f75 Auto-Submitted: auto-generated X-BeenThere: dev-commits-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the ports repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jun 2021 16:59:55 -0000 The branch main has been updated by dim (src committer): URL: https://cgit.FreeBSD.org/ports/commit/?id=3217bf995f8966f12f71127472e95b581eb36f75 commit 3217bf995f8966f12f71127472e95b581eb36f75 Author: Dimitry Andric AuthorDate: 2021-05-26 10:38:46 +0000 Commit: Dimitry Andric CommitDate: 2021-06-10 16:57:57 +0000 cad/brlcad: fix null pointer accesses during build During an exp-run for llvm 12 (see bug 255570), it turned out that cad/brlcad does not build with clang 12.0.0: [ 99% 4379/4403] cd /wrkdirs/usr/ports/cad/brlcad/work/brlcad-7.30.2/db/nist && /wrkdirs/usr/ports/cad/brlcad/work/brlcad-7.30.2/bin/step-g -O /wrkdirs/usr/ports/cad/brlcad/work/brlcad-7.30.2/share/db/nist/NIST_MBE_PMI_11.g /wrkdirs/usr/ports/cad/brlcad/work/brlcad-7.30.2/db/nist/NIST_MBE_PMI_11.stp > /wrkdirs/usr/ports/cad/brlcad/work/brlcad-7.30.2/db/nist/NIST_MBE_PMI_11.log 2>&1 FAILED: share/db/nist/NIST_MBE_PMI_11.g What happens is that the step-g intermediate program segfaults, because it attempts to access a null pointer. Valgrind shows: Reading Data from /wrkdirs/share/dim/ports/cad/brlcad/work/brlcad-7.30.2/db/nist/NIST_MBE_PMI_11.stp... HEADER read: ==24919== Invalid read of size 4 ==24919== at 0x1337BA10: EntList::firstNot(JoinType) (entlist.cc:39) ==24919== by 0x1337C93E: nextNot (complexSupport.h:185) ==24919== by 0x1337C93E: AndList::matchNonORs(EntNode*) (non-ors.cc:135) ==24919== by 0x1337B77C: ComplexList::matches(EntNode*) (complexlist.cc:176) ==24919== by 0x1337B36A: ComplexCollect::supports(EntNode*) const (collect.cc:140) ==24919== by 0x1335FA5A: STEPcomplex::Initialize(char const**, char const*) (STEPcomplex.cc:126) ==24919== by 0x1335F774: STEPcomplex::STEPcomplex(Registry*, std::__1::basic_string, std::__1::allocator > const**, int, char const*) (STEPcomplex.cc:33) ==24919== by 0x1331842E: STEPfile::CreateSubSuperInstance(std::__1::basic_istream >&, int, ErrorDescriptor&) (STEPfile.cc:1048) ==24919== by 0x13315E15: STEPfile::CreateInstance(std::__1::basic_istream >&, std::__1::basic_ostream >&) (STEPfile.cc:833) ==24919== by 0x133158B1: STEPfile::ReadData1(std::__1::basic_istream >&) (STEPfile.cc:502) ==24919== by 0x13319EA8: STEPfile::AppendFile(std::__1::basic_istream >*, bool) (STEPfile.cc:1674) ==24919== by 0x1331C984: STEPfile::ReadExchangeFile(std::__1::basic_string, std::__1::allocator >, bool) (STEPfile.inline.cc:119) ==24919== by 0x3AFDCE: STEPWrapper::load(std::__1::basic_string, std::__1::allocator >&) (STEPWrapper.cpp:1300) ==24919== Address 0x8 is not stack'd, malloc'd or (recently) free'd ==24919== ==24919== ==24919== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==24919== Access not within mapped region at address 0x8 ==24919== at 0x1337BA10: EntList::firstNot(JoinType) (entlist.cc:39) ==24919== by 0x1337C93E: nextNot (complexSupport.h:185) ==24919== by 0x1337C93E: AndList::matchNonORs(EntNode*) (non-ors.cc:135) ==24919== by 0x1337B77C: ComplexList::matches(EntNode*) (complexlist.cc:176) ==24919== by 0x1337B36A: ComplexCollect::supports(EntNode*) const (collect.cc:140) ==24919== by 0x1335FA5A: STEPcomplex::Initialize(char const**, char const*) (STEPcomplex.cc:126) ==24919== by 0x1335F774: STEPcomplex::STEPcomplex(Registry*, std::__1::basic_string, std::__1::allocator > const**, int, char const*) (STEPcomplex.cc:33) ==24919== by 0x1331842E: STEPfile::CreateSubSuperInstance(std::__1::basic_istream >&, int, ErrorDescriptor&) (STEPfile.cc:1048) ==24919== by 0x13315E15: STEPfile::CreateInstance(std::__1::basic_istream >&, std::__1::basic_ostream >&) (STEPfile.cc:833) ==24919== by 0x133158B1: STEPfile::ReadData1(std::__1::basic_istream >&) (STEPfile.cc:502) ==24919== by 0x13319EA8: STEPfile::AppendFile(std::__1::basic_istream >*, bool) (STEPfile.cc:1674) ==24919== by 0x1331C984: STEPfile::ReadExchangeFile(std::__1::basic_string, std::__1::allocator >, bool) (STEPfile.inline.cc:119) ==24919== by 0x3AFDCE: STEPWrapper::load(std::__1::basic_string, std::__1::allocator >&) (STEPWrapper.cpp:1300) ==24919== If you believe this happened as a result of a stack ==24919== overflow in your program's main thread (unlikely but ==24919== possible), you can try to increase the size of the ==24919== main thread stack using the --main-stacksize= flag. ==24919== The main thread stack size used in this run was 16777216. To fix this, add null pointer checks to EntList::firstNot() and various other EntList functions. Approved by: erik@brlcad.org (maintainer) PR: 256166 MFH: 2021Q2 --- ..._other_stepcode_src_clstepcore_complexSupport.h | 26 ++++++++++++++++++++++ ...src_other_stepcode_src_exp2cxx_complexSupport.h | 26 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/cad/brlcad/files/patch-src_other_stepcode_src_clstepcore_complexSupport.h b/cad/brlcad/files/patch-src_other_stepcode_src_clstepcore_complexSupport.h new file mode 100644 index 000000000000..393b8ffdc2c5 --- /dev/null +++ b/cad/brlcad/files/patch-src_other_stepcode_src_clstepcore_complexSupport.h @@ -0,0 +1,26 @@ +--- src/other/stepcode/src/clstepcore/complexSupport.h.orig 2020-03-12 15:32:36 UTC ++++ src/other/stepcode/src/clstepcore/complexSupport.h +@@ -182,19 +182,19 @@ class SC_CORE_EXPORT EntList { + // but all we need. + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { +- return next->firstNot( j ); ++ return next == NULL ? NULL : next->firstNot( j ); + } + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { +- return next->firstWanted( mat ); ++ return next == NULL ? NULL : next->firstWanted( mat ); + } + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { +- return prev->lastNot( j ); ++ return prev == NULL ? NULL : prev->lastNot( j ); + } + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { +- return prev->lastWanted( mat ); ++ return prev == NULL ? NULL : prev->lastWanted( mat ); + } + + JoinType join; diff --git a/cad/brlcad/files/patch-src_other_stepcode_src_exp2cxx_complexSupport.h b/cad/brlcad/files/patch-src_other_stepcode_src_exp2cxx_complexSupport.h new file mode 100644 index 000000000000..abed6c29701c --- /dev/null +++ b/cad/brlcad/files/patch-src_other_stepcode_src_exp2cxx_complexSupport.h @@ -0,0 +1,26 @@ +--- src/other/stepcode/src/exp2cxx/complexSupport.h.orig 2020-03-12 15:32:37 UTC ++++ src/other/stepcode/src/exp2cxx/complexSupport.h +@@ -162,19 +162,19 @@ class EntList { + // but all we need. + EntList * firstNot( JoinType ); + EntList * nextNot( JoinType j ) { +- return next->firstNot( j ); ++ return next == NULL ? NULL : next->firstNot( j ); + } + EntList * firstWanted( MatchType ); + EntList * nextWanted( MatchType mat ) { +- return next->firstWanted( mat ); ++ return next == NULL ? NULL : next->firstWanted( mat ); + } + EntList * lastNot( JoinType ); + EntList * prevNot( JoinType j ) { +- return prev->lastNot( j ); ++ return prev == NULL ? NULL : prev->lastNot( j ); + } + EntList * lastWanted( MatchType ); + EntList * prevWanted( MatchType mat ) { +- return prev->lastWanted( mat ); ++ return prev == NULL ? NULL : prev->lastWanted( mat ); + } + + JoinType join;