I can't reproduce on windows, 
I will have a closer look on ubuntu later.

Can you also try w/o stubs?

Thanks!

-----Original Message-----
From: Christopher Chavez <chrischa...@gmx.us> 
Sent: Sunday, March 8, 2020 7:02 AM
To: tcltk@perl.org
Subject: Possible bug in Tcl.pm exposed by Tktable?


[EXTERNAL EMAIL] 

Here's an issue I've known about for several months but hadn't reported.
I'm curious if there are any ideas here for debugging or what the cause might 
be (if obviously in Tcl.pm), or if I should go ahead and report it to Debian 
package maintainers.

Christopher A. Chavez

-------------------------------------------------------------------------

Using Debian 10 buster amd64, and packages provided by Debian:

perl      5.28.1-6
tk        8.6.9-2
tk-table  2.10-4 (borrowed from testing/bullseye; I can't find debug symbols 
for 2.10-3)

plus Tcl.pm 1.27 (either Debian's libtcl-perl 1.27+ds-1, or from GitHub master 
branch).

(I'm not sure which package might be responsible for this issue.
I believe I also observed this issue on a recent version of Ubuntu.)

Any normal usage of Tktable from Perl (e.g. with a wrapper like Tkx, Tcl::Tk, 
or Tcl::pTk) will seem to work fine, but an error occurs when the program is 
closed:

     munmap_chunk(): invalid pointer
     Aborted (core dumped)

This error does not occur when using Tktable directly from Tcl/Tk (e.g. 
tclsh/wish), so I suspect the issue may be in Tcl.pm or Perl.

Example Perl script that exhibits the error:

     use Tcl;
     my $i = new Tcl;
     $i->Init;
     $i->Eval('package require Tk');
     $i->Eval('package require Tktable');
     $i->Eval('destroy .');

Valgrind indicates the error is due to an invalid free, but the exact code 
responsible for the issue is unclear to me:

$ valgrind --num-callers=100 perl tktable-test.pl ==17734== Memcheck, a memory 
error detector ==17734== Copyright (C) 2002-2017, and GNU GPL'd, by Julian 
Seward et al.
==17734== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info 
==17734== Command: perl -Mblib tktable-test.pl ...
[omitting "Invalid read of size 1" error -- known behavior when Tk is loaded, 
https://core.tcl-lang.org/tk/tktview?name=e42eef33ee ] ...
==17734== Invalid free() / delete / delete[] / realloc()
==17734==    at 0x48369AB: free (vg_replace_malloc.c:530)
==17734==    by 0x162304: perl_destruct (in /usr/bin/perl)
==17734==    by 0x13C3DB: main (in /usr/bin/perl)
==17734==  Address 0x52012a0 is 8,400 bytes inside a block of size
16,384 alloc'd
==17734==    at 0x483577F: malloc (vg_replace_malloc.c:299)
==17734==    by 0x5550DFE: GetBlocks (tclThreadAlloc.c:1044)
==17734==    by 0x5550549: TclpAlloc (tclThreadAlloc.c:358)
==17734==    by 0x5459272: newstate (regc_nfa.c:135)
==17734==    by 0x54548B8: parseqatom (regcomp.c:1136)
==17734==    by 0x5453FA3: parsebranch (regcomp.c:760)
==17734==    by 0x5453DF2: parse (regcomp.c:689)
==17734==    by 0x545365E: TclReComp (regcomp.c:382)
==17734==    by 0x5542841: CompileRegexp (tclRegexp.c:934)
==17734==    by 0x5542404: Tcl_GetRegExpFromObj (tclRegexp.c:593)
==17734==    by 0x547FCF4: Tcl_RegexpObjCmd (tclCmdMZ.c:268)
==17734==    by 0x5467FB6: TclNRRunCallbacks (tclBasic.c:4461)
==17734==    by 0x54693AE: TclEvalEx (tclBasic.c:5330)
==17734==    by 0x5468D12: Tcl_EvalEx (tclBasic.c:4995)
==17734==    by 0x54078CB: XS_Tcl_Eval (Tcl.xs:1097)
==17734==    by 0x1F4360: Perl_pp_entersub (in /usr/bin/perl)
==17734==    by 0x1EA685: Perl_runops_standard (in /usr/bin/perl)
==17734==    by 0x166116: perl_run (in /usr/bin/perl)
==17734==    by 0x13C401: main (in /usr/bin/perl)
==17734==
==17734== Invalid free() / delete / delete[] / realloc()
==17734==    at 0x48369AB: free (vg_replace_malloc.c:530)
==17734==    by 0x162322: perl_destruct (in /usr/bin/perl)
==17734==    by 0x13C3DB: main (in /usr/bin/perl)
==17734==  Address 0x536add0 is 8,720 bytes inside a block of size
16,384 alloc'd
==17734==    at 0x483577F: malloc (vg_replace_malloc.c:299)
==17734==    by 0x5550DFE: GetBlocks (tclThreadAlloc.c:1044)
==17734==    by 0x5550549: TclpAlloc (tclThreadAlloc.c:358)
==17734==    by 0x5471A87: Tcl_Alloc (tclCkalloc.c:1059)
==17734==    by 0x5512900: AllocChannelBuffer (tclIO.c:2453)
==17734==    by 0x5512900: GetInput (tclIO.c:6843)
==17734==    by 0x5511B5C: DoReadChars (tclIO.c:5867)
==17734==    by 0x5522605: TclNREvalFile (tclIOUtil.c:1920)
==17734==    by 0x5480DE5: TclNRSourceObjCmd (tclCmdMZ.c:1013)
==17734==    by 0x5467FB6: TclNRRunCallbacks (tclBasic.c:4461)
==17734==    by 0x54693AE: TclEvalEx (tclBasic.c:5330)
==17734==    by 0x5468D12: Tcl_EvalEx (tclBasic.c:4995)
==17734==    by 0x54078CB: XS_Tcl_Eval (Tcl.xs:1097)
==17734==    by 0x1F4360: Perl_pp_entersub (in /usr/bin/perl)
==17734==    by 0x1EA685: Perl_runops_standard (in /usr/bin/perl)
==17734==    by 0x166116: perl_run (in /usr/bin/perl)
==17734==    by 0x13C401: main (in /usr/bin/perl)

Reply via email to