EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Segmentation fault when setting motorStatusProblem_ to 1
From: Mark Rivers <[email protected]>
To: "'Sobhani, Bayan'" <[email protected]>, "[email protected]" <[email protected]>
Date: Thu, 1 Feb 2018 18:48:25 +0000

To run the IOC in gdb do the following:

 

gdb path-to-application

run st.cmd

 

That will run the IOC under the debugger.  When the IOC crashes you should see the gdb prompt.  At that point type “backtrace” or “bt” for short.

 

Here is a demonstration using the example IOC from base 7.0.1.1.  I have put in bold the things I typed.

 

corvette:example/iocBoot/ioctest>gdb ../../bin/linux-x86_64/test

GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-100.el7_4.1

Copyright (C) 2013 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "x86_64-redhat-linux-gnu".

For bug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>...

Reading symbols from /home/epics/devel/example/bin/linux-x86_64/test...done.

(gdb) run st.cmd

Starting program: /home/epics/devel/example/iocBoot/ioctest/../../bin/linux-x86_64/test st.cmd

 

[Thread debugging using libthread_db enabled]

Using host libthread_db library "/lib64/libthread_db.so.1".

[New Thread 0x7ffff4e04700 (LWP 71487)]

[Thread 0x7ffff4e04700 (LWP 71487) exited]

#!../../bin/windows-x64-static/test

 

 

< envPaths

epicsEnvSet("IOC","ioctest")

epicsEnvSet("TOP","/home/epics/devel/example")

epicsEnvSet("EPICS_BASE","/usr/local/epics-devel/base-7.0.1")

[New Thread 0x7ffff7fd5700 (LWP 71488)]

 

cd "/home/epics/devel/example"

 

## Register all support components

dbLoadDatabase "dbd/test.dbd"

test_registerRecordDeviceDriver pdbbase

 

## Load record instances

dbLoadTemplate "db/user.substitutions"

dbLoadRecords "db/testVersion.db", "user=rivers"

dbLoadRecords "db/dbSubExample.db", "user=rivers"

 

#var mySubDebug 1

 

#traceIocInit

 

cd "/home/epics/devel/example/iocBoot/ioctest"

iocInit

Starting iocInit

############################################################################

## EPICS R7.0.1.1

## EPICS Base built Jan  3 2018

############################################################################

[New Thread 0x7ffff7f54700 (LWP 71489)]

[New Thread 0x7ffff39e2700 (LWP 71490)]

[New Thread 0x7ffff38e1700 (LWP 71491)]

[New Thread 0x7ffff36e0700 (LWP 71492)]

[New Thread 0x7ffff34df700 (LWP 71493)]

[New Thread 0x7ffff32de700 (LWP 71494)]

[New Thread 0x7ffff30dd700 (LWP 71495)]

[New Thread 0x7ffff2edc700 (LWP 71496)]

[New Thread 0x7ffff2cdb700 (LWP 71497)]

[New Thread 0x7ffff2ada700 (LWP 71498)]

[New Thread 0x7ffff28d9700 (LWP 71499)]

[New Thread 0x7ffff26d8700 (LWP 71500)]

[New Thread 0x7ffff24d7700 (LWP 71501)]

[New Thread 0x7ffff22d6700 (LWP 71502)]

cas warning: Configured TCP port was unavailable.

cas warning: Using dynamically assigned TCP port 39419,

cas warning: but now two or more servers share the same UDP port.

cas warning: Depending on your IP kernel this server may not be

cas warning: reachable with UDP unicast (a host's IP in EPICS_CA_ADDR_LIST)

[New Thread 0x7ffff20d5700 (LWP 71503)]

[New Thread 0x7ffff1fd4700 (LWP 71504)]

[New Thread 0x7ffff7ed3700 (LWP 71505)]

iocRun: All initialization complete

[New Thread 0x7ffff1ed3700 (LWP 71506)]

[New Thread 0x7ffff1dd2700 (LWP 71507)]

[New Thread 0x7ffff1d51700 (LWP 71508)]

[New Thread 0x7ffff1c50700 (LWP 71509)]

[New Thread 0x7ffff1b4f700 (LWP 71510)]

[New Thread 0x7ffff1ace700 (LWP 71511)]

[New Thread 0x7ffff1a4d700 (LWP 71512)]

[New Thread 0x7ffff19cc700 (LWP 71513)]

 

## Start any sequence programs

#seq sncExample, "user=rivers"

epics>

epics> (I typed ^C here to simulate a crash)

 

Program received signal SIGINT, Interrupt.

0x00007ffff59867fd in read () from /lib64/libc.so.6

Missing separate debuginfos, use: debuginfo-install glibc-2.17-196.el7_4.2.x86_64 libgcc-4.8.5-16.el7_4.1.x86_64 libstdc++-4.8.5-16.el7_4.1.x86_64 ncurses-libs-5.9-14.20130511.el7_4.x86_64 readline-6.2-10.el7.x86_64 sssd-client-1.15.2-50.el7_4.8.x86_64

(gdb) backtrace

#0  0x00007ffff59867fd in read () from /lib64/libc.so.6

#1  0x00007ffff5465097 in rl_getc () from /lib64/libreadline.so.6

#2  0x00007ffff54658e7 in rl_read_key () from /lib64/libreadline.so.6

#3  0x00007ffff5450b2f in readline_internal_char () from /lib64/libreadline.so.6

#4  0x00007ffff54511e5 in readline () from /lib64/libreadline.so.6

#5  0x00007ffff64bf942 in osdReadline (context=0x612980, context=0x612980, prompt=0x7ffff64d3499 "epics> ") at ../../src/osi/os/default/gnuReadline.c:67

#6  epicsReadline (prompt=0x7ffff64d3499 "epics> ", context=0x612980) at ../../src/osi/epicsReadline.c:86

#7  0x00007ffff64b0b4f in iocshBody (pathname=<optimized out>, commandLine=0x0, macros=0x0) at ../../src/iocsh/iocsh.cpp:618

#8  0x0000000000404db6 in main (argc=<optimized out>, argv=<optimized out>) at ../testMain.cpp:20

(gdb)

 

Mark

 

 

From: Sobhani, Bayan [mailto:[email protected]]
Sent: Thursday, February 01, 2018 12:33 PM
To: Mark Rivers <[email protected]>; [email protected]
Subject: RE: Segmentation fault when setting motorStatusProblem_ to 1

 

How exactly do i run the IOC from gdb? When the IOC is running ps -A shows two processes called st.cmd. I do gdp -p [PID] then make the IOC crash by typing dbpf {...}Mtr 1234, but I get the same result as when I type backtrace without crashing the IOC:

 

0  0x00007fd1d8545bbd in read () at ../sysdeps/unix/syscall-template.S:81

#1  0x00007fd1d7df2b7d in rl_getc ()

   from /lib/x86_64-linux-gnu/libreadline.so.6

#2  0x00007fd1d7df3447 in rl_read_key ()

   from /lib/x86_64-linux-gnu/libreadline.so.6

#3  0x00007fd1d7ddcc4c in readline_internal_char ()

   from /lib/x86_64-linux-gnu/libreadline.so.6

#4  0x00007fd1d7ddd3c5 in readline ()

   from /lib/x86_64-linux-gnu/libreadline.so.6

#5  0x00007fd1d9071970 in epicsReadline ()

   from /usr/lib/x86_64-linux-gnu/libCom.so.3.14.12.3

#6  0x00007fd1d9062fdf in ?? ()

   from /usr/lib/x86_64-linux-gnu/libCom.so.3.14.12.3

#7  0x0000000000404956 in main ()

 

 

 


From: Mark Rivers [[email protected]]
Sent: Thursday, February 01, 2018 11:22 AM
To: Sobhani, Bayan; [email protected]
Subject: RE: Segmentation fault when setting motorStatusProblem_ to 1

Ø  What is causing the segmentation fault to occur?

 

You need to obtain a stack trace when the fault occurs.  Are you running on Linux or Windows?  On Linux you can run your program under gdb and when it crashes type the gdb command “backtrace”.  On Windows you need to build for the –debug architecture and then you can use the Visual Studio debugger when it crashes.

 

Mark

 

 

From: [email protected] [mailto:[email protected]] On Behalf Of Sobhani, Bayan
Sent: Thursday, February 01, 2018 10:17 AM
To: [email protected]
Subject: Segmentation fault when setting motorStatusProblem_ to 1

 

Here is my polling function for the MCS2 driver I am developing:

 

asynStatus SmarActMCS2Axis::poll(bool* moving_p){

        int64_t val;

        comStatus_=getp(channel_,&val);

        if(comStatus_!=asynSuccess){

                *moving_p=false;

               asynPrint(c_p_->pasynUserSelf,ASYN_TRACE_ERROR,"Error reading axis, channel=%d, comstatus=%d!\n", channel_,comStatus_);

                //c_p_ is a pointer to the controller object

                //setIntegerParam(c_p_->motorStatusProblem_,1);

                setIntegerParam(c_p_->motorStatusCommsError_,1);

                callParamCallbacks();

                return asynError;

        }

        val=val/1000;

        setDoubleParam(c_p_->motorEncoderPosition_,(double)val);

        setDoubleParam(c_p_->motorPosition_,(double)val);

        if(is_moving(channel_)==true){

                *moving_p=true;

        }

        else{

                *moving_p=false;

        }

        setIntegerParam(c_p_->motorStatusProblem_,0);

        setIntegerParam(c_p_->motorStatusCommsError_,0);

 

        setIntegerParam(c_p_->motorStatusMoving_,*moving_p);

        setIntegerParam(c_p_->motorStatusDone_, ! *moving_p);

        callParamCallbacks();

        return asynSuccess;

}

 

Notice that “setIntegerParam(c_p_->motorStatusProblem_,1);” is commented out because when I uncomment it, it causes the IOC to have a segmentation fault when I attempt to move an axis that is not connected. Surprisingly, “setIntegerParam(c_p_->motorStatusCommsError_,1);” does not cause the IOC to have a segmentation fault, and as expected raises a COMM alarm when I attempt to move an axis that is not connected. motorStatusProblem and motorStatusCommsError are not referenced anywhere else inside my code. What is causing the segmentation fault to occur?

 

Alex


References:
Segmentation fault when setting motorStatusProblem_ to 1 Sobhani, Bayan
RE: Segmentation fault when setting motorStatusProblem_ to 1 Mark Rivers
RE: Segmentation fault when setting motorStatusProblem_ to 1 Sobhani, Bayan

Navigate by Date:
Prev: RE: Segmentation fault when setting motorStatusProblem_ to 1 Sobhani, Bayan
Next: Re: Segmentation fault when setting motorStatusProblem_ to 1 Kasemir, Kay
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Segmentation fault when setting motorStatusProblem_ to 1 Sobhani, Bayan
Next: Re: Segmentation fault when setting motorStatusProblem_ to 1 Kasemir, Kay
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  <20182019  2020  2021  2022  2023  2024 
ANJ, 01 Feb 2018 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·