Created attachment 1585494 [details] Reproducer of bug in guile Description of problem: If float_to_foreign_endianness function, from file libguile/bytevectors.c, is compiled with optimalization, then it breaks guiles scm_bytevector_ieee_single_set! function if used with big endianess argument. Version-Release number of selected component (if applicable): guile-2.0.14-7.el8.ppc64le gcc-8.3.1-4.4.el8.ppc64le How reproducible: Always Steps to Reproduce: 1. # dnf install guile Note: this guile is compiled with standard -O2 optimilization from '%configure' rpm macro 2. $ guile ./reproducer Actual results: #vu8(0 0 0 0 0 0 0 0) Expected results: #vu8(64 72 245 195 0 0 0 0) Additional info: When i build guile with patch which i will add to attachments the function started working as expected. For disabling optimilization i used '#pragma GCC optimize("O0")'. This problem occurs only on ppc64le architecture.
Created attachment 1585498 [details] patch with workaround This patch forces gcc to not optimalize float_to_foreign_endianness function.
Created attachment 1585617 [details] Rpm of patched guile I'm adding rpm of patched guile just to prove that workaround is working. Feel free to reach me if you will need anything else.
Have you tried -fsanitize=undefined and/or -fsanitize=address?
Hi Marek, After your suggestion i tried and it found some leaks. Although i do not think they are related to this issue, i was little surprised when i ran guile through valgrind and the problem disappeared. So i will further investigate those leaks and then tell you my conclusions.
So after further investigation of leaks i can say that they are not related to this problem. I recorded assembly instructions around code which were executed by non-optimalized and optimalized code. I do not really know anything about assembly so i hope it will be of more use to you than to me.
Created attachment 1589046 [details] Instructions executed by code with bug I scripted gdb to log assembly instructions and this is the output of code which causes bug.
Created attachment 1589047 [details] Instructions executed by code without bug These are instructions executed by non-optimalized code.
Tomas, trying to reproduce this, I see: # rpm -q gcc guile gcc-8.3.1-4.4.el8.ppc64le guile-2.0.14-7.el8.ppc64le # guile ./reproducer ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /root/./reproducer ;;; compiled /root/.cache/guile/ccache/2.0-LE-8-2.0/root/reproducer.go #vu8(64 72 245 195 0 0 0 0) Which is the expected result. What's up with that?
Hi Marek, I suppose you used bare metal machine. I did that now as well and the bug does not occur there. I'm sorry that i did not try it before. It seems that this issue is caused by virtualization. Thanks for your help anyway.