intel / hyperscan

High-performance regular expression matching library
https://www.hyperscan.io
Other
4.82k stars 719 forks source link

hyperscan library cause load shared libraries error #67

Open leeyiw opened 7 years ago

leeyiw commented 7 years ago

When I compile my project with hyperscan 4.5.1, there is no error. But when I try to execute the binary, there is a critical error, same critical error when I compile samples/simplegrep.c:

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#gcc -I/home/deps/dest/usr/local/include/hs  simplegrep.c /home/deps/dest/usr/local/lib64/libhs.a /usr/local/gcc-4.9.2/lib64/libstdc++.a -lm

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#./a.out
./a.out: error while loading shared libraries: unexpected PLT reloc type 0x25

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#ldd a.out
        not a dynamic executable

Here is my environment:

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#gcc --version
gcc (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#ld --version
GNU ld (GNU Binutils) 2.28
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#rpm -qf /lib64/libc.so.6
glibc-2.5-81.2

I think the problem is hyperscan use some relocation type that old glibc doesn't support. When I remove the static link to hyperscan from my project, the binary works well. So I'm pretty sure the problem is from hyperscan.

jviiret commented 7 years ago

I think this is most likely due to the way you're trying to statically link libstdc++ -- are you able to build your binary with:

# gcc -I/home/deps/dest/usr/local/include/hs  simplegrep.c \
    /home/deps/dest/usr/local/lib64/libhs.a -lstdc++ -lm

Are you building libhs.a on the same machine with the same toolchain?

leeyiw commented 7 years ago

@jviiret Thanks for quick reply. With -lstdc++, still error:

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#gcc -I/home/deps/dest/usr/local/include/hs  simplegrep.c /home/deps/dest/usr/local/lib64/libhs.a -lstdc++ -lm

[root@05c8ec243f3d /home/yiwei.liyw/test/hyperscan-4.5.2/examples]
#./a.out
./a.out: error while loading shared libraries: unexpected PLT reloc type 0x25

Are you building libhs.a on the same machine with the same toolchain?

Yes! I'm using exactly the same gcc/binutils/glibc to compile simplegrep.c.

leeyiw commented 7 years ago

@jviiret Oh, I have compiled libhs.a with FAT_RUNTIME=OFF, and the problem is gone. So maybe it's an issue about fat runtime. Is there anyone who can look into it?

leeyiw commented 7 years ago

@mdb256 Would you please look at this issue for a moment? Thank you very much.

mdb256 commented 7 years ago

The unexpected PLT reloc type 0x25 error that you got indicates that the ld-linux on that system does not support the R_X86_64_IRELATIVE relocation type which is required for the indirect functions (ifunc) that the fat runtime uses.

Glibc 2.5 is from 2006, and is far too old to support the use of the fat runtime.

leeyiw commented 7 years ago

@mdb256 Thanks for the quick reply. I will evaluate if our program could work without fat runtime support and make some necessary changes.

leeyiw commented 7 years ago

I think if the CMakeLists.txt of hyperscan could do some GLibc version check. It will prevent this issue happens, since too old GLibc shouldn't open FAT_RUNTIME option.