From nobody Thu Dec 16 05:45:48 2021 X-Original-To: dev-commits-ports-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 0BB3B18DCDFF; Thu, 16 Dec 2021 05:45: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 4JF1LN5VQQz3FXK; Thu, 16 Dec 2021 05:45:48 +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 926472A71C; Thu, 16 Dec 2021 05:45:48 +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 1BG5jmF3068221; Thu, 16 Dec 2021 05:45:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BG5jmco068220; Thu, 16 Dec 2021 05:45:48 GMT (envelope-from git) Date: Thu, 16 Dec 2021 05:45:48 GMT Message-Id: <202112160545.1BG5jmco068220@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org From: Kyle Evans Subject: git: 446e0f2e6c79 - 2021Q4 - games/gzdoom: fix wildmidi crash List-Id: Commits to the quarterly branches of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-branches@freebsd.org X-BeenThere: dev-commits-ports-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: ports X-Git-Refname: refs/heads/2021Q4 X-Git-Reftype: branch X-Git-Commit: 446e0f2e6c79e2fbf012861c91e678a389c8852f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639633548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uS2KDPlfb05ti9aztvNfaH1dnzUjmGyNgF8rNUWno9Y=; b=sRdOx6SCqi4CHa+uua2Aw1ySPgzLJDtOWxtqq8AR6upMevmto4GygToqql6sPBWMszq9H3 weXgKsw+7RvfqQnhI7yA/6jj6y3tXOUS5QxjBmKBW4e1D5W8Aexwhl7eoSTa/WeaggJ2zR yqGNKD6D7HfFwj6pG53oaIfOZ3Tai1uuXXSNt+NKiX5Doy+b6wOw3J/2HR7gyHZcLgd1ca 1bJvyRkxHQaxo9WbwJC3DPIZEHZNHT/ShgGg/yjUjMXrgTzg3XrOnU2fJYtoVJCJrkSkxF QiSoGF6ph3QTCHK+0NC75L3ExMYyVS+eHSIIBJdDcZ5qWlJw/gQtae1rTCuHfw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639633548; a=rsa-sha256; cv=none; b=pRO7R6TUkcP7omvs7oT4CNnxuBqIs9XgGtH9NglAmjUQbe8MZVA7Iycy6ipixQd9P4oLBb gpNtk0uAUR3riNgb+IaA/4rSgPs/QHzl8GtR+5B5HYcJdSn6dputHyExEEPgnP7HhXrEBW j+cFR9jtmhu07hBkmzWnzGaSPXSmHeQZ171uMO3cB6OiFrxBhdEUfe5jow+X2YcTCU1IDg S3FBBCqwaxgi3Yj0vqxuvfedQ1ErVDtbF51KRC5xgohT2cLcOEZJ0FA+yCgF5qIWxB+9he 5zEiJhB3Hij9HOShwk1aDpKhsvTS/cJo/PkBBiezvawZtBwiNPF5xawWfh/bBg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch 2021Q4 has been updated by kevans: URL: https://cgit.FreeBSD.org/ports/commit/?id=446e0f2e6c79e2fbf012861c91e678a389c8852f commit 446e0f2e6c79e2fbf012861c91e678a389c8852f Author: Kyle Evans AuthorDate: 2021-12-16 05:36:04 +0000 Commit: Kyle Evans CommitDate: 2021-12-16 05:40:55 +0000 games/gzdoom: fix wildmidi crash get_patch_data() may recurse on itself, which is not OK to do while using std::lock_guard<>. Move the contents of get_patch_data() to a get_patch_data_locked() that may recurse on itself. This is a direct commit to quarterly, as this has since been fixed by the version present in main. Specifically, a later refactoring ends up dropping the patch_lock entirely after get_patch_data() and friends are pushed into an Instruments class anyways. Based on triage work and an initial patch by wpaul@. --- .../patch-src_sound_wildmidi_wildmidi__lib.cpp | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/games/gzdoom/files/patch-src_sound_wildmidi_wildmidi__lib.cpp b/games/gzdoom/files/patch-src_sound_wildmidi_wildmidi__lib.cpp new file mode 100644 index 000000000000..eaa3681841db --- /dev/null +++ b/games/gzdoom/files/patch-src_sound_wildmidi_wildmidi__lib.cpp @@ -0,0 +1,49 @@ +--- src/sound/wildmidi/wildmidi_lib.cpp.orig 2019-05-04 19:58:35 UTC ++++ src/sound/wildmidi/wildmidi_lib.cpp +@@ -1318,11 +1318,9 @@ static int load_sample(struct _patch *sample_patch) { + } + + static struct _patch * +-get_patch_data(unsigned short patchid) { ++get_patch_data_locked(unsigned short patchid) { + struct _patch *search_patch; + +- std::lock_guard lock(patch_lock); +- + search_patch = patch[patchid & 0x007F]; + + if (search_patch == NULL) { +@@ -1335,12 +1333,32 @@ get_patch_data(unsigned short patchid) { + } + search_patch = search_patch->next; + } + if ((patchid >> 8) != 0) { +- return (get_patch_data(patchid & 0x00FF)); ++ return (get_patch_data_locked(patchid & 0x00FF)); + } + return NULL; + } + ++static struct _patch * ++get_patch_data(unsigned short patchid) { ++ struct _patch *patch; ++ ++ /* ++ * Uh, hey, no, sorry pal, you can't use this ++ * construction here. This function can call itself ++ * recursively, which means you will recursively ++ * try to acquire the patch_lock mutex, which is ++ * not allowed with lock_guard. ++ */ ++ ++/* std::lock_guard lock(patch_lock); */ ++ ++ patch_lock.lock(); ++ patch = get_patch_data_locked(patchid); ++ patch_lock.unlock(); ++ return (patch); ++} ++ + static void load_patch(struct _mdi *mdi, unsigned short patchid) { + unsigned int i; + struct _patch *tmp_patch = NULL;