-
Notifications
You must be signed in to change notification settings - Fork 36
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
Runtime errors on PPC (big endian) #165
Comments
- Don't implicitly convert intptr_t difference to int8_t but perform explicit comparisons - Don't implicitly convert strcmp() int result to int8_t Fixes: #165 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Reportedly, automatic conversion of the `isatty()` int result value to a bool does not work correctly on PPC. Explicitly compare the result value with `1` to infer the boolean result value. Fixes: #165 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Reportedly, automatic conversion of the `isatty()` int result value to a bool does not work correctly on PPC. Explicitly compare the result value with `1` to infer the boolean result value. Fixes: #165 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Thank you for your report and the analysis of the problems. Frankly I don't understand the |
Thanks for the quick reaction and for adjusting the patches. I was able to compile and run it out on PPC without any problems. (pulled Merge: 4bee0ef 093684d) 25_ltrim ................................ OK
26_rtrim ................................ OK
27_sprintf .............................. OK
28_printf ............................... OK
29_require .............................. !
Testcase #4: Expected stderr did not match:
--- Expected stderr
+++ Resulting stderr
@@ -1,7 +1,7 @@
Runtime error: Unable to compile source file './files/require/test/broken.uc':
| Syntax error: Expecting label
- | In line 3, byte 1:
+ | In line 2, byte 10:
|
| `return {`
| ^-- Near here
---
29_require .............................. FAILED (1/4)
30_iptoarr .............................. OK
...OK
34_json ................................. OK
35_include .............................. !
Testcase #6: Expected stderr did not match:
--- Expected stderr
+++ Resulting stderr
@@ -1,7 +1,7 @@
Runtime error: Unable to compile source file './files/broken.uc':
| Syntax error: Expecting label
- | In line 4, byte 1:
+ | In line 3, byte 11:
|
| ` return {`
| Near here --^
---
35_include .............................. FAILED (1/7)
36_render ............................... !
Testcase #6: Expected stderr did not match:
--- Expected stderr
+++ Resulting stderr
@@ -1,7 +1,7 @@
Runtime error: Unable to compile source file './files/broken.uc':
| Syntax error: Expecting label
- | In line 4, byte 1:
+ | In line 3, byte 11:
|
| ` return {`
| Near here --^
---
36_render ............................... FAILED (1/6)
...OK
62_loadfile ............................. !
Testcase #7: Expected stderr did not match:
--- Expected stderr
+++ Resulting stderr
@@ -1,7 +1,7 @@
Runtime error: Unable to compile source file './files/test6.uc':
| Syntax error: Expecting expression
- | In line 2, byte 1:
+ | In line 1, byte 5:
|
| `1 +`
| ^-- Near here
---
62_loadfile ............................. FAILED (1/7)
...OK
13_split_by_string_leading_trailing ..... OK
14_incomplete_expression_at_eof ......... !
Testcase #1: Expected stderr did not match:
--- Expected stderr
+++ Resulting stderr
@@ -1,5 +1,5 @@
Syntax error: Expecting expression
-In line 2, byte 1:
+In line 1, byte 7:
`{% 1+`
^-- Near here
---
14_incomplete_expression_at_eof ......... FAILED (1/1)
...OK
24_compiler_local_for_loop_declaration .. OK
25_lexer_shifted_offsets ................ !
Testcase #1: Expected stderr did not match:
--- Expected stderr
+++ Resulting stderr
@@ -1,5 +1,5 @@
Error
-In line 3, byte 13:
+In line 3, byte 12:
` die("Error");`
Near here -----^
---
25_lexer_shifted_offsets ................ FAILED (1/1)
...
Ran 167 tests, 161 okay, 6 failures
However, a run with the old custom test cases from (PKG_SOURCE_VERSION:=c7d84aae09691a99ae3db427c0b2463732ef84f4) is error-free. I therefore assume that the PPC specific patches work well (also the (isatty(fd) == 1). Maybe the custom test suite should possibly be adjusted. |
This is happening on PPC?
FYI that custom test suite passes on x86/64 https://github.com/jow-/ucode/actions/runs/5656546401/job/15324077119#step:3:1805 |
Yes, that's true on my x86/64, that was my first test, no errors occur. |
In my tests yesterday I accidentally had an old version of libucode.so. As a result, the function 'update_line()' from lexer.c was not up to date, which led to the line counting error. With the newly compiled version, 167 tests are now also okay on the PPC. Thank you for the effort. |
I adapt the OpenWrt firmware for our railway access points. The access point hardware is based on PowerPC CPUs of the type QorIQ T1023(32Bit) and T2081(64Bit). For the next OpenWrt merge to version v22.03.05 the ucode package for the firewall (fw4) had to work.
In the first attempts on x86 and an ARM platform, the 167 tests of the ucode Test-Suite ran error-free.
But the ucode output generated on the PPC target was faulty, causing the FW4 not to start correctly.
Unfortunately, I couldn't run the test suite on the PPC platform at first, because it only provides busybox-shell and busybox-utils and not the full versions of bash / diff / truncate that are required.
That's why I first adapted the test suite script 'run_tests.sh'. My 'OpenWrt' version 'run_tests_openwrt.sh' now uses readlink-coreutils, truncate-coreutils and diff-gnu and can run in the busybox shell. However, many of the 167 tests were incorrect.
I was able to localize the error on the function 'ucv_compare' from the source file types.c.
Here the (int) return value of the strcmp () function is converted into a character (int8_t). On an x86/arm this always seems to work fine. However, on a PPC platform (big endian), the conversion leads to unpredictable results.
I patched the spot like this:
With this patch, at least 157 out of 167 tests in the test suite were error-free.
I then found a similar error in 'lib/fs.c'. Here the (int) return value of isatty() is directly converted into a 'ucv_boolean_new(isatty(fd))'. This also does not work correctly on the PPC. The following patch:
With this patch, all 167 tests in the Test-Suite were error-free.
I added another patch in types.c that didn't trigger a Test-Suite error. The difference of an INT pointer subtraction can definitely be larger than: int8_t delta;
The patches could also be interesting for other architectures, but at least for OpenWrt ./target/linux/mpc85xx'.
If desired I can provide my test script: test/custom/run_tests_openwrt.sh.
Here is the version for which we use the patches.
The text was updated successfully, but these errors were encountered: