Re: To 'C' or not to 'C' ... now what the hell to I do?



In article <4794f341$0$90263$14726298@xxxxxxxxxxxxxxx>,
Arne Vajhøj <arne@xxxxxxxxxx> wrote:

VAXman- @SendSpamHere.ORG wrote:
It does and I found it! It wasn't in the application but in the program
used to generate the regression data and the problem is already document-
ed in the release notes of the VMS83A_ACRTL-V0400 patch:

5.2.5 Function mktime() Fix

5.2.5.1 Problem Description:

Modules compiled under OpenVMS version 7.3-2 use the
short version of struct tm when making a call to mktime()
on an OpenVMs version 8.3 system. The mktime() API
internally creates a temporary copy of a struct tm then
calls localtime_r(). In our environment, the module
containing the mktime() function was compiled using 8.3
semantics. This resulted in a longer struct tm.

At the end of the mktime() function the temporary struct
tm is copied onto the input struct tm. This results in
copying a longer struct tm over a short struct tm.

I needed to find it first before applying any patch. I changed the code
in the regression test to add some padding after the tm struct where it
is called out. The bug in the mktime() was writing over a variable that
was eventually used in the length of a descriptor. The code was actually
compiled well before V7.3-2. The tm struct was 36 bytes in length and the
new tm is 44 bytes -- 2 longwords longer.

That is a really bad thing they did there.

In reality it means that any program that uses struct tm need to be
rebuild when moved from VMS 7.3-2 to 8.3 !

Very non-VMSish !

Well, this goof apparently consisted of merely compiling one module in
the CRTL with the standard headers. Look at the following sections from
time.h:

** - Future VMS releases will get a longer tm structure possibly with
** changed/filler names, to make all objects of tm the same length,
** which may force recompilation of all modules using tm.
** - Macro _TM_SHORT will force short tm
** - Macro _TM_LONG will force long tm
**

[and later]

# if __CRTL_VER >= 80300000 || defined _TM_LONG || \
defined __TM_CXX_NEED_FILLER_NAMES
/* Longer tm, but non-polluting BSD member names */
# define __TM_DEF_BSD_FILLER_NAMES

[and later still]

#elif defined __TM_DEF_BSD_FILLER_NAMES
/* BSD tm member extensions, non-polluting namespace */
long __tm_gmtoff; /* offset from UTC in seconds */
char *__tm_zone; /* timezone abbreviation */


So clearly compiling under v8.3 gives you a couple more structure
members than you would have had before, at least unless you had
explicitly defined the _TM_LONG macro before.

I suspect that it's much harder, if not impossible, to build a v8.3
CRTL on older VMS versions than has been the case in some eras. So
many of the new goodies depend on OS features, RMS features, etc. They
did make a mistake in not preserving upward compatibility, but I can
see how it happened. I was hoping that this meant the 2038 bug had
been fixed for anything compiled on v8.3 and later, but that appears to
be unrelated and will be another compatibility rat's nest in our
future.

--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: To C or not to C ... now what the hell to I do?
    ... used to generate the regression data and the problem is already document- ... Function mktime() Fix ... short version of struct tm when making a call to mktime ... I needed to find it first before applying any patch. ...
    (comp.os.vms)
  • Re: To C or not to C ... now what the hell to I do?
    ... used to generate the regression data and the problem is already document- ... Function mktime() Fix ... short version of struct tm when making a call to mktime ... I needed to find it first before applying any patch. ...
    (comp.os.vms)
  • Re: How to convert from a struct tm to a time_t ?
    ... Very handy. ... so they are straightforward to put into a struct tm. ... mktime() except it assumes that the broken-down time is in GMT. ... You can then apply that adjustment ...
    (comp.lang.c)
  • Re: main() in C90
    ... NO SPECIFICATION about maximum data ranges is done at ALL! ... of components of a struct tm is specified by the standard. ... The function of mktime is to convert the system ... specific timer format to a known system independent format. ...
    (comp.lang.c)
  • Re: byte alignment/dynamic memory from heap x64
    ... I had seen the definition in the WDK header that uses ... declspec) and I was compiling with x64 compiler. ... struct and when my driver is loaded I dynamically allocate memory using these ... The documention for x64 states that SLIST_ENTRY and SLIST_HEADER must be 16 ...
    (microsoft.public.development.device.drivers)