Anders Bergh | 1 Aug 01:55
Picon
Gravatar

Re: bug

On 7/31/07, Roberto Ierusalimschy <roberto <at> inf.puc-rio.br> wrote:
> Mike Pall just reported the following bug:
>
> > $ ulimit -s 1024       # Reduce C stack to 1MB for quicker results
> > $ lua -e 'local s = "a,"; for i=1,18 do s = s..s end print(loadstring("local a"..s.."a=nil", ""))'
> > Segmentation fault
> > $

I can't reproduce the bug, this is what happens here and on my x86_64 machine:

[anders <at> router ~]$ ulimit -s 1024
[anders <at> router ~]$ lua -e 'local s = "a,"; for i=1,18 do s = s..s end
print(loadstring("local a"..s.."a=nil", ""))'
nil     [string ""]:1: main function has more than 200 local variables

--

-- 
Anders

Mike Pall | 1 Aug 02:53
Picon

Re: bug (really: assignment parser stack overflow)

Hi,

Anders Bergh wrote:
> On 7/31/07, Roberto Ierusalimschy <roberto <at> inf.puc-rio.br> wrote:
> > Mike Pall just reported the following bug:
> >
> > > $ ulimit -s 1024       # Reduce C stack to 1MB for quicker results
> > > $ lua -e 'local s = "a,"; for i=1,18 do s = s..s end print(loadstring("local a"..s.."a=nil", ""))'
> > > Segmentation fault
> > > $
> 
> I can't reproduce the bug, this is what happens here and on my x86_64 machine:

Gee .. a really cute cut'n'paste error which completely changes
the semantics. Umm, Roberto, this needs a space or semicolon at
the end of "local a ". My original mail included the space. :-)

Ok, so here's the same script without wrap-around problems:

  local s = "a,"
  for i=1,18 do s = s..s end
  print(loadstring("local a;"..s.."a=nil", ""))

Bye,
     Mike

Mark Hamburg | 1 Aug 03:55
Picon
Favicon

Re: lists with nil play nice for Lua 5.2

on 7/30/07 8:19 AM, Jerome Vuarand at jerome.vuarand <at> ubisoft.com wrote:

>> __len??
> 
> I thought so initially, but it's not overridable for tables :-)

I got burned by that a while ago when I wanted to create an array that
actually did data lookup to fetch the members but would not hang onto that
data afterward. Code that used # wouldn't work. We ended up resorting to
interposing a userdata.

Mark

Mike Pall | 1 Aug 03:59
Picon

Re: Problems with MinGW v3.4.5 on WinXP SP2 when luaL_checkxxx() fails

Hi,

RJP Computing wrote:
> My system is Windows XP SP2 with MinGW 5.1.2/gcc v3.4.5 and Lua 5.1.2. I am
> not sure if this is a Lua issue or a lack of understanding on my part, so
> please bare with this. Thanks.

It's most likely a problem with the C++ exception mechanism.

GCC (even the MinGW edition) doesn't use the standard Windows
mechanism for exception unwinding. This is because of the Borland
SEH patent. That leaves us with SJLJ or DW2 exceptions. DW2 may
break cross-DLL throws, so better check what your MinGW GCC has
been compiled with (it's not a command line flag).

This mess causes all sorts of trouble when mixing code compiled
with or without exception support, with or without frame
pointers, with or without debug symbols and so on. And of course
when mixing DLLs made by different compilers. Yes, this sucks.

> (I used the binary static library from LuaBinary on LuaForge

Since you've already installed MinGW, you're much better off
compiling Lua yourself. A "make mingw" takes a few seconds.

Try the standard compile first. If this doesn't work then try
adding -fexceptions. Or try compiling Lua with the C++ compiler.
Or compile your C++ code without exception handling. :-)

Some permutation of this will make it work. That is ... until
(Continue reading)

Mark Hamburg | 1 Aug 04:11
Picon
Favicon

Re: lists with nil play nice for Lua 5.2

Where this thread seems to be headed is toward defining a standard userdata
type "array".

    a = array( 2, nil, "foo" )

    #a -- yields 3

    a:insert( "baz" )

    a[ 4 ] -- yields "baz"

    a:unpack() -- yields 2, nil, "foo", "baz"

    for i, v in a:ipairs() do
        print( i, v )
    end
        -- 1    2
        -- 2    nil
        -- 3    foo
        -- 4    baz

Not that hard to define. Probably built by using the environment table for
the userdata perhaps with a separate metatable per object as well that can
point to the environment table in its __index entry.

Of course, now we've moved from one table to three in order to represent an
array and we've lost the simple uniformity of having only one data type. So,
I'm not sure it's an improvement.

The fundamental problem with the current situation is that code that isn't
(Continue reading)

RJP Computing | 1 Aug 04:12
Picon
Gravatar

Re: Problems with MinGW v3.4.5 on WinXP SP2 when luaL_checkxxx() fails

On 7/31/07, Mike Pall <mikelu-0708 <at> mike.de> wrote:

Since you've already installed MinGW, you're much better off
compiling Lua yourself. A "make mingw" takes a few seconds.

Yes I already tried this. It didn't help. :( I was simplifying the example so people could build it easier.

Try the standard compile first. If this doesn't work then try
adding -fexceptions. Or try compiling Lua with the C++ compiler.

 How do I compile Lua with the C++ compiler. I include a lua.hpp that extern C's the files, so I think I already am. I will try adding the -fexceptions flag tomorrow.

Or compile your C++ code without exception handling. :-)

I can't do this. My entire re-use library uses exception.

Some permutation of this will make it work. That is ... until
someone strips the binaries or ... anyway, excuse my rant.

Well that is OK, I just need this to work. It is crazy that all my other code works fine, but all of it has been C++ code, not C.
--
Regards,
Ryan
RJP Computing
Tom Miles | 1 Aug 10:49
Picon

"Require" in a sandboxed environment

Hi there,
 
I have had lua integrated into my project quite successfully for a while now.  I have lots of objects each with their own states spawned off a main state and running in a sandboxed environment to avoid global variables clashes.  Some of the objects have enough shared functionality that I have started to divide code up into modules and use "require" to import the functionality back in.  However, I started to run into problems when the modules needed to store some sort of state.  Now, my understanding of how modules work is that a module is loaded into a table, stored in a "packages" table, then a copy is also stored in the globals table of the enviornment it is loaded into, and another copy returned which can be stored in a differently named variable by the code calling require if desired.  As lua doesn't work with references, if the module has a variable within it, then there will now by potentially 3 different copies of this variable.  If this module is "require"d in 2 seperate environments then you will have 5 copies, 1 in "packages", 1 in each of the environments globals table, and the locally stored versions if used.  This way you cannot share data between the 2 different environments as they will use different versions of the module.  Am I correct so far?
 
Working on this assumption I wrote my own require functionality in a module thus:
 
function Require(pack)
        require(pack)
        local t = {}
        local mt = { __index = function(t,k) return package.loaded[pack][k] end }
        setmetatable(t, mt)
        return t
end
 
The idea behind this is that we return a proxy table that always references the table in package.loaded.  If we never use the global instance, and only use the returned table then we will only ever reference the copy stored in package.loaded, thus all environments using the module will share the same one, and only 1 copy of the data is ever used.  This will only work however if there is only ever one version of "package" shared across all the environments.  Is this the case?  My system seems to work in some cases but not in others, so I'm guessing there is a hole in my logic somewhere.  Can anyone point out what I might be doing wrong?
 
Thanks in advance,
 
Tom

DISCLAIMER
This email is sent by The Creative Assembly Limited company No. 03425917, registered in England & Wales registered office 27 Great West Road, Middlesex, TW8 9BW, England. The contents of this e-mail and any attachments are confidential to the intended recipient and may also be legally privileged. Unless you are the named addressee (or authorised to receive for the addressee) of this email you may not copy, disclose or distribute it to anyone else. If you have received this email in error, please notify us immediately by e-mail on postmaster <at> creative-assembly.co.uk and then delete the email and any copies. The Creative Assembly Limited have made all reasonable efforts to ensure that this e-mail and any attached documents or software are free from software viruses, but it is the recipient's responsibility to confirm this.
       

Stephen Kellett | 1 Aug 12:17
Picon
Picon
Favicon

Re: bug

Roberto Ierusalimschy wrote:
> Mike Pall just reported the following bug:

Just a suggestion, could future posts like this have a more informative 
subject? If you post them all with the subject "bug" they will all get 
confused with each other. This could easily have been posted with the 
subject "bug: parser causes stack overflow".

Then any replies are identified as replies to that and that only, rather 
than to the similarly named "bug" which deals with strawberries being 
found in the blueberry muffin compiler.

Stephen

Picon
Picon

Re: bug (really: assignment parser stack overflow)

> Gee .. a really cute cut'n'paste error which completely changes
> the semantics. Umm, Roberto, this needs a space or semicolon at
> the end of "local a ". My original mail included the space. :-)

You are completely right. Sorry about the mistake.

-- Roberto

Duncan Cross | 1 Aug 13:15
Picon

Re: "Require" in a sandboxed environment

On 8/1/07, Tom Miles <Tom <at> creative-assembly.co.uk> wrote:

Now, my understanding of how modules work is that a module is loaded into a table, stored in a "packages" table, then a copy is also stored in the globals table of the enviornment it is loaded into, and another copy returned which can be stored in a differently named variable by the code calling require if desired.  As lua doesn't work with references, if the module has a variable within it, then there will now by potentially 3 different copies of this variable.

Nope, Lua DOES use references, all three will be references to the same table. It sounds like there is must be some other problem if you are requiring packages from several environments created from the same original main state and they all seem to be getting a new version each time, the package system uses the shared registry table. Do you have a simple example of one of the modules you are using?

Gmane