[Debian-astro-maintainers] Bug#934081: esorex: testsuite failures on riscv64 due to wrong usage of ffi_prep_cif

Aurelien Jarno aurel32 at debian.org
Tue Aug 6 21:22:54 BST 2019


Package: esorex
Version: 3.13.2+dfsg-1
Severity: normal
Tags: upstream patch
User: debian-riscv at lists.debian.org
Usertags: riscv64

esorex fail to build from source on riscv64 due to two failures in the
testsuite:

| PASS: esorex_json_parse_errors1-test
| ../../admin/test-driver: line 107:  2130 Aborted                 "$@" > $log_file 2>&1
| FAIL: esorex_json-test
| PASS: esorex_json_parser-test
| PASS: esorex_json_parse_errors2-test
| PASS: esorex_json_parse_errors3-test
| ../../admin/test-driver: line 107:  2133 Aborted                 "$@" > $log_file 2>&1
| FAIL: esorex_json_internal-test
| PASS: esorex_json_parse_errors4-test
| PASS: esorex_python_errors1-test
| PASS: esorex_python_errors2-test
| PASS: esorex_python_errors4-test
| SKIP: esorex_python_recipe-test
| PASS: esorex_python-test
| PASS: esorex_python_errors3-test
| PASS: esorex_python_internal-test

A full build log is available there:
https://buildd.debian.org/status/fetch.php?pkg=esorex&arch=riscv64&ver=3.13.2%2Bdfsg-1&stamp=1564942941&raw=0

After some debugging I have found that libffi is called incorrectly in
src/er_json.c. The ffi_prep_cif() function is used to prepare a call to
cpl_parameter_new_enum(), however this function is a variadic function.
In that case depending on the architecture, the arguments, and their
order the ABI might be slightly different. That's why ffi_prep_cif_var
must be used instead for variadic functions. See the libffi manual for
more details:

http://www.chiark.greenend.org.uk/doc/libffi-dev/html/The-Basics.html

ffi_prep_cif_var() takes the number of fixed arguments, 4 in the case of
cpl_parameter_new_enum(), and the total number of arguments just like
ffi_prep_cif().

Therefore here is a small patch fixing the issue:

--- esorex-3.13.2+dfsg.orig/src/er_json.c
+++ esorex-3.13.2+dfsg/src/er_json.c
@@ -3714,8 +3714,8 @@ static cpl_parameter * json_to_parameter
                            || type == CPL_TYPE_STRING);
                     break;
             }
-            if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, nargs, &ffi_type_pointer,
-                             argtypes)
+            if (ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 4, nargs,
+                                 &ffi_type_pointer, argtypes)
                 == FFI_OK)
             {
                 ffi_call(&cif, (void (*)(void))&cpl_parameter_new_enum, &param,

With it the testsuite fully passes on riscv64, and I also see no
regression on amd64.

Regards,
Aurelien


More information about the Debian-astro-maintainers mailing list