Wireshark-bugs: [Wireshark-bugs] [Bug 12968] New: Lua metatable problems (__gc being invoked for

Date: Sat, 01 Oct 2016 11:10:33 +0000
Bug ID 12968
Summary Lua metatable problems (__gc being invoked for table types)
Product Wireshark
Version Git
Hardware All
OS All
Status UNCONFIRMED
Severity Major
Priority Low
Component Common utilities (libwsutil)
Assignee [email protected]
Reporter [email protected]
CC [email protected]

Build Information:
TShark (Wireshark) 2.3.0 (v2.3.0rc0-880-gfdbf443 from master)

Copyright 1998-2016 Gerald Combs <[email protected]> and contributors.
License GPLv2+: GNU GPL version 2 or later
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiled (64-bit) with libpcap, with POSIX capabilities (Linux), with libnl 3,
with GLib 2.48.2, with zlib 1.2.8, without SMI, with c-ares 1.11.0, with Lua
5.2.4, with GnuTLS 3.4.15, with Gcrypt 1.7.3, with MIT Kerberos, with GeoIP.

Running on Linux 4.7.2-1-ARCH, with Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
(with SSE4.2), with 31996 MB of physical memory, with locale en_GB.UTF-8, with
libpcap version 1.7.4, with GnuTLS 3.4.15, with Gcrypt 1.7.3, with zlib 1.2.8.

Built using gcc 6.2.1 20160830.

--
On exiting Wireshark, surprisingly lua_error is raised during garbage
collection (for instance, TvbRange__gc). This can be reproduced with an empty
pcap and a simple Lua dissector.

The problem is that all classes are registered as a table with metatables set
on both the class instances (OK) and the class table itself (bad). Metamethods
like __gc and __tostring only make sense for the class instances, not the class
itself. The only metamethod that remotely makes sense for class methods is
__call (and maybe in weird cases __index and __newindex?).

Proposal: use two different metatables for instances and class methods.
This also removes the limitation of one __call function. Instead of:

    field = Field.new("some.field")
    fieldinfos = field()

we could add a new __call method that enables:

    field = Field("some.field")
    fieldinfos = field()

As a bonus, weird things like Tvb() (instead of tvb()) will also not be
possible anymore. This will change the API, but should not affect many as you
would have to be a special user that introspects via __metatable.


You are receiving this mail because:
  • You are watching all bug changes.