[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Crash in luaL_loadfile in 64-bit x86_64
- From: "E. Wing" <ewmailing@...>
- Date: Fri, 16 Oct 2009 13:49:06 -0700
I have a semi-reproducible crash in Lua running in 64-bit x86_64 on
Snow Leopard.
When it crashes, I get a:
Program received signal: “EXC_BAD_ACCESS”.
at this line:
while (gnext(othern) != mp) othern = gnext(othern); /* find previous */
in the internal Lua function:
static TValue *newkey (lua_State *L, Table *t, const TValue *key)
(othern seems to be NULL which I think is related to the crash.)
It only seems to crash in 64-bit mode for me. I have not experienced
any problems in 32-bit mode.
What's very strange is that if I make minor changes to my Lua script,
such as deleting a line or changing a few things around, my program
may or may not crash the next time around. But once I have a script
that triggers the crash, it always seems to be reproducible with that
exact same script.
I gutted my program reduced it to a bare minimum where I have no
custom code except to get the file path to load my lua script. So I
have ruled out my application code. I also tried gcc 4.0, gcc 4.2 and
Clang 1.0 in both debug and release modes, and they all have the same
behavior so I think I can rule out a compiler bug.
I did modify luaconf.h for 64-bit, which might be related to my
problems. Since I needed to be able to hold 64-bit numbers, I changed
lua_Number to long double. It's possible I forgot to change something
else I'm required to change. This is my diff -u of luaconf.h.
--- /Users/ewing/Downloads/lua-5.1.4/src/luaconf.h 2008-02-11
08:25:08.000000000 -0800
+++ luaconf.h 2009-10-16 12:21:04.000000000 -0700
@@ -501,9 +501,13 @@
** ===================================================================
*/
+#if __LP64__
+#define LUA_NUMBER_LDOUBLE
+#define LUA_NUMBER long double
+#else
#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER double
-
+#endif
/*
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number.
@@ -518,8 +522,14 @@
@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
@@ lua_str2number converts a string to a number.
*/
+#ifdef LUA_NUMBER_LDOUBLE
+#define LUA_NUMBER_SCAN "%Lg"
+#define LUA_NUMBER_FMT "%.20Lg"
+#else
#define LUA_NUMBER_SCAN "%lf"
#define LUA_NUMBER_FMT "%.14g"
+#endif
+
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
#define lua_str2number(s,p) strtod((s), (p))
I am really stumped by this crash. I would really appreciate any
help/insights on this.
I have uploaded my simplified reproducible crashing project to
http://www.assembla.com/spaces/LuaCocoa/documents/aa1N0SUO8r3RGweJe5aVNr/download/Lua64bitcrash.tar.gz
It includes the Lua source and builds it as a static library which
links into my test program.
I also include my backtrace below.
Thanks,
Eric
(gdb) bt
#0 0x0000000100015ccf in newkey (L=0x100110e60, t=0x10011d730,
key=0x7fff5fbfe920) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ltable.c:412
#1 0x0000000100016193 in luaH_setstr (L=0x100110e60, t=0x10011d730,
key=0x10011e190) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ltable.c:527
#2 0x000000010000e356 in luaX_newstring (ls=0x7fff5fbfef30,
str=0x10011e041 "NSPoint.x, NSPoint.y\"ataon\"ata\"urn' value='0'>
is:\"\"33", '0' <repeats 11 times>, "4'> is:\"48'> is:\"", l=20) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:120
#3 0x000000010000f262 in read_string (ls=0x7fff5fbfef30, del=34,
seminfo=0x7fff5fbfef50) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:327
#4 0x000000010000f855 in llex (ls=0x7fff5fbfef30,
seminfo=0x7fff5fbfef50) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:391
#5 0x000000010000fbca in luaX_next (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:453
#6 0x0000000100012651 in funcargs (ls=0x7fff5fbfef30,
f=0x7fff5fbfec00) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:618
#7 0x000000010001292f in primaryexp (ls=0x7fff5fbfef30,
v=0x7fff5fbfec00) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:718
#8 0x0000000100013c5a in exprstat (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:1228
#9 0x0000000100013f9f in statement (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:1318
#10 0x0000000100013fd2 in chunk (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:1330
#11 0x0000000100011db4 in luaY_parser (L=0x100110e60,
z=0x7fff5fbff1e0, buff=0x7fff5fbff188, name=0x1004013a8
"@/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:391
#12 0x000000010000b083 in f_parser (L=0x100110e60, ud=0x7fff5fbff180)
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:497
#13 0x0000000100009b0b in luaD_rawrunprotected (L=0x100110e60,
f=0x10000aff2 <f_parser>, ud=0x7fff5fbff180) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:116
#14 0x000000010000af38 in luaD_pcall (L=0x100110e60, func=0x10000aff2
<f_parser>, u=0x7fff5fbff180, old_top=64, ef=0) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:463
#15 0x000000010000b1cc in luaD_protectedparser (L=0x100110e60,
z=0x7fff5fbff1e0, name=0x1004013a8
"@/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:513
#16 0x000000010000360c in lua_load (L=0x100110e60, reader=0x100004f6e
<getF>, data=0x7fff5fbff250, chunkname=0x1004013a8
"@/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lapi.c:869
#17 0x00000001000052d4 in luaL_loadfile (L=0x100110e60,
filename=0x100400fd0
"/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lauxlib.c:581
#18 0x00000001000013e9 in main (argc=1, argv=0x7fff5fbff6d8) at
/Users/ewing/Source/HG/Lua64bitcrash/Xcode/../Test/main.m:28
(gdb)
#0 0x0000000100015ccf in newkey (L=0x100110e60, t=0x10011d730,
key=0x7fff5fbfe920) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ltable.c:412
#1 0x0000000100016193 in luaH_setstr (L=0x100110e60, t=0x10011d730,
key=0x10011e190) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ltable.c:527
#2 0x000000010000e356 in luaX_newstring (ls=0x7fff5fbfef30,
str=0x10011e041 "NSPoint.x, NSPoint.y\"ataon\"ata\"urn' value='0'>
is:\"\"33", '0' <repeats 11 times>, "4'> is:\"48'> is:\"", l=20) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:120
#3 0x000000010000f262 in read_string (ls=0x7fff5fbfef30, del=34,
seminfo=0x7fff5fbfef50) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:327
#4 0x000000010000f855 in llex (ls=0x7fff5fbfef30,
seminfo=0x7fff5fbfef50) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:391
#5 0x000000010000fbca in luaX_next (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/llex.c:453
#6 0x0000000100012651 in funcargs (ls=0x7fff5fbfef30,
f=0x7fff5fbfec00) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:618
#7 0x000000010001292f in primaryexp (ls=0x7fff5fbfef30,
v=0x7fff5fbfec00) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:718
#8 0x0000000100013c5a in exprstat (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:1228
#9 0x0000000100013f9f in statement (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:1318
#10 0x0000000100013fd2 in chunk (ls=0x7fff5fbfef30) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:1330
#11 0x0000000100011db4 in luaY_parser (L=0x100110e60,
z=0x7fff5fbff1e0, buff=0x7fff5fbff188, name=0x1004013a8
"@/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lparser.c:391
#12 0x000000010000b083 in f_parser (L=0x100110e60, ud=0x7fff5fbff180)
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:497
#13 0x0000000100009b0b in luaD_rawrunprotected (L=0x100110e60,
f=0x10000aff2 <f_parser>, ud=0x7fff5fbff180) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:116
#14 0x000000010000af38 in luaD_pcall (L=0x100110e60, func=0x10000aff2
<f_parser>, u=0x7fff5fbff180, old_top=64, ef=0) at
/Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:463
#15 0x000000010000b1cc in luaD_protectedparser (L=0x100110e60,
z=0x7fff5fbff1e0, name=0x1004013a8
"@/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/ldo.c:513
#16 0x000000010000360c in lua_load (L=0x100110e60, reader=0x100004f6e
<getF>, data=0x7fff5fbff250, chunkname=0x1004013a8
"@/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lapi.c:869
#17 0x00000001000052d4 in luaL_loadfile (L=0x100110e60,
filename=0x100400fd0
"/Users/ewing/Source/HG/Lua64bitcrash/Xcode/build/Debug/TestApp.app/Contents/Resources/test.lua")
at /Users/ewing/Source/HG/Lua64bitcrash/lua/Xcode/../src/lauxlib.c:581
#18 0x00000001000013e9 in main (argc=1, argv=0x7fff5fbff6d8) at
/Users/ewing/Source/HG/Lua64bitcrash/Xcode/../Test/main.m:28