-
Notifications
You must be signed in to change notification settings - Fork 143
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
Boolean bitfields writes treated as 32/64-bit rather than 8-bit; broken on big-endian #292
Comments
Has there been any progress on this issue? Is this related to the issue reading files with little endian BOM? |
I haven't looked further into this. I wasn't planning to attempt a fix myself. It's completely unrelated to the BOM and file I/O bugs. I've just dusted off that branch and did a little on it. I could submit it as a draft PR. |
That would be great. Looking forward to it. |
Is it possible to get access to the code fix for the BOM and file I/O bugs? FBC is having BOM issues when building VisualFBEditor on big endian. |
OK, I've picked it up again. Sorry for forgetting about it. |
Any further progress on this? |
Sorry... I forgot that you'd previously asked about the big endian file BOM bugs in this issue; that's what you're asking about rather than this bitfield bug? I did indeed resume work on that branch for a while (I just pushed some more to https://github.com/rversteegen/fbc/commits/ppc) but looking at it I see I mostly got really sidetracked with tests and fixes for obscure putback buffer bugs. There are some BOM fixes but apparently not including OPEN ENCODING nor fbc's BOM detection, which are likely the two fixes you most need. But those shouldn't be too hard to fix. I'm a bit busy at the moment though. |
Thanks for all your work. I understood that you were probably busy, just wanted to see if you’d done any more on the big endian BOM issues. I’ll checkout your ppc branch. At any rate I’ve installed fbsd 13.2 for little endian and may move everything to that platform. Again, thanks in advance for your help. |
…bit rather than 8-bit - preserve the 8-bit boolean bitfield container size when shifting / masking bits
… 32/64-bit rather than 8-bit - preserve the 8-bit boolean bitfield container size when shifting / masking bits - in gas64 don't assume that boolean can be initialized from byte without normalizing i.e. don't allow same-size copy from 8-bit since
Maybe not the best code generation, but looks like we should be limiting memory reads and writes to one byte only. 32-bit gas, x86:
64-bit gas, x86_64:
32-bit gcc, x86:
64-bit gcc, x86_64
(FYI, the |
The first priority was to at least get some changes added so that memory was not overwritten and try to add a few tests for it. Then follow up to explore the code generation. But at: fbc/src/compiler/ast-node-misc.bas Line 428 in fef1dfa
I believe I had intended: Because, with usage in source linked above, overloaded |
When fbc writes to a boolean bitfield it treats the bitfield address as an integer ptr (32 or 64 bit). So it reads 3/7 bytes past the bitfield and then writes them back as they were. Reading from the bitfield doesn't seem to be affected.
This is usually invisible and I don't think there's any unittest that can test for this bug on a little-endian platform, but it breaks big-endian platforms because the bitmask used is wrong. This bug was discovered by running on PowerPC (discussion in #290).
Testcase:
32-bit -gen gcc x86 result:
64-bit -gen gcc is the same except it treats the address as a uint64* and uses the bitmask 0xfffffffffffffffe instead.
-gen gas output:
The text was updated successfully, but these errors were encountered: