Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfaults on 64-bit windows #164

Open
digama0 opened this issue Sep 28, 2023 · 1 comment
Open

segfaults on 64-bit windows #164

digama0 opened this issue Sep 28, 2023 · 1 comment

Comments

@digama0
Copy link
Member

digama0 commented Sep 28, 2023

I don't have a windows machine, but the cross compile for 64-bit windows on my machine looks like this:

$ cd build
$ make clean
$ make CC=x86_64-w64-mingw32-gcc
$ wine src/metamath.exe
0024:err:file:init_redirects /home/mario/.wine/dosdevices/c:/windows: No such file or directory
002c:err:wineboot:main Cannot set the dir to L"C:\\windows" (2)
002c:err:wineboot:process_run_key Error running cmd L"C:\\windows\\system32\\winemenubuilder.exe -a -r" (2).
wine: could not open working directory L"unix\\home\\mario\\Documents\\metamath\\metamath-exe\\build\\", starting in the Windows directory.
002c:err:shell:SHGetFolderPathAndSubDirW Failed to create directory L"C:\\users\\mario\\Application Data".
002c:err:shell:SHGetFolderPathAndSubDirW Failed to create directory L"C:\\users\\mario".
002c:err:shell:SHGetFolderPathAndSubDirW Failed to create directory L"C:\\users\\mario\\Local Settings\\Application Data".
wine: could not open working directory L"unix\\home\\mario\\Documents\\metamath\\metamath-exe\\build\\", starting in the Windows directory.
*** BUG #1501
Metamath - Version 0.199.pre 29-Jan-2022      wine: Unhandled page fault on read access to 0000000000000000 at address 00000001C8DFD2B0 (thread 0040), starting debugger...
0040:err:seh:start_debugger Couldn't start debugger L"winedbg --auto 60 60" (2)
Read the Wine Developers Guide on how to set up winedbg or another debugger

Most of the wine errors are harmless, but metamath immediately gives BUG #1501 and then dereferences null shortly afterward. The 32-bit windows build works properly.

I believe the reason is because metamath-exe uses long as an equivalent to size_t, ptrdiff_t and the like, but in 64-bit windows long is 4 bytes while pointers and allocation sizes are 8 bytes, so there is a lot of invalid casting going around.

@creator1creeper1
Copy link

creator1creeper1 commented Oct 28, 2023

Thank you for noting this issue. Compiling with clang m*.c -o ../bin/metamath.exe -O3 -funroll-loops -finline-functions -fomit-frame-pointer -m32 (note the -m32) works on my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants