Wireshark-bugs: [Wireshark-bugs] [Bug 3090] New: LUA script : WireShark crashes after closing an
Date: Fri, 28 Nov 2008 00:58:48 -0800 (PST)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3090

           Summary: LUA script : WireShark crashes after closing and opening
                    again a window used by a listener.draw() function.
           Product: Wireshark
           Version: 1.0.4
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Low
         Component: Wireshark
        AssignedTo: wireshark-bugs@xxxxxxxxxxxxx
        ReportedBy: philippe.alarcon@xxxxxxx


Build Information:
Version 1.0.4 (SVN Rev 26501)

Copyright 1998-2008 Gerald Combs <gerald@xxxxxxxxxxxxx> and contributors.

Compiled with GTK+ 2.12.8, with GLib 2.14.6, with WinPcap (version unknown),
with libz 1.2.3, without POSIX capabilities, with libpcre 7.0, with SMI 0.4.8,
with ADNS, with Lua 5.1, with GnuTLS 2.3.8, with Gcrypt 1.4.1, with MIT
Kerberos, with PortAudio V19-devel, with AirPcap.

Running on Windows XP Service Pack 2, build 2600, with WinPcap version 4.0.2
(packet.dll version 4.0.0.1040), based on libpcap version 0.9.5, without
AirPcap.

Built using Microsoft Visual C++ 6.0 build 8804
--
Overview :
After closing and opening again a window accessed by a listener.draw()
function, WireShark crashes and generates an exception.


Bug description :

Load the following LUA script :
-----------------------------------------------------------------
function Counting_Packets()
   local count = 0
   local m_w
   local b_m_w = 0

   -- Create Melodhy tap
   local m_tap = Listener.new()

   -- Function used to remove tap
   function m_w_close()
      m_tap:remove()
      b_m_w = 0
   end

   -- Create a window
   if(b_m_w == 0) then
      m_w = TextWindow.new(" Counting packets")
      m_w:set_atclose(m_w_close)
      b_m_w = 1
   end

   -- Function called for each packet
   function m_tap.packet(pinfo,tvb)
      count = count + 1
   end

   -- Function used every few seconds to update the window
   function m_tap.draw(t)
      if(b_m_w == 1) then
         m_w:clear()
         m_w:append("\nCounted packets : " .. count)
      end
   end

   -- Function called to reset displayed information
   function m_tap.reset()
      if(b_m_w == 1) then
         m_w:clear()
      end
   end
end

-- Build Tools menu
register_menu("Counting", Counting_Packets, MENU_TOOLS)
------------------------------------------------------------------

Script description :
The aim of this simple script, is to count the packets number of a capture
file.
The function Counting_Packets() is registered as a menu.
This function creates a listener (tap) and a window.
The number of packets is counted using tap.packet() function.
The counting result is displayed in the window using the tap.draw() function.
The tap is removed when closing the window.

Steps to reproduce :
Activating the new menu, create the window.
When loading a capture file, the packets are counted correctly.
You close the capture file.
You close the window.
Then you activate again the menu and the window is created again.
When loading a capture file (the same file or another), WireShark crashes,
and generates an exception.

Notes :
I have made several tests.
It seems that the problem is linked to the window accessed by the tap.draw()
function.
Even when the tap is removed, and the window closed,
it seems that the new window structure is not correctly referenced by the
tap.draw() function.

When I use a window within tap.packet() function,
the window can be closed and re-open again without problem.

Environment :
I use WireShark 1.0.4 under Windows XP.


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