You are not logged in.

#1 2011-11-13 01:55:37

endeavor
Member
Registered: 2011-10-28
Posts: 9

lua malloc errors

Not sure where this topic belongs. Please move it accordingly.

I'm working on a fairly large project making use of lua, and was getting weird memory corruption bugs I was having issues tracking down. It looked like these bugs were coming from lua, but I was somewhat in disbelief.

Then I ran this:

valgrind -v lua -e "print('hi')"

For a bit of clarity, I compiled the latest lua so I would have some symbols:

valgrind -v ./lua -e "print('hi')"
==2277== Memcheck, a memory error detector
==2277== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2277== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==2277== Command: ./lua -e print('hi')
==2277== 

... omitted for brevity ...

==2277== Invalid read of size 8
==2277==    at 0x59DB6C1: ??? (in /lib/libc-2.14.1.so)
==2277==    by 0x59C362D: fputs (in /lib/libc-2.14.1.so)
==2277==    by 0x417267: luaB_print (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40852B: luaD_precall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x411A47: luaV_execute (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40893C: luaD_call (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x407BF6: luaD_rawrunprotected (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x408AD1: luaD_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x4061FE: lua_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x4043E5: docall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40447D: dostring (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x404986: pmain (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==  Address 0x5cf5398 is 24 bytes inside a block of size 27 alloc'd
==2277==    at 0x4C2740D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2277==    by 0x4C27597: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2277==    by 0x40A97B: luaM_realloc_ (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40E565: luaS_newlstr (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x415B31: luaX_newstring (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x415F52: llex (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x416828: luaX_next (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40C23F: funcargs (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40C445: primaryexp (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40C533: chunk (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40DCE4: luaY_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x407F6F: f_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277== 
hi
==2277== 
==2277== HEAP SUMMARY:
==2277==     in use at exit: 0 bytes in 0 blocks
==2277==   total heap usage: 430 allocs, 430 frees, 33,475 bytes allocated
==2277== 
==2277== All heap blocks were freed -- no leaks are possible
==2277== 
==2277== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 6 from 6)
==2277== 
==2277== 2 errors in context 1 of 1:
==2277== Invalid read of size 8
==2277==    at 0x59DB6C1: ??? (in /lib/libc-2.14.1.so)
==2277==    by 0x59C362D: fputs (in /lib/libc-2.14.1.so)
==2277==    by 0x417267: luaB_print (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40852B: luaD_precall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x411A47: luaV_execute (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40893C: luaD_call (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x407BF6: luaD_rawrunprotected (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x408AD1: luaD_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x4061FE: lua_pcall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x4043E5: docall (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40447D: dostring (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x404986: pmain (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==  Address 0x5cf5398 is 24 bytes inside a block of size 27 alloc'd
==2277==    at 0x4C2740D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2277==    by 0x4C27597: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2277==    by 0x40A97B: luaM_realloc_ (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40E565: luaS_newlstr (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x415B31: luaX_newstring (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x415F52: llex (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x416828: luaX_next (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40C23F: funcargs (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40C445: primaryexp (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40C533: chunk (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x40DCE4: luaY_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277==    by 0x407F6F: f_parser (in /home/endeavor/source/lua-5.1.4/src/lua)
==2277== 
--2277-- 
--2277-- used_suppression:      4 U1004-ARM-_dl_relocate_object
--2277-- used_suppression:      2 glibc-2.5.x-on-SUSE-10.2-(PPC)-2a
==2277== 
==2277== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 6 from 6)

I am unsure of where to go from here. I get these errors both in 64 and 32-bit Arch. Another user in the #lua channel using gentoo does not have these errors, which leads me to believe this is an arch-specific issue.

Can someone smarter than myself shed some light on this? It looks like lua, for some reason, isn't playing nice with Arch's glibc. I'm leaning towards perhaps this is an Arch glibc issue, but not sure.

Offline

#2 2011-12-03 23:53:32

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: lua malloc errors

I'm running a couple of lua scripts which import files into NoteCase Pro. These scripts always stall (about 2/3 of the way through) on Arch when I import a large number of files (say more than 500), but they work when I import the files in smaller batches (so not a data problem). The same scripts work on Windows XP and other Linux distros tried, but always stall on Arch so that the NoteCase process has to be killed.

So, your suspicion about Lua problems and Arch is very interesting, and I have also been in touch with the author of NoteCase Pro to discount other possibilties.
May try as you have done and experiment with Valgrind a bit.

Offline

#3 2011-12-04 22:17:56

mrspin
Member
Registered: 2008-02-16
Posts: 14

Re: lua malloc errors

I've been seeing the exact same trace in my stuff (and not using the Arch built lua). They even happen in my old builds where I know they didn't happen.

Offline

#4 2011-12-04 22:40:10

mrspin
Member
Registered: 2008-02-16
Posts: 14

Re: lua malloc errors

Downgrading from glibc-2.14-6 to glibc-2.14-5 seems to fix them

Offline

Board footer

Powered by FluxBB