Wireshark-bugs: [Wireshark-bugs] [Bug 7400] Update Lua from 5.1 to 5.2
Date: Thu, 12 Jul 2012 01:46:12 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7400

--- Comment #10 from Tony Trinh <tony19@xxxxxxxxx> 2012-07-12 01:46:11 PDT ---
Bug to be found...

The checked-in modifications that work in *NIX are causing a Lua-panic at
startup in Windows. That is, when tshark.exe/wireshark.exe starts, you'll see
this message followed by the exiting of the process:

 PANIC: unprotected error in call to Lua API (error in __gc metamethod (bad
argument #1 to '?' (Pref expected, got table)))

Another variation of the message is:

 PANIC: unprotected error in call to Lua API (error in __gc metamethod (bad
argument #1 to '?' (userdata expected, got table)))

(FYI, I'm using Windows 7 (32-bit) in a Virtual Box VM, along with VC++ 2010EE)

Setup instructions:

 1. Download the Lua 5.2 binaries for your Windows system, and unzip it.
 2. In config.nmake, set LUA_DIR to your Lua 5.2 binaries directory. 
 3. In Makefile.nmake, comment out the lines that download the Lua binaries
during the build-setup:

  @$(SH) $(WIN_SETUP) "$(WIN_SETUP_OPT)" "$(WIRESHARK_LIB_DIR)" \
        lua$(LUA_VER) lua$(LUA_DIST)_lib.zip

 4. Build Wireshark.
 5. From VC++ 2010EE, choose menu "File > Open > Project/Solution"
(CTRL+SHIFT+O), and select ${src}/wireshark-gtk2/tshark.exe (wireshark.exe is
too slow for debugging purposes).
 6. Start the debugger (F5).

After running the debugger above, you'll likely hit a break in
Address_register() (or one of the other functions called by
wslua_register_classes()), which is misleading since the panic output indicates
the "Pref" class (not "Address"). The actual location of the panic is in
checkPref() called by Pref_gc() (wslua_proto.c). checkPref()'s job is to pull a
userdata off the Lua stack, and return it as a casted pointer to Pref, but it
panics when it doesn't see a userdata on the Lua stack. Somehow it sees a table
instead.

If you comment out Pref_gc(), the panic goes away, and tshark starts happily
(obviously not desirable but helps in narrowing in on the bug). Note the error
is occurring at initialization (during which there should be no GC) and not
during the run of any Lua script. On the bright side, the error is consistently
repeatable.

I'm having trouble debugging this, so I'm hoping someone else can take a look.
Any Lua bravehearts in the house?

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.