EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: Asyn/VXI-11 problems
From: Benjamin Franksen <[email protected]>
To: [email protected]
Date: Thu, 20 Sep 2007 14:50:40 +0200
On Wednesday 19 September 2007 15:36, Benjamin Franksen wrote:
> On Tuesday 18 September 2007 17:03, Eric Norum wrote:
> > On Sep 18, 2007, at 9:59 AM, Jeff Hill wrote:
> > > Hi Ben,
> > >
> > > You might try commenting out iocInit in the startup script, and
> > > then after
> > > the IOC boots up type "sp iocInit". When it fails type "tt <task
> > > id>" to get
> > > the stack trace. If that doesn't help you might also build for
> > > debugging and
> > > attach the Tornado debugger to the IOC.
> >
> > This is running on linux so Benjamin needs only to run the IOC under
> > gdb.
>
> I have run it under ddd and valgrind and attached the outputs. I used
> asyn4-8 and stream2-2. The problem /appears/ to be in stream support
> (contrary to what I thought at first). OTOH, the many many timeouts are
> completely inexplicable to me and suggest that there is something wrong
> with asyn/vxi-11, too. Anyway, I am completely lost; I have great
> difficulty understabnding the relevant stream (C++) code.

Ok, I've found one bug in stream version 2-2 that leads to a crash. A format 
of "%*[whatever>]"
gets converted internally to "%0[whatever>]%n" and then only /one/ pointer 
arg is provided to sscanf, instead of two. The method where sscanf crashes 
is in StreamFormatConverter.cc:

int StdCharsetConverter::
scanString(const StreamFormat& fmt, const char* input,
    char* value, size_t maxlen)
{
    int length = -1;
    if (fmt.flags & skip_flag)
    {
        if (sscanf (input, fmt.info, &length) < 0) return -1;
    }
    ....

Since skip_flag is set only for %* formats, it is wrong to replace it with 
%0. Thus the parse method must be changed, like this (see comments):

int StdCharsetConverter::
parse(const StreamFormat& fmt, StreamBuffer& info,
    const char*& source, bool scanFormat)
{
    if (!scanFormat)
    {
        error("Format conversion %%[ is only allowed in input formats\n");
        return false;
    }
    if (fmt.flags & (left_flag|sign_flag|space_flag|zero_flag|alt_flag))
    {
        error("Use of modifiers '-', '+', ' ', '0', '#'"
            "not allowed with %%%c conversion\n",
            fmt.conv);
        return false;
    }
    if (scanFormat && fmt.prec >= 0)
    {
        error("Use of precision field '.%d' not allowed with %%%c input 
conversion\n",
            fmt.prec, fmt.conv);
        return false;
    }
    // fix: bfr 20/09/07
    if (fmt.flags & skip_flag ) {
        info.printf("%%*[");
    }
    else {
        info.printf("%%%d[", fmt.width);
    }
    // end fix
    while (*source && *source != ']')
    {
        if (*source == esc) source++;
        info.append(*source++);
    }
    if (!*source) {
        error("Missing ']' after %%[ format conversion\n");
        return false;
    }
    source++; // consume ']'
    info.append("]%n");
    return string_format;
}

However, the IOC crashes anyway, because this is just one of many bugs. I'll 
send more debugger output soon.

Cheers
Ben
-- 
"Programming = Mathematics + Murphy's Law" (E.W.Dijkstra)

Replies:
Re: Asyn/VXI-11 problems Benjamin Franksen
Re: Asyn/VXI-11 problems Dirk Zimoch
References:
Asyn/VXI-11 problems Benjamin Franksen
Re: Asyn/VXI-11 problems Eric Norum
Re: Asyn/VXI-11 problems Benjamin Franksen

Navigate by Date:
Prev: Re: lanGpibSupport-2.4.c Benjamin Franksen
Next: Re: Asyn/VXI-11 problems Benjamin Franksen
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Asyn/VXI-11 problems Benjamin Franksen
Next: Re: Asyn/VXI-11 problems Benjamin Franksen
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Nov 2011 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·