lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Aug 25, 2011 at 11:14:43PM +0200, Luis Carvalho wrote:
> > I made a 5.1 and a 5.2 version, both doing this:
> > 
> >     > A=matrix{{1,2,3},{4,5,6}}
> >     > =A:pinv()
> >     Segmentation fault
> It's hard to guess without details on your platform and libs, 

Ubuntu 11.4, kept up to date by `aptitude safe-upgrade` up to 
  17 July 2011.

libatlas-dev   3.8.3-29  (two other atlas libraries at the same version)

$ gcc -v
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=i386-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/i386-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/i386-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) 

> [1] Try building your own ATLAS lib  
And do this every time I upgrade Ubuntu?  

> "GCC's violation of the x86 ABI causes seg faults/bus errors when mixed with
> other compilers", for more information.
I followed the link from there.  Over my head, frankly, but nevertheless
fascinating.  The guys discussing the topic were real experts who quietly 
opted out the moment the public started chipping in.  

But surely Ubuntu's libatlas is compiled by gcc?  So no other compilers
in my case? 

> [2] The other solution is to specify LUAI_USER_ALIGNMENT_T 
> to attain the 8-byte boundary in luaconf.h. Minimal change:
> #define LUAI_USER_ALIGNMENT_T union { double u[3]; void *s; long l; }
Would I need to rebuild my Lua or only the NumLua package?

> While you're at it, you might as well patch llex.c with your favorite
> extension -- short lambda! -- or add token filters. :)
Not I — I'm a Lua puritan. 

> Another straightforward solution -- and a quick way to know if your problem
> is memory alignment -- is to use LuaJIT since it guarantees 8-byte aligned
> userdata. 

This works.

I have tried to narrow down the problem, and can also offer this: if 
run the code several times with various matrices, I get quite a nice 
spectrum of error messages:

  Sementation fault

  lua: malloc.c:4631:  _int_malloc: Assertion `(unsigned long)(size) >= (unsigned long)(nb)' failed.

  ** On entry to DGESVD parameter number 11 had an illegal value

  *** glibc detected *** lua5.2: malloc(): memory corruption: 0x09fb0a40 ***

  not enough memory

(the last of these does not crash the Lua interpreter)

Moreover, the following other routines also have this problem:

    cond qr svd rank

These are obviously related: cond and rank call svd at the matrix.lua
level, and qr and svd, though calling different LAPACK routines, make
heavy use of Householder reflections.

Luajit works on all of them.  Unfortunately for the quest towards scientific
truth, that fact kills my enthusiasm for finding the cause in the case of
standard Lua.