Tk Source Code

View Ticket
Login
Ticket UUID: b305ee09b16d3ff3857985f0fefd91004d2e08fd
Title: valgrind reports that Conditional jump or move depends on uninitialised value(s)
Type: Bug Version: trunk
Submitter: fvogel Created on: 2023-09-03 10:21:26
Subsystem: 99. Other Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-09-03 10:36:37
Resolution: Fixed Closed By: fvogel
    Closed on: 2023-09-03 10:36:37
Description:

With a -DPURIFY build, running tclsh 8.7 under valgrind and then package require Tk, valgrind reports several times the same "Conditional jump or move depends on uninitialised value(s)":

francois@debian:~/Documents/tcltk/fossil/tcltk/bin$ valgrind --tool=memcheck --leak-check=full  /home/francois/Documents/tcltk/fossil/tcltk/bin/tclsh8.7
==31398== Memcheck, a memory error detector
==31398== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31398== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==31398== Command: /home/francois/Documents/tcltk/fossil/tcltk/bin/tclsh8.7
==31398== 
% package require Tk
8.7a6
% ==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925825: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x49DA5EF: Tcl_DoOneEvent (tclNotify.c:943)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398==    by 0x49D261D: Tcl_MainEx (tclMain.c:561)
==31398==    by 0x1091E0: main (tclAppInit.c:94)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925825: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x6A44EE3: TkUnixDoOneXEvent (tkUnixEvent.c:627)
==31398==    by 0x6A644FB: WaitForEvent (tkUnixWm.c:5314)
==31398==    by 0x6A647BE: WaitForMapNotify (tkUnixWm.c:5419)
==31398==    by 0x6A5A733: TkWmMapWindow (tkUnixWm.c:772)
==31398==    by 0x6953138: Tk_MapWindow (tkWindow.c:1762)
==31398==    by 0x69643CC: MapFrame (tkFrame.c:1905)
==31398==    by 0x4A0D616: TclServiceIdle (tclTimer.c:751)
==31398==    by 0x49DA750: Tcl_DoOneEvent (tclNotify.c:1020)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925831: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x6A44EE3: TkUnixDoOneXEvent (tkUnixEvent.c:627)
==31398==    by 0x6A644FB: WaitForEvent (tkUnixWm.c:5314)
==31398==    by 0x6A647BE: WaitForMapNotify (tkUnixWm.c:5419)
==31398==    by 0x6A5A733: TkWmMapWindow (tkUnixWm.c:772)
==31398==    by 0x6953138: Tk_MapWindow (tkWindow.c:1762)
==31398==    by 0x69643CC: MapFrame (tkFrame.c:1905)
==31398==    by 0x4A0D616: TclServiceIdle (tclTimer.c:751)
==31398==    by 0x49DA750: Tcl_DoOneEvent (tclNotify.c:1020)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925825: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x695408E: TkDoConfigureNotify (tkWindow.c:2326)
==31398==    by 0x6A62407: ConfigureEvent (tkUnixWm.c:4162)
==31398==    by 0x6A62D6C: WrapperEventProc (tkUnixWm.c:4499)
==31398==    by 0x6925BC7: Tk_HandleEvent (tkEvent.c:1285)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x6A44EE3: TkUnixDoOneXEvent (tkUnixEvent.c:627)
==31398==    by 0x6A644FB: WaitForEvent (tkUnixWm.c:5314)
==31398==    by 0x6A647BE: WaitForMapNotify (tkUnixWm.c:5419)
==31398==    by 0x6A5A733: TkWmMapWindow (tkUnixWm.c:772)
==31398==    by 0x6953138: Tk_MapWindow (tkWindow.c:1762)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925831: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x695408E: TkDoConfigureNotify (tkWindow.c:2326)
==31398==    by 0x6A62407: ConfigureEvent (tkUnixWm.c:4162)
==31398==    by 0x6A62D6C: WrapperEventProc (tkUnixWm.c:4499)
==31398==    by 0x6925BC7: Tk_HandleEvent (tkEvent.c:1285)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x6A44EE3: TkUnixDoOneXEvent (tkUnixEvent.c:627)
==31398==    by 0x6A644FB: WaitForEvent (tkUnixWm.c:5314)
==31398==    by 0x6A647BE: WaitForMapNotify (tkUnixWm.c:5419)
==31398==    by 0x6A5A733: TkWmMapWindow (tkUnixWm.c:772)
==31398==    by 0x6953138: Tk_MapWindow (tkWindow.c:1762)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925825: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x6A44C63: TkUnixDoOneXEvent (tkUnixEvent.c:552)
==31398==    by 0x6A644FB: WaitForEvent (tkUnixWm.c:5314)
==31398==    by 0x6A647BE: WaitForMapNotify (tkUnixWm.c:5419)
==31398==    by 0x6A5A733: TkWmMapWindow (tkUnixWm.c:772)
==31398==    by 0x6953138: Tk_MapWindow (tkWindow.c:1762)
==31398==    by 0x69643CC: MapFrame (tkFrame.c:1905)
==31398==    by 0x4A0D616: TclServiceIdle (tclTimer.c:751)
==31398==    by 0x49DA750: Tcl_DoOneEvent (tclNotify.c:1020)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925831: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x6A44C63: TkUnixDoOneXEvent (tkUnixEvent.c:552)
==31398==    by 0x6A644FB: WaitForEvent (tkUnixWm.c:5314)
==31398==    by 0x6A647BE: WaitForMapNotify (tkUnixWm.c:5419)
==31398==    by 0x6A5A733: TkWmMapWindow (tkUnixWm.c:772)
==31398==    by 0x6953138: Tk_MapWindow (tkWindow.c:1762)
==31398==    by 0x69643CC: MapFrame (tkFrame.c:1905)
==31398==    by 0x4A0D616: TclServiceIdle (tclTimer.c:751)
==31398==    by 0x49DA750: Tcl_DoOneEvent (tclNotify.c:1020)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925825: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x6A62FE9: WrapperEventProc (tkUnixWm.c:4522)
==31398==    by 0x6925BC7: Tk_HandleEvent (tkEvent.c:1285)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x6A44EE3: TkUnixDoOneXEvent (tkUnixEvent.c:627)
==31398==    by 0x6A644FB: WaitForEvent (tkUnixWm.c:5314)
==31398==    by 0x6A647BE: WaitForMapNotify (tkUnixWm.c:5419)
==31398==    by 0x6A5A733: TkWmMapWindow (tkUnixWm.c:772)
==31398==    by 0x6953138: Tk_MapWindow (tkWindow.c:1762)
==31398==    by 0x69643CC: MapFrame (tkFrame.c:1905)
==31398==    by 0x4A0D616: TclServiceIdle (tclTimer.c:751)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925831: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x49DA5EF: Tcl_DoOneEvent (tclNotify.c:943)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398==    by 0x49D261D: Tcl_MainEx (tclMain.c:561)
==31398==    by 0x1091E0: main (tclAppInit.c:94)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925825: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x49DA733: Tcl_DoOneEvent (tclNotify.c:1007)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398==    by 0x49D261D: Tcl_MainEx (tclMain.c:561)
==31398==    by 0x1091E0: main (tclAppInit.c:94)
==31398== 
==31398== Conditional jump or move depends on uninitialised value(s)
==31398==    at 0x6925831: Tk_HandleEvent (tkEvent.c:1145)
==31398==    by 0x69265DA: WindowEventProc (tkEvent.c:1738)
==31398==    by 0x49DA2F3: Tcl_ServiceEvent (tclNotify.c:710)
==31398==    by 0x49DA733: Tcl_DoOneEvent (tclNotify.c:1007)
==31398==    by 0x6926C1C: Tk_MainLoop (tkEvent.c:2124)
==31398==    by 0x49D261D: Tcl_MainEx (tclMain.c:561)
==31398==    by 0x1091E0: main (tclAppInit.c:94)
==31398== 

% 

User Comments: fvogel added on 2023-09-03 10:36:37:

This does not happen with core-8-6-branch, only with trunk. It was introduced by the implementation of TIP #474 in [7c9e1f47a8].

XEvent is an union, and before using e.g. eventPtr->xbutton.button, the event type needs to be checked, otherwise for event types other than ButtonPress and ButtonRelease, we get the warning reported by valgrind.

Therefore the fix: [c0067caa76]