"attempt to index global 'base' (a nil value)" - Wireshark 3.6.2-2
Hi!
I am using a custom dissector in conjunction with Nordic's nRF BLE Sniffer tooling. In my installation scripts, I have pinned the Wireshark version to 3.6.2-2 because of some of the differences between how Nordic's tooling operates and some differences between Lua 5.2 and 5.4. On Ubuntu 22.04 I keep getting the error "attempt to index global 'base' (a nil value)" when using base.DEC, base.HEX in my dissector code.
To successfully install this version, I install the following packages from apt:
- wireshark=3.6.2-2
- wireshark-qt=3.6.2-2
- wireshark-dev=3.6.2-2
- wireshark-common=3.6.2-2
Any ideas why the definition for "base" is missing from my installation?
Thanks!
Do you have a small piece of code that shows the issue?
Hi Chuck,
This code throws the error on my installation of 3.6.2-2:
Here is the error:
The same code does not have any issues loading in the latest apt version 4.4.0.
Thanks!
(sample capture attached to 18267: Assertion due to incorrect mask for btatt.battery_power_state.)
Works on Windows:
Version 3.6.2 (v3.6.2-0-g626020d9b3c3)Will need to build on Ubuntu to see if I can recreate issue.
local my_proto = Proto("my_dissector", "My Dissector") local device_type = ProtoField.uint8("my_proto.test", "test", base.DEC) local device_hex = ProtoField.uint8("my_proto.test_hex", "test", base.HEX) my_proto.fields = { device_type, device_hex } function my_proto.dissector(buffer, pinfo, tree) -- Custom dissector code here subtree = tree:add(my_proto) subtree:add(device_type, 10) subtree:add(device_hex, 10) end local btatt_table = DissectorTable.get("btatt.handle") btatt_table:add("0-200", my_proto)I believe that 3.6 needs an init.lua file to load some of the globals, it was before this commit: https://gitlab.com/wireshark/wireshar...
If the difference between Lua 5.2 and 5.4 is the issue, can you use Wireshark 4.0 or 4.2, both of which use Lua 5.2. Wireshark 3.6 is no longer supported, but 4.2 is.
btattfails on 3.6.2 but the dissector works withregister_postdissector(my_proto)My Dissector test: 10 test: 0x0aprint("base[DEC]: " .. base["DEC"]) print("base[HEX]: " .. base["HEX"]) --[[ Evaluated --]] Tue 15 Oct 2024 08:06:51 AM CDT Console opened Tue 15 Oct 2024 08:07:12 AM CDT base[DEC]: 1 Tue 15 Oct 2024 08:07:12 AM CDT base[HEX]: 2From
init.lua:-- Display Bases base = { ["NONE"] = 0, -- none ["DEC"] = 1, -- decimal ["HEX"] = 2, -- hexadecimal ["OCT"] = 3, -- octalPerhaps
init.luais not being loaded on your system per @johnthacker comment above?