Access Security segmentation fault if *.acf file is missing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
Medium
|
Andrew Johnson | ||
3.14 |
Fix Released
|
Medium
|
Andrew Johnson | ||
3.15 |
Fix Released
|
Medium
|
Andrew Johnson | ||
3.16 |
Fix Released
|
Medium
|
Andrew Johnson |
Bug Description
Hi,
I discovered that a missing *.acf file in combination with iocStats leads to to a segmentation fault. This seems to be caused by a mutex locked by AccessSecurity which is never unlocked. If I remove asSetFilename from the startup script or remove iocStats the segmentation fault does not occur. Our base version is 13.14.12.5. Is this already known or perhaps fixed in 3.14.12.6?
Here is the whole backtrace + startup script call:
(gdb) run
Starting program: /home/schroeder
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_
[New Thread 0x7ffff40f5700 (LWP 26778)]
[Thread 0x7ffff40f5700 (LWP 26778) exited]
#!../..
epicsEnvSet IOC SIOC45C
epicsEnvSet LOG_DIR /opt/IOC/log
# Change to top directory
cd ../..
#######
epicsEnvSet STREAM_
epicsEnvSet(
#######
dbLoadDatabase dbd/SIOC45C.dbd 0 0
SIOC45C_
#######
drvAsynIPPortCo
[New Thread 0x7ffff7fc2700 (LWP 26780)]
[New Thread 0x7ffff38f4700 (LWP 26781)]
[New Thread 0x7ffff37f3700 (LWP 26782)]
[New Thread 0x7ffff7ec1700 (LWP 26783)]
#######
set_requestfile
set_requestfile
set_savefile_path /opt/IOC/
save_restoreSet
save_restoreSet
#######
dbLoadRecords db/DistVersion.db "IOC=SIOC45C,TOP=."
dbLoadRecords db/IOC-stats.db "IOC=SIOC45C"
dbLoadRecords db/FugProbusV.
dbLoadRecords "db/asynRecord.db" "P=PKIK1D1R:
#######
set_pass0_
set_pass1_
#######
# IOC Log Server Connection 0=enabled 1=disabled
setIocLogDisable 1
# Configure Access Security
asSetFilename /opt/IOC/
#######
iocInit
[New Thread 0x7ffff36f2700 (LWP 26784)]
Starting iocInit
#######
## EPICS R3.14.12.5 $Date: Tue 2015-03-24 09:57:35 -0500$
## EPICS Base built May 30 2017
#######
[New Thread 0x7ffff3671700 (LWP 26785)]
[New Thread 0x7ffff3570700 (LWP 26786)]
[New Thread 0x7ffff336f700 (LWP 26787)]
[New Thread 0x7ffff316e700 (LWP 26788)]
[New Thread 0x7ffff2f6d700 (LWP 26789)]
[New Thread 0x7ffff2d6c700 (LWP 26790)]
reboot_restore: entry for file 'SIOC45C_0.sav'
reboot_restore: Found filename 'SIOC45C_0.sav' in restoreFileList.
*** restoring from '/opt/IOC/
reboot_restore: done with file 'SIOC45C_0.sav'
[New Thread 0x7ffff2c6b700 (LWP 26791)]
reboot_restore: entry for file 'SIOC45C_1.sav'
reboot_restore: Found filename 'SIOC45C_1.sav' in restoreFileList.
*** restoring from '/opt/IOC/
reboot_restore: done with file 'SIOC45C_1.sav'
[New Thread 0x7ffff2b6a700 (LWP 26792)]
[New Thread 0x7ffff2969700 (LWP 26793)]
[New Thread 0x7ffff2768700 (LWP 26794)]
[New Thread 0x7ffff2567700 (LWP 26795)]
[New Thread 0x7ffff2366700 (LWP 26796)]
[New Thread 0x7ffff2165700 (LWP 26797)]
[New Thread 0x7ffff1f64700 (LWP 26798)]
[New Thread 0x7ffff1d63700 (LWP 26799)]
asInitFile: Can't open file '/opt/IOC/
iocBuild: asInit Failed.
epics>
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff2d6c700 (LWP 26790)]
epicsMutexLock (pmutexNode=0x0) at ../../.
143 epicsMutexOsdLo
(gdb) bt
#0 epicsMutexLock (pmutexNode=0x0) at ../../.
#1 0x00007ffff66a0f09 in casStatsFetch (pChanCount=
pCircuitCou
#2 0x00007ffff73269d7 in scan_time (type=3) at ../devIocStatsA
#3 0x00007ffff579f7fe in epicsTimerForC:
at ../../.
#4 0x00007ffff57a113e in timerQueue::process (this=this@
at ../../.
#5 0x00007ffff57a1853 in timerQueueActiv
at ../../.
#6 0x00007ffff57942a9 in epicsThreadCall
at ../../.
#7 0x00007ffff57998f5 in start_routine (arg=0x6d35c0)
at ../../.
#8 0x00007ffff497e064 in start_thread (arg=0x7ffff2d6
#9 0x00007ffff4c7b62d in clone () at ../sysdeps/
(gdb)
From a quick look, the issue is that casStatsFetch() can't be called until/unless the CA server (RSRV) has successfully initialized. iocstats is starting it's 1Hz scan timer from a device support init() function, this happens before RSRV is started. So this would also crash if the initialization between these two points takes longer than 1 second.
At a minimum, iocStats should not start this timer until after RSRV has started, if not later. I'd suggest an initHook with initHookAfterCa ServerRunning or initHookAfterIo cRunning.
https:/ /github. com/epics- modules/ iocStats/ blob/0cec4fc67a 4d4419c21161d88 9862766a7690daa /devIocStats/ devIocStatsAnal og.c#L405