Page 1 of 1

hang in pthread_join subsequent to Python CPhidget_close

Posted: Fri Nov 17, 2017 7:57 pm
by wbclay
Python Phidget application hang in pthread_join called from CPhidget_close.

There appears to be a problem with InterfaceKit closePhidget() when using pure time-interval-based analog input interrupt-driven sampling:

d.setDataRate(i, 256)
d.setSensorChangeTrigger(i, 0)

The data sampling works fine. The problem is closePhidget() provokes the following hang frequently (ca. 75%), which can be cleared only by kill -KILL:

0x00007fca602ce49b in pthread_join (threadid=140507019728640, thread_return=0x0)
at pthread_join.c:92
92 pthread_join.c: No such file or directory.
(gdb) bt
#0 0x00007fca602ce49b in pthread_join (threadid=140507019728640, thread_return=0x0)
at pthread_join.c:92
#1 0x00007fca5d5f3284 in CUSBCloseHandle (phid=0x7fca56ffd9d0) at linux/cusblinux-1.0.c:39
#2 0x00007fca5d5afd0e in CPhidget_close (phid=0x7fca56ffd9d0) at cphidget.c:524
#3 0x00007fca5ef50f60 in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#4 0x00007fca5ef509c8 in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#5 0x00007fca5f161055 in _ctypes_callproc ()
from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#6 0x00007fca5f1659b2 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#7 0x00000000004c9e8b in PyEval_EvalFrameEx ()
#8 0x00000000004c996a in PyEval_EvalFrameEx ()
#9 0x00000000004c996a in PyEval_EvalFrameEx ()
#10 0x00000000004c7a59 in PyEval_EvalCodeEx ()
#11 0x000000000050160f in ?? ()
#12 0x00000000004f6c32 in PyRun_FileExFlags ()
#13 0x00000000004f5d37 in PyRun_SimpleFileExFlags ()
#14 0x00000000004981cd in Py_Main ()
#15 0x00007fca5f618b45 in __libc_start_main (main=0x497c60 <main>, argc=2, argv=0x7ffd0bc313e8,
init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7ffd0bc313d8) at libc-start.c:287
#16 0x0000000000497b8b in _start ()
(gdb)

This problem is reliably (so far) evaded by simply switching to change-based interrupts immediately prior to closing:

d.setSensorChangeTrigger(genbatt, 100)
d.closePhidget()

Environment:
Debian Jessie
Linux version 3.16.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.43-2+deb8u5 (2017-09-19)
attached InterfaceKit, lib ver=Phidget21 - Version 2.1.8 - Built Apr 24 2017 21:10:02, dev ver=204

Re: hang in pthread_join subsequent to Python CPhidget_close

Posted: Tue Nov 21, 2017 9:13 am
by mparadis
Thanks for the error report. This issue has been fixed in Phidget22.