assert fail of caget under msvc 8

Bug #541265 reported by Jeff Hill
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
High
Jeff Hill

Bug Description

This appears to be related to this line in caget/caput/camonitor/cainfo.

    setvbuf(stdout,NULL,_IOLBF,0); /* Set stdout to line buffering */

Apparently the new ms CRTL assert fails 2 <= size <= INT_MAX. Thats a new feature of visual C++ 2005 (see <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_setvbuf.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_setvbuf.asp</a>). This does not match POSIX (see <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/setvbuf.html">http://www.opengroup.org/onlinepubs/007908799/xsh/setvbuf.html</a>).

I did find that making this change appears to fix the problem.

    setvbuf(stdout,NULL,_IOLBF,2); /* Set stdout to line buffering */

Jeff

> -----Original Message-----
> From: guobao shen
> Sent: Wednesday, November 23, 2005 5:09 AM
> To: 'Jeff Hill'; 'Vladimir Sirotenko'; <email address hidden>
> Subject: RE: EPICS base compiling using Visual C++ 2005 Express
>
> Dear Dr. Jeff and Dr. Vladimir,
>
> Thank you very much.
>
> I succeeded in the compilation after removing the TD from the fdopen
> specification.
> If I tried to build static libraries, there was no problem. But if I tried
> to build shared
> libraried, I must copy the manifest specification file for each exe or dll
> file into
> bin/win32-x86 manually.
>
> I also found that I can not execute the catools such as
> caget/cainfo/camonitor correctly.
> The only error message is "caget.exe has encountered a problem and needs
> to
> close."
>
> Can you give any suggestion?
>
> Thanks again.
>
> Best Regards,
>
> Guobao Shen
> J-PARC Control Group
>
>
> >
> > I looked into this "w+bTD" verses "W+B".
> >
> > The purpose of this code is to open an identical type of
> > temporary file on all OS. This particular problem is, of
> > course, in Microsoft specific code working with previous
> > versions, but not with Visual C++ 2005.
> >
> > The very latest documentation at MS with a 2005 time stamp on
> > it lists "T"
> > and "D" as valid Microsoft specific options to _fdopen. This
> > therefore smells like a bug at MS. Nevertheless, the proposed
> > change appears to work - not creating any permanent files on
> > the disk. This is probably because roughly equivalent options
> > are specified to the preceding open().
> >
> > We have committed the suggested change - ETA R3.14.8.
> >
> > Jeff
> >
> > > -----Original Message-----
> > > From: Vladimir Sirotenko
> > > Sent: Tuesday, November 22, 2005 9:34 AM
> > > To: guobao shen; <email address hidden>
> > > Subject: Re: EPICS base compiling using Visual C++ 2005 Express
> > >
> > > Try to do the following, it worked for us:
> > >
> > > Antelope failed to run correctly because it could not create a
> > > temporary file.
> > > Modify srclibComosiWIN32epicsTempFile.cpp and remove
> > the TD from
> > > the fdopen specification.
> > >
> > > pNewFile = _fdopen ( fd, "w+b" ); instead of pNewFile =
> > > _fdopen ( fd, "w+bTD" );
> > >
> > > Vladimir
> > >

Original Mantis Bug: mantis-230
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=230

Tags: 3.14
Revision history for this message
Jeff Hill (johill-lanl) wrote :

Perhaps this MS warning is relevant.

Visual C++ now supports a secure version of the C Runtime Library. Use of this library is turned on by default. You may see some warnings about deprecated functions when you build your project. It is advised that you correct these warnings, in order to make your code more secure.

Revision history for this message
Jeff Hill (johill-lanl) wrote :

The problem is that they want you to call alternative functions only available in - you guessed it - the OS of global domination.

For example they want strncpy_s instead of strncpy

So perhaps we just need to use a different library or command line flag instead of giving over to the dark side.

If that is the case then Ralph may not be the person to look at this.

edited on: 2005-11-23 17:17

Revision history for this message
Jeff Hill (johill-lanl) wrote :

I had a closer look at the MS and the POSIX doc. It appears that there is confusion between the two related to how the arguments are interpreted when the user buffer pointer is null. In the POSIX doc it clearly states that the count only applies if the user pointer isnt nill. In the MS doc it clearly states that the count is also the size of the internally allocated buffer when the user pointer is nill.

It seems that a reasonable compromise will be to specify a buffer size of BUFSIZ (defined by POSIX and fortunately also by windows).

edited on: 2005-11-29 10:06

Revision history for this message
Jeff Hill (johill-lanl) wrote :

fixed in R3.14.8

Revision history for this message
Andrew Johnson (anj) wrote :

R3.14.8 released.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.