ccurl
ccurl copied to clipboard
Does not compile correctly on ARM
Does not compile correctly on ARM due to a difference in CHAR implementation between x86 and ARM. x86 implementation treat CHAR as SIGNED CHAR, whereas ARM treats CHAR as UNSIGNED CHAR. Note that there isn't a standard for C how CHARs are signed or unsigned.
This difference in C spec results in unexpected results on ARM. The code multiplies by Trite which on x86 is [-1, 0 or 1] and on ARM [255, 0 or 1] which results in copying data from incorrect memory locations.
To make the code portable it is essential that all Trits are defined as SIGNED CHAR. Secondly Trytes on the other hand should be UNSIGNED CHARS "ABCDEF..XYZ9". There is no math done with Trytes so this is no as big of an issue as Trits.
I have a fix for this, and will create a pull request later. This issue was first encountered in the Proof of Work C code in the Go library (GIOTA) and may reside in other code in the IOTA ecosphere.
I've been running into this as well trying to compile and use libccurl on an ARMv6 Raspberry Pi 1 Model B (512MB RAM). It compiles fine, with a few warnings, but throws a segfault upon attempting to use the library for PoW. Looking forward to your pull request.
The compatibility change for ARM has been submitted as PR #40. The changes simply define the Trits CHAR to SIGNED CHAR. This is a change that makes the code portable and is valid on all processor architectures.
The code has been tested on both the x86/AMD64 architecture and on the ARM64v8 architecture.