poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

poke.mi-json/mi-json test uses installed shared libraries


From: Bruno Haible
Subject: poke.mi-json/mi-json test uses installed shared libraries
Date: Fri, 19 Feb 2021 19:47:27 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-201-generic; KDE/5.18.0; x86_64; ; )

On a system where I had an older version of poke installed, I configured and
built poke-0.90 with the same --prefix option, and ran "make check":

Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for 
target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using /build/poke-0.90/testsuite/config/unix.exp as tool-and-target-specific 
interface file.
Running /build/poke-0.90/testsuite/poke.cmd/cmd.exp ...
Running /build/poke-0.90/testsuite/poke.libpoke/libpoke.exp ...
Running /build/poke-0.90/testsuite/poke.map/map.exp ...
Running /build/poke-0.90/testsuite/poke.mi-json/mi-json.exp ...
FAIL: poke.mi-json/mi-json killed: 17988 exp6 0 0 CHILDKILLED SIGSEGV 
{segmentation violation}
Running /build/poke-0.90/testsuite/poke.pickles/pickles.exp ...
...

Then ran "make install", and "make check" again. And poke.mi-json/mi-json
no longer fails.

The cause is that running 'mi-json' ends up using the installed shared
libraries. (I see this by adding a 'sleep (60);' statement to mi-json.c,
and then while doing "make check" looking at /proc/<pid>/maps.)

The problem comes from the way this program is created:

$ make mi-json
/bin/bash ../../libtool  --tag=CC   --mode=link gcc -ftrapv 
-I/usr/include/json-c -g -O2  -L/inst-x86_64-64/lib -o mi-json 
mi_json-mi-json.o ../../poke/mi_json-pk-mi-msg.o 
../../poke/mi_json-pk-mi-json.o -ljson-c ../../gl/libgnu.la 
../../libpoke/libpoke.la 
libtool: link: gcc -ftrapv -I/usr/include/json-c -g -O2 -o .libs/mi-json 
mi_json-mi-json.o ../../poke/mi_json-pk-mi-msg.o 
../../poke/mi_json-pk-mi-json.o  -L/inst-x86_64-64/lib -ljson-c 
../../gl/.libs/libgnu.a -lreadline /inst-x86_64-64/lib/libtextstyle.so -lm 
-lncurses ../../libpoke/.libs/libpoke.so -pthread -Wl,-rpath 
-Wl,/inst-x86_64-64/lib

The option '-Wl,-rpath -Wl,/inst-x86_64-64/lib' is necessary for referencing
the installed libgc and libtextstyle. But a reference to the libpoke installed
in the same directory should be avoided.

How to achieve this? Setting LD_LIBRARY_PATH or LD_RUN_PATH does not help.
I tried various options to the libtool invocation that creates 'mi-json'.
I tried a different libpoke_uninstalled.la instead of libpoke.la. Does not
help either: libtool reorders the -Wl,-rpath options.

One possible way to mitigate such a crash would be to
  1) add an exported macro LIBPOKE_VERSION to libpoke.h,
  2) add an exported variable libpoke_version to the libpoke library,
     whose value is LIBPOKE_VERSION,
  3) add to mi-json.c code like

     if (libpoke_version != LIBPOKE_VERSION)
       {
         fprintf (stderr, "Skipping: You need to run 'make install' before 
running this test.\n");
         exit (77);
       }

  4) Make sure that LIBPOKE_VERSION gets incremented frequently enough.

What do you think?

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]