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

Alignment exception on ARM in libvncclient zrle #422

Closed
ghost opened this issue Jun 3, 2020 · 3 comments
Closed

Alignment exception on ARM in libvncclient zrle #422

ghost opened this issue Jun 3, 2020 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Jun 3, 2020

Similar to issue #199 - Alignment exception on ARM in rfbWriteExact()

This code in zrle.c in libvncclient:

#if REALBPP!=BPP && defined(UNCOMP) && UNCOMP!=0
#if UNCOMP>0
#define UncompressCPixel(pointer) ((*(CARDBPP*)pointer)>>UNCOMP)
#else
#define UncompressCPixel(pointer) ((*(CARDBPP*)pointer)<<(-(UNCOMP)))
#endif
#else
#define UncompressCPixel(pointer) (*(CARDBPP*)pointer)
#endif

casts byte pointers to larger types without taking into consideration that some CPUs throw a bus error if the address is odd.

In my case, I'm only ever using 16bit colours (unsigned short) so I simply replaced the last define above with the following to fix the issue (for me):

#if BPP !=16
#define UncompressCPixel(pointer) (*(CARDBPP*)pointer)
#else
#define UncompressCPixel(pointer) ((pointer [1] << 8) | (pointer [0]))
#endif

If I ever move to 32 bit colours, I might fix it there too - but the device I've compiled my project for is 10 years old and will never use a different screen to what it has now. (iMX31 - in LE mode)

@ghost ghost added the bug label Jun 3, 2020
@bk138
Copy link
Member

bk138 commented Jun 3, 2020

Is this with 0.9.12 or current master? 53073c8 changed somehting w.r.t. alignment.

@ghost
Copy link
Author

ghost commented Jun 4, 2020

Hi, it was a snapshot of the current master from about 4 weeks ago. Time flies, it took me almost that long to get it working on my old hardware. But work it does - it's very cool, thanks.

The commit mentioned above only addresses the issue in the VNCServer source which I'm not using, that file isn't in my project which is a VNCClient. It may well be the case that fixing it on the server side solves the problem on the client side, except I'm not connecting to a LibVNCServer server, I think it's RealVNC server that I've got (whatever comes as default/recommended for a Raspberry Pi).

Incidentally, I'm using the Arduino IDE (with a custom board profile for my device) to build my project. Arduino will compile the .ino and all .c / .cpp files in the project directory... Of course some of the .c files here are "do not compile" ones - so I renamed them as .h (well, except zlib.c which I named zlibc.h). I don't think I did much more (other than change some config settings for stuff I'm missing on my platform) so it might be worth thinking about making the filename change here... It would certainly remove any ambiguity and you can take out the warnings in the source to not compile? :)

@bk138
Copy link
Member

bk138 commented Dec 2, 2022

As no one else was reporting this bug and the OP has turned into a 👻, I'll tentatively close this. Maybe 8f6b47d fixed it (altough it does not deal with alignment exceptions...)

@bk138 bk138 closed this as completed Dec 2, 2022
@bk138 bk138 added this to the Release 0.9.14 milestone Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant