[perl #57504] [PATCH][Lua] Fixed 64bit bug in Lua bytecode decoder/translator.

Will Coleda via RT parrotbug-followup at parrotcode.org
Wed Oct 28 03:48:26 UTC 2009


On Mon Aug 04 15:10:03 2008, Neopallium wrote:
> On Mon Aug 04 02:39:05 2008, fperrad wrote:
> > On Mon Aug 04 02:37:16 2008, fperrad wrote:
> > > On my 32bits box (Windows 2000, Perl 5.8.8 ActiveState), on array
> > > context localtime(-1) gives an empty array.
> > > 
> > > Currently, I see 2 solutions:
> > > 1)
> > > - revert t/os.t to r29936 
> > > - a small patch on src/pmc/lua.pmc
> > > Index: lua.pmc
> > > 
=========================================================
==========
> > > --- lua.pmc	(revision 29995)
> > > +++ lua.pmc	(working copy)
> > > @@ -221,7 +221,7 @@
> > >  
> > >          t = mktime(&ts);
> > >  
> > > -        if (t == -1)
> > > +        if (t < 0)
> > >              retval = pmc_new(INTERP, dynpmc_LuaNil);
> > >          else {
> > >              retval = pmc_new(INTERP, dynpmc_LuaNumber);
> > > 
> 
> Returning nil for "t < 0" will not match how the official lua
> interpreter handles the return value from mktime.
> 
> Here is the code snip from the official lua interpreter:
> 
>     t = mktime(&ts);
>   }
>   if (t == (time_t)(-1))
>     lua_pushnil(L);
>   else
>     lua_pushnumber(L, (lua_Number)t);
>   return 1;
> }
> 
> on 32bit systems mktime has a major limitation in that it can only
> handle dates between year Jan 1970 to Jan 2038 reliably.  Buth on 64bit
> system (should be the same on 64bit windows, but I can't test) mktime
> isn't limited to that small range.  The same Epoch time is used for '0'
> and negative values are used for dates before Epoch.
> 
> Also here is a quote from the "Lua 5.1 Reference manual" about os.time:
> 
> "The returned value is a number, whose meaning depends on your system.
> In POSIX, Windows, and some other systems, this number counts the number
> of seconds since some given start time (the "epoch"). In other systems,
> the meaning is not specified, and the number returned by time can be
> used only as an argument to date and difftime."
> 
> We might need different test cases for each platform.  Maybe check the
> return value of "localtime(-1)" in perl and use the old year 1000 date
> if localtime doesn't return a valid date.

Lua is no longer (for some time) hosted in the parrot repository. I'm going to reject this ticket 
as we try to clean out parrot's old ticketing system.

It looks like lua's ticketing system is now at: http://github.com/fperrad/lua/issues; that's 
where I would recommend pursuing this issue now.

Regards.
-- 
Will "Coke" Coleda


More information about the parrot-dev mailing list