From nobody Mon Nov 22 16:34:49 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 88A3E1889886; Mon, 22 Nov 2021 16:34:49 +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 4HyXtK3DWMz3lY5; Mon, 22 Nov 2021 16:34:49 +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 4F880261EC; Mon, 22 Nov 2021 16:34:49 +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 1AMGYnil064343; Mon, 22 Nov 2021 16:34:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AMGYncN064342; Mon, 22 Nov 2021 16:34:49 GMT (envelope-from git) Date: Mon, 22 Nov 2021 16:34:49 GMT Message-Id: <202111221634.1AMGYncN064342@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 22082f15f9bb - releng/12.3 - When copying types from one CTF container to another, ensure that we always copy intrinsic data types before copying bitfields which are based on those types. This ensures the type ordering in the destination CTF container matches the assumption made elsewhere in the CTF code that instrinsic data types will always appear before bitfields based on those types. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.3 X-Git-Reftype: branch X-Git-Commit: 22082f15f9bbc06c43cdc75a5c77a92ac96f612c Auto-Submitted: auto-generated X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N The branch releng/12.3 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=22082f15f9bbc06c43cdc75a5c77a92ac96f612c commit 22082f15f9bbc06c43cdc75a5c77a92ac96f612c Author: Jonathan T. Looney AuthorDate: 2020-11-17 14:07:27 +0000 Commit: Mark Johnston CommitDate: 2021-11-22 16:31:45 +0000 When copying types from one CTF container to another, ensure that we always copy intrinsic data types before copying bitfields which are based on those types. This ensures the type ordering in the destination CTF container matches the assumption made elsewhere in the CTF code that instrinsic data types will always appear before bitfields based on those types. This resolves the following error message some users have seen after r366908: "/usr/lib/dtrace/ipfw.d", line 121: failed to copy type of 'ip6p': Conflicting type is already defined Reviewed by: markj Approved by: re (gjb) Sponsored by: Netflix (cherry picked from commit 3cbb4cc200f8a0ad7ed08233425ea54524a21f1c) (cherry picked from commit 4faff19d63053defffe707312c6208c2b1e934ef) --- cddl/contrib/opensolaris/common/ctf/ctf_create.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cddl/contrib/opensolaris/common/ctf/ctf_create.c b/cddl/contrib/opensolaris/common/ctf/ctf_create.c index a2ca81960f73..46e2b7faf437 100644 --- a/cddl/contrib/opensolaris/common/ctf/ctf_create.c +++ b/cddl/contrib/opensolaris/common/ctf/ctf_create.c @@ -1258,7 +1258,7 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type) uint_t kind, flag, vlen; ctf_bundle_t src, dst; - ctf_encoding_t src_en, dst_en; + ctf_encoding_t src_en, main_en, dst_en; ctf_arinfo_t src_ar, dst_ar; ctf_dtdef_t *dtd; @@ -1373,6 +1373,27 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type) if (ctf_type_encoding(src_fp, src_type, &src_en) != 0) return (ctf_set_errno(dst_fp, ctf_errno(src_fp))); + /* + * This could be a bitfield, and the CTF library assumes + * intrinsics will appear before bitfields. Therefore, + * try to copy over the intrinsic prior to copying the + * bitfield. + */ + if (dst_type == CTF_ERR && name[0] != '\0' && + (hep = ctf_hash_lookup(&src_fp->ctf_names, src_fp, name, + strlen(name))) != NULL && + src_type != (ctf_id_t)hep->h_type) { + if (ctf_type_encoding(src_fp, (ctf_id_t)hep->h_type, + &main_en) != 0) { + return (ctf_set_errno(dst_fp, + ctf_errno(src_fp))); + } + if (bcmp(&src_en, &main_en, sizeof (ctf_encoding_t)) && + ctf_add_type(dst_fp, src_fp, + (ctf_id_t)hep->h_type) == CTF_ERR) + return (CTF_ERR); /* errno is set for us */ + } + if (dst_type != CTF_ERR) { if (ctf_type_encoding(dst_fp, dst_type, &dst_en) != 0) return (CTF_ERR); /* errno is set for us */