Bug 273573 - emulators/pcsx2: unbreak with kern.elf64.allow_wx=0
Summary: emulators/pcsx2: unbreak with kern.elf64.allow_wx=0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Ganael LAPLANCHE
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-05 02:03 UTC by Jan Beich
Modified: 2023-09-05 10:19 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (martymac)


Attachments
v1 (apply via "git am") (1.20 KB, patch)
2023-09-05 02:03 UTC, Jan Beich
no flags Details | Diff
v1 (apply via "git am") (1.20 KB, patch)
2023-09-05 02:12 UTC, Jan Beich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2023-09-05 02:03:41 UTC
Created attachment 244646 [details]
v1 (apply via "git am")

$ sysctl kern.elf64.allow_wx=0
$ pcsx2-qt
[...]
Video Dumping Directory: /home/foo/.config/PCSX2/videos
Segmentation fault

Process 52821 stopped
* thread #7, name = 'CPU Thread', stop reason = signal SIGSEGV: invalid address (fault address: 0xe4edae0)
    frame #0: 0x000000082c29c41d libthr.so.3`check_and_init_mutex(mutex=0x000000000e4edae0, m=0x000000086944ba40) at thr_mutex.c:597:7
   594  {
   595          int ret;
   596
-> 597          *m = *mutex;
   598          ret = 0;
   599          if (*m == THR_PSHARED_PTR) {
   600                  *m = __thr_pshared_offpage(mutex, 0);
(lldb) bt
* thread #7, name = 'CPU Thread', stop reason = signal SIGSEGV: invalid address (fault address: 0xe4edae0)
  * frame #0: 0x000000082c29c41d libthr.so.3`check_and_init_mutex(mutex=0x000000000e4edae0, m=0x000000086944ba40) at thr_mutex.c:597:7
    frame #1: 0x000000082c29bb86 libthr.so.3`__Tthr_mutex_lock(mutex=0x000000000e4edae0) at thr_mutex.c:753:8
    frame #2: 0x000000082ea37289 libc++.so.1`std::__1::mutex::lock() [inlined] std::__1::__libcpp_mutex_lock(__m=<unavailable>) at __threading_support:303:10
    frame #3: 0x000000082ea37284 libc++.so.1`std::__1::mutex::lock(this=<unavailable>) at mutex.cpp:33:14
    frame #4: 0x0000000000a2edc7 pcsx2-qt`std::__1::unique_lock<std::__1::mutex>::unique_lock(this=0x000000086944bcc0, __m=0x000000000e4edae0) at __mutex_base:119:61
    frame #5: 0x00000000011824fa pcsx2-qt`pxOnAssertFail(file="/wrkdirs/usr/ports/emulators/pcsx2/work/pcsx2-1.7.4970/pcsx2/System.cpp", line=181, func="VirtualMemoryManagerPtr makeMemoryManager(const char *, const char *, size_t, size_t)", msg="Failed to find a good place for the memory allocation, recompilers may fail") at Assertions.cpp:95:19
    frame #6: 0x0000000000b2dcce pcsx2-qt`makeMemoryManager(name="Code Memory Manager", file_mapping_name=0x0000000000000000, size=319815680, offset_from_base=335544320) at System.cpp:181:3
    frame #7: 0x0000000000b2d9e2 pcsx2-qt`SysMainMemory::SysMainMemory(this=0x000018692aa24000) at System.cpp:191:17
    frame #8: 0x0000000000b53ead pcsx2-qt`std::__1::__unique_if<SysMainMemory>::__unique_single std::__1::make_unique<SysMainMemory>() at unique_ptr.h:725:32
    frame #9: 0x0000000000b4545a pcsx2-qt`VMManager::Internal::CPUThreadInitialize() at VMManager.cpp:347:16
    frame #10: 0x00000000007afa74 pcsx2-qt`EmuThread::run(this=0x0000186924a11520) at QtHost.cpp:377:7
    frame #11: 0x000000082fbce5f5 libQt6Core.so.6`QThreadPrivate::start(this=0x000000086944bf68)::$_0::operator()() const at qthread_unix.cpp:321:14
    frame #12: 0x000000082fbcd05d libQt6Core.so.6`void (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(t=0x000000086944bf68)::$_0>(QThreadPrivate::start(void*)::$_0&&) at qthread_unix.cpp:257:9
    frame #13: 0x000000082fbccfbd libQt6Core.so.6`QThreadPrivate::start(arg=0x0000186924a11520) at qthread_unix.cpp:280:5
    frame #14: 0x000000082c297a7a libthr.so.3`thread_start(curthread=0x0000186924a13500) at thr_create.c:292:16
(lldb) f 6
frame #6: 0x0000000000b2dcce pcsx2-qt`makeMemoryManager(name="Code Memory Manager", file_mapping_name=0x0000000000000000, size=319815680, offset_from_base=335544320) at System.cpp:181:3
   178          // If it's i386 anything can reach anything so it doesn't matter
   179          if (sizeof(void*) == 8)
   180          {
-> 181                  pxAssertRel(0, "Failed to find a good place for the memory allocation, recompilers may fail");
   182          }
   183          return std::make_shared<VirtualMemoryManager>(name, file_mapping_name, 0, size);
   184  }
Comment 1 Jan Beich freebsd_committer freebsd_triage 2023-09-05 02:12:52 UTC
Created attachment 244647 [details]
v1 (apply via "git am")

Oops, forgot to test build:

elfctl -i -e +wxneeded /wrkdirs/usr/ports/emulators/pcsx2/work/.build/pcsx2
elfctl: error opening file /wrkdirs/usr/ports/emulators/pcsx2/work/.build/pcsx2: Is a directory
*** Error code 1
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-09-05 10:19:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a407c7abf1d805f5f926ad30fe94e71a12dde245

commit a407c7abf1d805f5f926ad30fe94e71a12dde245
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2023-09-05 10:16:47 +0000
Commit:     Ganael LAPLANCHE <martymac@FreeBSD.org>
CommitDate: 2023-09-05 10:16:47 +0000

    emulators/pcsx2: Unbreak with kern.elf64.allow_wx=0

    PR:     273573
    Reported by:    jbeich

 emulators/pcsx2/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Comment 3 Ganael LAPLANCHE freebsd_committer freebsd_triage 2023-09-05 10:19:44 UTC
Committed, thanks Jan!