elsampsa / valkka-core

Valkka - Create video surveillance, management and analysis programs with PyQt
GNU Lesser General Public License v3.0
181 stars 35 forks source link

Note for docker users: "crash in libVallka getValue()" #29

Open alexey001 opened 2 years ago

alexey001 commented 2 years ago

Version: 1.2.2-0ubuntu1-focalppa1 (self compiled same effect) Crash on demo application websocket-mse-demo .

Backtrace:

Program terminated with signal SIGSEGV, Segmentation fault.

0 __new_sem_getvalue (sem=0x0, sval=0x7ffddd6ddc94) at sem_getvalue.c:38

38 sem_getvalue.c: No such file or directory. (gdb) bt

0 __new_sem_getvalue (sem=0x0, sval=0x7ffddd6ddc94) at sem_getvalue.c:38

1 0x00007f2e6b2b78c6 in SharedMemRingBufferBase::getValue() () from /lib/libValkka.so.1

2 0x00007f2e6b2b7a31 in SharedMemRingBufferBase::zero() () from /lib/libValkka.so.1

3 0x00007f2e6b2b8118 in SharedMemRingBufferBase::SharedMemRingBufferBase(char const*, int, unsigned long, int, bool) () from /lib/libValkka.so.1

4 0x00007f2e6b2a5239 in FragMP4SharedMemRingBuffer::FragMP4SharedMemRingBuffer(char const*, int, unsigned long, int, bool) () from /lib/libValkka.so.1

5 0x00007f2e6b2a548c in FragMP4ShmemFrameFilter::FragMP4ShmemFrameFilter(char const*, int, unsigned long, int) () from /lib/libValkka.so.1

6 0x00007f2e6c9d371f in _wrap_new_FragMP4ShmemFrameFilter () from /usr/lib/python3/dist-packages/valkka/core/_valkka_core.so

7 0x00000000005f2d6a in cfunction_call_varargs (kwargs=, args=,

func=<built-in method new_FragMP4ShmemFrameFilter of module object at remote 0x7f2e6ca3c4a0>) at ../Include/internal/pycore_pyerrors.h:13

OS: cat /etc/os-release NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.3 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal

(running in LXD container).

df -h | grep shm tmpfs 16G 8.0K 16G 1% /dev/shm

ipcs -m

------ Shared Memory Segments -------- key shmid owner perms bytes nattch status

SIGSEGV occurs when run as regular user and root.

elsampsa commented 2 years ago

Thanks for the report.

A quick follow-up question: you have only seen this segfault when using the LXD container, right?

alexey001 commented 2 years ago

Yes. I have not tried other options as my host system not debian-based (gentoo) and more work needs to be done to compile libvalkka.

alexey001 commented 2 years ago

It looks like the problem is somewhere in my system. I will analyze more..

==24324== ---Thread-Announcement------------------------------------------ ==24324== ==24324== Thread #1 is the program's root thread ==24324== ==24324== ---------------------------------------------------------------- ==24324== ==24324== Thread #1's call to sem_open failed ==24324== with error code 13 (EACCES: Permission denied) ==24324== at 0x48445F4: sem_open (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_helgrind-amd64-linux.so) ==24324== by 0x5EF9FDE: SharedMemRingBufferBase::SharedMemRingBufferBase(char const, int, unsigned long, int, bool) (in /usr/lib/libValkka.so.1.2.2) ==24324== by 0x5EE7238: FragMP4SharedMemRingBuffer::FragMP4SharedMemRingBuffer(char const, int, unsigned long, int, bool) (in /usr/lib/libValkka.so.1.2.2) ==24324== by 0x5EE748B: FragMP4ShmemFrameFilter::FragMP4ShmemFrameFilter(char const*, int, unsigned long, int) (in /usr/lib/libValkka.so.1.2.2) ==24324== by 0x5C5771E: _wrap_new_FragMP4ShmemFrameFilter (in /usr/lib/python3/dist-packages/valkka/core/_valkka_core.so.1.2.2) ==24324== by 0x5F2D69: UnknownInlinedFun (call.c:758) ==24324== by 0x5F2D69: PyCFunction_Call (call.c:773) ==24324== by 0x5F300F: _PyObject_MakeTpCall (call.c:159) ==24324== by 0x5700F2: UnknownInlinedFun (abstract.h:125) ==24324== by 0x5700F2: UnknownInlinedFun (abstract.h:115) ==24324== by 0x5700F2: UnknownInlinedFun (ceval.c:4963) ==24324== by 0x5700F2: _PyEval_EvalFrameDefault (ceval.c:3469) ==24324== by 0x568D99: UnknownInlinedFun (ceval.c:741) ==24324== by 0x568D99: _PyEval_EvalCodeWithName (ceval.c:4298) ==24324== by 0x5F5B32: _PyFunction_Vectorcall (call.c:436)

elsampsa commented 2 years ago

thanks!

One detail: working with shared memory (and semaphores?) in containers, can give surprises. See for example the comments in libValkka's dockerhub page.

Could this be a problem with user rights in your container's /dev/shm folder? : link

alexey001 commented 2 years ago

The problem was simple - I launched the application one time as a root and of course, after that the application could not open /dev/shmXXX (running as regular user). Probably it is worth providing for the analysis of the return code when opening shared memory dev's.

elsampsa commented 2 years ago

I will keep this open to remind me that using shared memory in docker containers can give surprises & this must be properly documented