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

File parsing can crash on non-x86 platforms #285

Closed
bkoropoff opened this issue Mar 26, 2023 · 3 comments
Closed

File parsing can crash on non-x86 platforms #285

bkoropoff opened this issue Mar 26, 2023 · 3 comments

Comments

@bkoropoff
Copy link
Contributor

A lot of the file parsing code uses casts from char*/byte* to structs, short, int, etc. This generates a lot clang warnings about pointer alignment.

In a lot of cases this is harmless, as the buffer pointer is guaranteed to be aligned due to program logic. In others it's not, e.g.

  lump_info = (const filelump_t*)(buffer + header->infotableofs);

If the wad header has an infotableofs that is not 4-byte aligned for whatever reason, accessing lump_info->filepos will crash on platforms like ARM where unaligned memory access is not allowed.

There are attributes/pragmas that can be used to mark structures as 'packed' so that the compiler generates the necessary code to access unaligned memory safely on platforms that require it.

On the other hand, maybe running dsda-doom on anything but x86 doesn't matter.

@kraflab
Copy link
Owner

kraflab commented Mar 26, 2023

To be honest I would rather leave this alone until we reach a time where it must be done.

@kraflab kraflab closed this as completed Apr 8, 2023
@bkoropoff
Copy link
Contributor Author

This isn't really fixed, the warning is just turned off 😆

@kraflab
Copy link
Owner

kraflab commented Apr 8, 2023

I'd like everything in the issues tab to be actionable and intended to be addressed, so in this case I decided to close it, although the problem does still exist as you said :^)

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

No branches or pull requests

2 participants