From nobody Wed Dec 15 23:09:48 2021 X-Original-To: ports-bugs@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 0DC5D18EC44D for ; Wed, 15 Dec 2021 23:09:49 +0000 (UTC) (envelope-from bugzilla-noreply@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 4JDrYS6HBCz4s6n for ; Wed, 15 Dec 2021 23:09:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 B490124F60 for ; Wed, 15 Dec 2021 23:09:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1BFN9mCK005203 for ; Wed, 15 Dec 2021 23:09:48 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1BFN9mvd005202 for ports-bugs@FreeBSD.org; Wed, 15 Dec 2021 23:09:48 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 260456] games/gzdoom: GZDoom 4.1.1 crashes on start-up due to improper use of std::lock_guard Date: Wed, 15 Dec 2021 23:09:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: noisetube@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: kevans@freebsd.org X-Bugzilla-Flags: maintainer-feedback? X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter flagtypes.name Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Ports bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-ports-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports-bugs@freebsd.org X-BeenThere: freebsd-ports-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639609788; 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=WE8atzSDtF/tMCEjvsZwGcHwqbJ1g8zKOx+8/Ktb8eQ=; b=ZhK6NCwOJsEPFe7UUuGpWsvYd25Itp0tVu25WTN3ZRC9umQ0fzccC/0lsvKbu4zgNt8bJQ sQPNpQfCO5hSJHiYuZM7oU1aYsFeaPa2c2Yr6LByfnfN+4+UMhzoFyhigRCRD0o3ALyQyI vXEIAU0humE/Flt+VBO0NGsUeu+kKViAkBKwI6X3mdX5L5eSGsgMP+uVMHf4elLaAfpWPo 0XkzHt5E9+j3ugDgruarsHBhOMK14qby+1Lep1u977TAYTQ0TATdNBT9Pz+ysqs8BetsFt PXtTFblbwXo42SHFk0W65NXKJwsdG5DQ/HT04IbLsWozWl10q/iwPeU2s30G9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639609788; a=rsa-sha256; cv=none; b=OPTZTJGaQGBLMeoh7wThWfDNHII76G4gBf9JvA6C0CsfN7WI46jn11gPRPxyzVBFFp9uyq ENp6EVla5TpRQRGm8nN1RkS1r/9QQ/xvxZaNYNk8+ZSRjGX/lu9yYsD5Etq7SOHuovVRNr E+6Qu/ei3+TXWe3CxGBt8GBn83nv+EdIZTGA9QOiTJVaEEBMfPjTWITTlEwkPzkcfuJmFz 2W/Xu50S2mHSsgCSZT6VtvSVtYvQvdCJqsjH4TPtWsJ8iqDsTt862OLQU2E3uEn1rC2DFO rchMxkRQ1fTLofH0GVA680KmxUgQYhZjxKykThoj7abTXsTnuJpsOtfzmCMXyg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260456 Bug ID: 260456 Summary: games/gzdoom: GZDoom 4.1.1 crashes on start-up due to improper use of std::lock_guard Product: Ports & Packages Version: Latest Hardware: amd64 OS: Any Status: New Severity: Affects Many People Priority: --- Component: Individual Port(s) Assignee: kevans@freebsd.org Reporter: noisetube@gmail.com Assignee: kevans@freebsd.org Flags: maintainer-feedback?(kevans@freebsd.org) The GZDoom port might compile ok, but it doesn't run, at least not for me w= ith FreeBSD/amd64 12.2-RELEASE or 12.3-RELEASE. When I launch it, it crashes and dumps core while performing sound initialization. After some digging, I fou= nd that the root cause seems to be a bug in the wildmidi_lib.cpp module. GZDoom supports a number of different options for playing Doom MIDI/MUS mus= ic, one of which is the WildMidi library. The actual WildMidi library is writte= n in C, but GZDoom includes its own bastardized^Wcustom version which has been re-written in C++. Internally, wildmidi_lib.cpp uses mutexes when loading p= atch files. The get_patch_data() function in particular makes use of a C++ facility cal= led std::lock_guard. The salient feature of this facility is that it allows mut= exes to be automatically released when reaching end of scope. This allows you to take a lock on entry to a function and have the lock automatically released when the function returns, saving than the programmer having to insert the = code to do this themselves, like an animal. The only problem is that get_patch_data() recursively calls itself, and if I understand correctly, you can't use std::lock_guard with recurs= ive functions. I'm not sure how this ever worked; maybe you can get away with it when using GCC. But FreeBSD and Clang/LLVM hate it. I managed to create a patch that fixes this problem which can be obtained h= ere: http://people.freebsd.org/~wpaul/gzdoom You can copy the patch-src_sound_wildmidi_wildmidi_lib.cpp file into /usr/ports/games/gzdoom/files and rebuild the port, and it should run corre= ctly now. Instead of using std::lock_guard, the lock is now taken/given directly, and released before get_patch_data() recursively calls itself. Note that I am not an expert at C++, so I can't claim that my approach is entirely correct, but it at least it seems to make GZDoom run. On a side note, 4.1.1 is a very old version. In the most recent version, the WildMidi code had been reworked significantly and no longer has this proble= m. --=20 You are receiving this mail because: You are the assignee for the bug.=