Skip to content
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

Compile fstack as a shared library "libfstack.so", it will core dump when running. Need help, pls #84

Open
jinhao2 opened this issue Sep 26, 2017 · 9 comments

Comments

@jinhao2
Copy link
Contributor

jinhao2 commented Sep 26, 2017

Compile DPDK as all shared librarys, compile fstack as static library libfstack.a, running $FF_PATH/example/helloworl goes OK.
Compile DPDK as all shared librarys, compile fstack as shared library libfstack.so, running $FF_PATH/example/helloworl goes wrong, and core file created.
#0 0x00007ffff7ab20ce in free (addr=0x0, type=0x7ffff625f6b5) at ff_glue.c:1031
1031 ff_free(addr);
Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7_3.4.4.x86_64 libgcc-4.8.5-4.el7.x86_64 openssl-libs-1.0.1e-60.el7_3.1.x86_64 zlib-1.2.7-15.el7.x86_64
(gdb) bt
#0 0x00007ffff7ab20ce in free (addr=0x0, type=0x7ffff625f6b5) at ff_glue.c:1031
#1 0x00007ffff7a87945 in ff_free (p=0x0) at ff_host_interface.c:117
#2 0x00007ffff7ab20d3 in free (addr=0x0, type=0x7ffff625f6b5) at ff_glue.c:1031
#3 0x00007ffff7a87945 in ff_free (p=0x0) at ff_host_interface.c:117
#4 0x00007ffff7ab20d3 in free (addr=0x0, type=0x7ffff625f6b5) at ff_glue.c:1031
#5 0x00007ffff7a87945 in ff_free (p=0x0) at ff_host_interface.c:117
#6 0x00007ffff7ab20d3 in free (addr=0x0, type=0x7ffff625f6b5) at ff_glue.c:1031
#7 0x00007ffff7a87945 in ff_free (p=0x0) at ff_host_interface.c:117
#8 0x00007ffff7ab20d3 in free (addr=0x0, type=0x7ffff625f6b5) at ff_glue.c:1031
#9 0x00007ffff7a87945 in ff_free (p=0x0) at ff_host_interface.c:1

And it seems go into infinit loop while loading modules before into main function.

@whl739
Copy link
Member

whl739 commented Sep 26, 2017

In static library, all symbols are made local, only the symbols that are part of the API are made externally available.
But in shared library, you probably didn't do that, so some symbols have the same name, such as free, we must find a way to avoid this, for example, use visibility=hidden for local symbols.

@jinhao2
Copy link
Contributor Author

jinhao2 commented Sep 26, 2017

OK, used "objcopy --globalize-symbols=ff_api.symlist *.o" , the libfstack.so was updated. And core 's stack is:
#0 0x00007ffff7aa86d5 in linker_addmodules (lf=0x60cca0, start=0x345558, stop=0x345660, preload=1) at /root/f-stack-master/lib/../freebsd/kern/kern_linker.c:1429
1429 mp = *mdp;
Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7_3.4.4.x86_64 libgcc-4.8.5-4.el7.x86_64 openssl-libs-1.0.1e-60.el7_3.1.x86_64 zlib-1.2.7-15.el7.x86_64
(gdb) bt
#0 0x00007ffff7aa86d5 in linker_addmodules (lf=0x60cca0, start=0x345558, stop=0x345660, preload=1) at /root/f-stack-master/lib/../freebsd/kern/kern_linker.c:1429
#1 0x00007ffff7aa899a in linker_preload (arg=0x0) at /root/f-stack-master/lib/../freebsd/kern/kern_linker.c:1501
#2 0x00007ffff7a8c460 in mi_startup () at ff_init_main.c:260
#3 0x00007ffff7a8c003 in ff_freebsd_init () at ff_freebsd_init.c:111
#4 0x00007ffff7b78fde in ff_init (argc=5, argv=0x7fffffffe238) at ff_init.c:47
#5 0x0000000000400ca1 in main (argc=5, argv=0x7fffffffe238) at main_tcps.c:106
(gdb) list
1424 struct mod_metadata *mp, **mdp;
1425 const char *modname;
1426 int ver;
1427
1428 for (mdp = start; mdp < stop; mdp++) {
1429 mp = *mdp;
1430 if (mp->md_type != MDT_VERSION)
1431 continue;
1432 modname = mp->md_cval;
1433 ver = ((const struct mod_version *)mp->md_data)->mv_version;
(gdb) p mdp
$1 = (struct mod_metadata **) 0x345558
(gdb) p *mdp
Cannot access memory at address 0x345558

@whl739
Copy link
Member

whl739 commented Sep 26, 2017

In my enviroment, i modified lib/Makefile like this:

diff --git a/lib/Makefile b/lib/Makefile
index 4f35cf0..79a8e25 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -382,7 +382,8 @@ libfstack.a: machine_includes ff_api.symlist ${MHEADERS} ${MSRCS} ${HOST_OBJS} $
        rm $*_localize_list.tmp
        objcopy --globalize-symbols=ff_api.symlist $*.ro
        rm -f $@
-       ar -cqs $@ $*.ro ${HOST_OBJS}
+       #ar -cqs $@ $*.ro ${HOST_OBJS}
+       ${CC} -shared -o libfstack.so $*.ro -fPIC ${HOST_OBJS}
        rm -f $*.ro

and execute:

export CONF_CFLAGS=-fPIC
make

This works fine.

How did you modify makefile?

@jinhao2
Copy link
Contributor Author

jinhao2 commented Sep 26, 2017

I edit mk/kern.pre.mk and lib/Makefile, add "-fPIC" in CFLAGS/KERNEL_CFLAGS/HOST_CFLAGS, make sure all "gcc -c" had a "-fPIC". And ld the so as following:
${LD} -shared -o libfstack.so $*.ro ${HOST_OBJS} -lc -lm -ldl -lcrypto -L${FF_DPDK}/lib -lrte_eal -lrte_mbuf -lrte_mempool -lrte_hash -lrte_ring -lrte_kni -lethdev -lrte_timer

May you check your lib is dynamic or static indeed.

@whl739
Copy link
Member

whl739 commented Sep 27, 2017

I'm sure it's dynamic.

@jinhao2
Copy link
Contributor Author

jinhao2 commented Sep 27, 2017

it is in this way: dynamic fstack's lib with static dpdk libs work OK. static fstack lib with dynamic dpdk lib work well too.
Dynamic fstack lib and dynamic dpdk lib will go wrong, as presented yesterday.

@ghost
Copy link

ghost commented Mar 11, 2019

Compiled f-stack as a shared library libfstack.so but get
OSError: ./libfstack.so: undefined symbol: rte_cycles_vmware_tsc_map
when loading in python CDLL('./libfstack.so')

@HREOLIN
Copy link

HREOLIN commented Apr 13, 2022

编译的f-stack作为共享库 libfstack.so,但在python CDLL('./libfstack.so')中加载时得到 OSError: ./libfstack.so: undefined symbol: rte_cycles_vmware_tsc_map

Is there a solution

1 similar comment
@HREOLIN
Copy link

HREOLIN commented Apr 13, 2022

编译的f-stack作为共享库 libfstack.so,但在python CDLL('./libfstack.so')中加载时得到 OSError: ./libfstack.so: undefined symbol: rte_cycles_vmware_tsc_map

Is there a solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants