ext-chunkutils2 icon indicating copy to clipboard operation
ext-chunkutils2 copied to clipboard

No endian safety

Open dktapps opened this issue 7 years ago • 1 comments

The vast majority of devices and machines these days are little-endian, but this extension doesn't consider the possibility of being compiled and run on a big-endian platform. If it is run on a big-endian platform, then lots of unpleasant things could occur, like word array corruption, generated chunks having the wrong byte order, client crashes, and so on and so forth.

Initial tests (with extra hacks to stop client crashes) yield the following results: screenshot_20180430-193845 screenshot_20180430-194008

Since both disk saves and network sends are little endian, it would probably be best to have some big-endian-specific conversion code to translate little-endian packed byte arrays to/from big-endian in-memory format on the interfaces. This would produce some minor performance loss for big-endian platforms, but I think those are rare enough that nobody should really care.

dktapps avatar Apr 30 '18 19:04 dktapps

In the meantime, you should throw an error on compilation for non-little-endian platforms

ghost avatar May 17 '18 11:05 ghost