cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.11k stars 605 forks source link

Missing symbols when running Python 3 from Fedora on OSv #992

Closed wkozaczuk closed 9 months ago

wkozaczuk commented 6 years ago

Following symbols are reported missing:

/usr/lib/libpython3.6m.so.1.0: failed looking up symbol sched_getscheduler /usr/lib/libpython3.6m.so.1.0: failed looking up symbol flistxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol unlinkat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol wcscat_chk /usr/lib/libpython3.6m.so.1.0: failed looking up symbol fsetxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol llistxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol fremovexattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol lgetxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol listxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol sched_getparam /usr/lib/libpython3.6m.so.1.0: failed looking up symbol sched_setscheduler /usr/lib/libpython3.6m.so.1.0: failed looking up symbol sigtimedwait /usr/lib/libpython3.6m.so.1.0: failed looking up symbol readlinkat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol fexecve /usr/lib/libpython3.6m.so.1.0: failed looking up symbol mkdirat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol __wcsncpy_chk /usr/lib/libpython3.6m.so.1.0: failed looking up symbol lsetxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol clock_settime /usr/lib/libpython3.6m.so.1.0: failed looking up symbol fgetxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol sched_rr_get_interval /usr/lib/libpython3.6m.so.1.0: failed looking up symbol xmknodat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol linkat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol removexattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol getgrouplist /usr/lib/libpython3.6m.so.1.0: failed looking up symbol sigpending /usr/lib/libpython3.6m.so.1.0: failed looking up symbol sched_setparam /usr/lib/libpython3.6m.so.1.0: failed looking up symbol fchownat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol getxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol renameat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol setxattr /usr/lib/libpython3.6m.so.1.0: failed looking up symbol symlinkat /usr/lib/libpython3.6m.so.1.0: failed looking up symbol waitid /usr/lib/libpython3.6m.so.1.0: failed looking up symbol lremovexattr

Even though these symbols are not used by Python when running the examples from apps/python3x/README, they get resolved because Python from Fedora distribution is compiled to trigger eager symbols resolution (aka BIND_NOW).

Python from Ubuntu does NOT have those problems (because symbols are resolved lazily) all 3 examples work fine with Python 3.

We probably need to at least add stubs for these symbols.

wkozaczuk commented 6 years ago

WIth latest patch addressing #993 to relax symbol resolution for BIND_NOW Python 3 can start and operate without these symbols this issue becomes much less important obviously until somebody wants to run Python app that ends up using one of these symbol. Also we do not need stubs for any of those.

photoszzt commented 5 years ago

I'm hitting this error:

/usr/lib/libpython3.6m.so.1.0: failed looking up symbol __wcscat_chk

[backtrace] 0x000000004035fdf9 <elf::object::symbol(unsigned int, bool)+1001> 0x000000004035febf <elf::object::resolve_pltgot(unsigned int)+127> 0x0000000040360099 <elf_resolve_pltgot+57> 0x00000000403a643f <???+1077568575> 0x00002000001f8c2f <???+2067503>

How can I add this symbol implementation?

photoszzt commented 5 years ago

I get this error when I'm using virtualenv. If I get out of virtualenv, I don't have this error.

wkozaczuk commented 5 years ago

@photoszzt In general, it should be pretty trivial. You need to add an implementation of the missing symbol into a new file or existing one and then to a makefile. Here is an example - https://github.com/cloudius-systems/osv/commit/00a2284f1c1bdfc9fb02158cbc509a75b8a47c51.

As I undestand __wcscat_chk is a 'fortify' type-of function from libc so it would go there like others:

find libc/ -name \*_chk.c
libc/string/__stpcpy_chk.c
libc/string/__strncpy_chk.c
libc/string/__memmove_chk.c
libc/string/__strncat_chk.c
libc/string/__strcat_chk.c
libc/string/__wcscpy_chk.c
libc/string/__strcpy_chk.c
libc/string/__memset_chk.c
libc/string/__explicit_bzero_chk.c
libc/string/__memcpy_chk.c
libc/stdio/__fread_chk.c
libc/stdio/__vfprintf_chk.c
libc/stdio/__fprintf_chk.c
libc/__read_chk.c

I have found here a possible implementation of it.

We welcome patches :-)

cdosoftei commented 4 years ago

:+1: for the top of the list, sched_getscheduler. In #996 there is a mention of an existing patch in the mailing list; could it be this one?

Thank you!

nyh commented 4 years ago

Yes, indeed (though I don't remember if this was the last version). But this was much more than just sched_getscheduler() - this was implementing also realtime scheduling in OSv. If all you need is a trivial implementation which always returns the same scheduler, you don't really need that entire patch. If you do want to bring back realtime scheduling in OSv, let me know - I have the latest version of my scheduler patch stashed somewhere.

cdosoftei commented 4 years ago

That is very useful, thank you.

I am still in the process of researching so I don't have a full view of the scope's extent (accounting for syscalls like clock_nanosleep for example); once I figure it out, I'll likely start a topic on the mailing list which should be better suited for a "meta" conversation rather than this issue tracker.

Thanks again.

wkozaczuk commented 9 months ago

I think this issue has been about many things and mostly belongs to the mailing list so closing it. If one cannot run Python because of missing __wcscat_chk they can run with Linux dynamic linker and libc on OSv to get around this problem.