-
Notifications
You must be signed in to change notification settings - Fork 33
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
Bus error on NetBSD 9.1/sparc64 #190
Comments
You can build with:
Then run with -v:
This should provide some useful information. I'm not sure why you don't get anything useful from gdb. Are you getting a core? |
Yes, I can provide a core if you need, but first to the debug problems:
It errored out with:
So i had remove -Werror from the DEBUG_FLAGS: Now it get a bus error when the testing framework is active and cannot complete the debug build:
Any idea what to do now? |
The test doesn't complete but the binary is built, so you can try running caprice with debug logs, although I'm not sure this will help much:
Because the test fails on As the test run in random order, you may need to run it manually to run just the test that fails:
But because launching |
Attached is a cap32.log of the debug binary and a .core of that run. |
I won't be able to open the core on a non-sparc64 machine.
Which should give you the exact line where it crashes. Unfortunately, if it's unaligned memory access it's likely to occur all over the code and will be very hard to fix. |
Result of the first debug is:
|
Weird, I would expect this access to be aligned as RendPos is a dword*. Maybe it's not unaligned access in the end? Can you try the following in gdb (from the same core):
|
|
Ah indeed, RendPos is not the allocated thing, RendBuff is and it's byte[]. And we can point at word boundaries instead of dword boundaries in the half pixel case. Fixing all of them (or even some) would potentially be interesting as they can have a performance impact even on other architectures. It's likely to be a lot of work and will not go well if I have to ask you to test and report for every single one of them. So I'd need a way to debug it myself. |
|
Bad news is that it doesn't detect any issue when running the Zip test case, so it may not be a silver bullet ... |
You could set up a qemu sparc64 with NetBSD, but i am not sure if this will help, since it has no working gpu emulation at the moment, only sparc 32bit has one. |
I have set scr_style=1, but the error jumps to another section of crtc.cpp:
|
So here is what it requires to verify alignment:
If the alignment of a buffer is the only issue, it can be fixed with something like:
Unfortunately, it seems most of the issues won't be fixable (at least not easily). PSGFor example, there's one in psg.cpp that comes from RegisterAY:
Accessing Envelope as an unsigned short is, by design, unaligned. We could align it by reordering values or adding an unused char after ampc but this would mess with the register indexes, so all accesses through Index would need to be modified to map the register to a different offset. This is not unfeasible but adds requires some significant refactoring with unknown impact on performances (probably low though, registered are not used that often). CRTCMore problematic is an issue in crtc.cpp:
Adding some log around the val variable shows that it can take any value (typically 12, then 9 (causing unaligned access), then 6, 5, 3, 2, 2, 1 ...). We cannot just do a few accesses at byte level to align and then continue with dword. I can try to ensure val is always aligned and see what it gives, but it's unlikely to be fine ... |
…t could fail (if we do not reach the directory signature on the first try, we move only one byte backward) but it seems fine as far as I could test so far. #190
OK, I gave a try at it on the You can try it with the following:
If it doesn't work, you can retry the |
Preliminary result is that cap32 starts up without a bus error. When scr_style=1 i get a black screen with white fps and % readings in the upper left, if i set scr_style=8 i get a red screen with white ftp an % writings. It is very slow and didn't reach a visible CPC tartup screen. |
Ah, I didn't realize sparc64 was big endian! It's not surprising that it fails. Caprice32 assumes little endianness in many places. You can try:
I'd expect this new |
I fixed the obvious places where little endianness is assumed. I would be surprised if it's enough to work, but let me know at least if the unit tests pass. |
I have a problem compiling the new tests:
The only "filesystem" i found on my NetBSD didn't have the required declaration:
|
That's weird, this test is not new so if you managed to compile tests before, it should still work. Did you change something in your system? You can also skip this particular test by just removing the file What gcc version are you using? (what's the output of |
Before i was compiling the cacprice32 4.6.0 from the package distribution of NetBSD. test/keyboard.cpp is not present there, when it retrieves the original source file.
|
Attached is a run of the test suite without keyboard.cpp: |
Awesome, that's some good progress. I setup a build with a big endian arch on Travis and I do get the same test failure for Zip (https://travis-ci.org/github/ColinPitrat/caprice32/jobs/765533669). I don't get the one for the configuration but that's not a big deal, it's just a test that verifies that writing to a read-only file fails. Not sure why it's not the case in your case, either that the write to the read-only file succeeds (which would be very weird) or that the error is not properly surfaced by the API either. Could be NetBSD specific. I will probably not have a look at this issue in the coming days but I won't forget it. |
Probably writing to read-only file succeeds because i'm running stuff on these machines as root :) |
Oh yeah, that explains :-) |
I compiled caprice32 4.6.0 on NetBSD 9.1/sparc64.
When i try to run it i get a bus error.
Unfortunately i don't get any detailed point of error in the console or with gdb.
What can i do to produce some debug output or gdb backtrace to possibly find the cause of the error?
Regards,
Connor
The text was updated successfully, but these errors were encountered: