PCemOnMac / PCemV17macOS

Port of the PCem PC emulator for macOS. Comes with OpenGL 3.0 support built-in
GNU General Public License v3.0
68 stars 14 forks source link

Segmentation Fault 11 on macOS Big Sur (Intel) #24

Open brunocastello opened 3 years ago

brunocastello commented 3 years ago

I downloaded the last release from here and unfortunately the app does not open, I have placed the roms in the right place, however, the app refuses to open, no warning, no alert, no mention of the reason why. The icon comes on dock and leaves.

macOS Big Sur 11.4, retina Macbook Pro 13" 2013.

almeath commented 3 years ago

A while back, I forked v17 while it was still running well on Mojave and Big Sur on my Intel machines. I was concerned that any subsequent changes (either to the code, or from Apple's side) might break it. Can you let me know if this version will run for you? It does not include any changes since 1 March that were made in an attempt to get it running on Apple Silicon. It only includes the bare minimum changes that were needed to get it working on Big Sur (Intel).

https://github.com/almeath/PCemV17macOS

brunocastello commented 3 years ago

I'm gonna try it now. Gimme a few minutes...

brunocastello commented 3 years ago

Nope, it doesn't run. Same error.

almeath commented 3 years ago

Both versions were working for you previously though? Can you pinpoint a time it suddenly failed, i.e after an Apple software update perhaps?

brunocastello commented 3 years ago

I can say that I havent tried PCem since last time we talked about. Then I went through two minor maCOS Big Sur updates, 11.3 and 11.4. This weekend and today I tried to run, it didn't work, then I decided to compile all versions available (kyro's v16, v17, yours v17, and sarah's updated v17) and all them are giving me a segfault 11.

almeath commented 3 years ago

Ok, that helps. It still works fine in Mojave on my iMac. I will need to do some tests in Big Sur 11.4 on my MacBook.

brunocastello commented 3 years ago

@almeath I decided to investigate even further and re-read the old thread: https://github.com/PCemOnMac/PCemV14MacOSX/issues/7

I got these files again: Your PCemV16 and wxmac 3.0.5.1 from February 16 https://github.com/PCemOnMac/PCemV14MacOSX/issues/7#issuecomment-779586970

And your PCemV17 from February 16 https://github.com/PCemOnMac/PCemV14MacOSX/issues/7#issuecomment-779611620

I've installed your precompiled wxmac there and dang v16 did boot a machine! But v17 got stuck trying to boot.

I'll try again later after a good nap to compile the v17 from source and also recompile wxmac with the newest version, because I really want to use the dark mode. I have also found the wxmac.rb script in our old thread for that attempt.

So it's quite possible that the culprit was how I or brew compiled and installed wxmac. I had completely forgotten that thread and our findings when I attempted it a few days ago. Well, nap time. Plus, it's my birthday =)

almeath commented 3 years ago

Good to hear that you are making progress, and happy birthday :)

Yes, it does sound like a compilation issue could be the culprit, so let me know how you go with re-compiling for v17.

brunocastello commented 3 years ago

Here we go:

@almeath 's v16 precompiled + wxmac precompiled = success almeath's v17 precompiled + wxmac precompiled = fail

me compiling almeath's v16 and v17's with new wxmac = fail me compiling kyr0's v16 and 17 with both new and old wxmac = fail me compiling sarah's v17 with both wxmacs = fail

Clearly I am missing some dependency to build wxmac correctly. I can load PCem and such, but cannot boot a machine. I can boot oldest ones like the amstrad 8088, but not from 386 onwards. I am even following the instructions from the old thread, but cannot seem to be able to build both wxmac and PCem correctly on my end. Hmmm...

Meanwhile your v16 and wxmac 3.0.5.1 still works fine. However v16 is limited to Pentium MMX, there is no Pentium II support. Bummer... I saved a backup of this working build just in case. Maybe I will try again v17 when I get a M1 Mac next year and with a clean slate environment to develop, I can try again to build.

brunocastello commented 3 years ago

@almeath could this be a part of the problem? Since it runs well on anything before Big Sur. https://github.com/libsdl-org/SDL-1.2/commit/89fc1b1c8a65d2f642bb05be9cdac2636c82ff5f

brunocastello commented 3 years ago

@almeath I think I've found the problem when trying to compile PCem v17 from this repo and Sarah's repo.

Both gave me the same error related to the macOS SDK, something about an include from macOS SDK and "isxdigit". Not sure what is this all about. But I am on macOS Big Sur 11.4, and Xcode 12.5.1. Apparently it can compile against an older SDK, but I do not know how to change nor if this is possible.

Xcode 13 and macOS Monterey are on the horizon this year to be released around september.

brunocastello commented 3 years ago

Screen Shot 2021-07-24 at 5 21 54 PM

almeath commented 3 years ago

I just tried a fresh compile in Big Sur 11.4 using the instructions on my Github page, and it results in the same issues you have experienced. I can get older BIOS to work, up to the American Megatrends WinBIOS. Anything later is tending to segfault and crash PCem. Clearly, something Apple updated or changed in 11.4 has broken an otherwise functioning v17 build, but only in relation to something the more demanding systems need to function.

When I tried my custom app bundle, already working perfectly in Mojave, I get an error about "libwx_osx_cocoau_xrc-3.0.0.0.5.0.dylib" not being identified, so Apple considers it "malware" and wont let my app run (typical Apple BS, stopping me from using an app I put together myself). This is basically why I am still on Mojave and do not plan to upgrade my iMac from this point forward. It just does not pay to be on Apple's cutting edge.

almeath commented 3 years ago

All I can say at this stage, is I have a functioning self-contained app bundle for PCem v17 running on Big Sur 11.4, and I used dylibbundler to make sure it finds all of its dependencies inside the app bundle. There are no errors when it launches, but I cannot get past the segfaults when more advanced BIOS configurations are selected.

almeath commented 3 years ago

While I can deal with compilation errors and getting working builds, I have no deep coding experience to extensively trouble shoot things that lead to crashes and segfaults. We may have to approach the group that is taking over PCem and see if they have any Mac users who can take a deeper look at this with us.

dob205 commented 3 years ago

So I decided to mess around with the configure.ac in the latest snapshot of the PCem repository and the culprit at the moment is the -O3 optimization flag inside it. Switching to -O1 made it possible to run it, but it makes the Pentium 75 which ran previously at 100% with my MacBook Pro Retina Late 2013 with a built in Intel Core i5-4258U running slower, but it runs just fine on macOS 11.5 and Xcode 12.5.1 (see: screenshot). In theory you could search for the problems inside the code caused by clang in the newest Xcode version. Edit: the --enable-debug flag works too, but it runs even slower then. Edit 2: specified the used Xcode version image

tomnic79 commented 1 year ago

I solved in Ventura modifying the two makefile files, one in src subfolder the other in the root of the project, replace it after the normal config command changing these lines:

CFLAGS = -O3 -fcommon -fno-inline-functions -mtune=native

CPPFLAGS =

CXX = g++

CXXDEPMODE = depmode=gcc3

CXXFLAGS = -O3 -fcommon -fno-inline-functions -mtune=native