Skip to content

Commit 9cf118c

Browse files
committed
qtvcp: stop QPin update timer before hal_exit to prevent shutdown SIGSEGV
On Ubuntu 24.04 (glibc 2.39) shutting down a qtvcp screen can SIGSEGV because the QPin polling timer keeps firing after hal_exit detaches HAL shared memory. Path: qtvcp.py shutdown() calls HAL.exit() -> _hal.component.exit() -> hal_exit(comp_id). When the last component exits, hal_lib.c calls rtapi_shmem_delete, unmapping HAL shmem. QPin.REGISTRY still holds Python QPins whose pyhalitem.pin.u is a value-snapshot pointer into that shmem, and the QPin.update_all QTimer is never stopped, so its next tick dereferences an unmapped page. Older glibc/kernel combinations happened to keep the pages around after detach, hiding the bug. Fix: stop the QPin update timer before HAL.exit().
1 parent daf366a commit 9cf118c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/emc/usr_intf/qtvcp/qtvcp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ def shutdown(self,signum=None,stack_frame=None):
523523
LOG.debug('Exiting HAL')
524524
if not HAL is None:
525525
try:
526+
# Stop the QPin polling timer before hal_exit; otherwise its
527+
# next tick dereferences pin->u after hal_exit has unmapped
528+
# HAL shmem, causing SIGSEGV on glibc 2.39 (Ubuntu 24.04).
529+
from qtvcp.qt_halobjects import QPin
530+
QPin.update_stop()
526531
HAL.exit()
527532
except Exception as e:
528533
print(e)

0 commit comments

Comments
 (0)