Segmentation fault after destroying non-dependent window

<[email protected]>
Newsgroups gmane.comp.lang.perl.tk
Message-ID <D99246B510C34944823191CB90759C8601FF12D2@blrse201.ap.infineon.com>
Hi All,

Forwarding issue : Segmentation faults with Perl/Tk (please see the mail
below)!

I seem to have the same problem for the code (shown below) in perl/5.8.7
for both linux and solaris. What is the reason for the segmentation
faults? Even
after changing "destroy" to "UnmapWindow", segmentation faults occur. Is
there a solution or a workaround to this problem?

Any help is appreciated.

Thanks,
Kaushik



---------- Forwarded message ----------
From: Kingpin
Date: 1997/09/12
Subject: Segmentation fault after destroying non-dependent window 
To:


#!/usr/local/bin/perl -w

=head Description

The program below demonstrates a Segmentation fault (with no error
messages whatsoever) which occurs after a non-dependent window is
explicitly destroyed.  (By "non-dependent" I mean that it doesn't have 
anything to do with what happens from the point of its destruction
onward.) I am using perl 5.00401 and Tk400.202 on Solaris 2.5.1.

=head tkperl version

> perl -e 'use Tk;print $Tk:VERSION'

400.202

=head perl version

Site configuration information for perl 5.00401:

Configured by mthurn at Mon Aug 25 17:02:55 EDT 1997.

Summary of my perl5 (5.0 patchlevel 4 subversion 1) configuration: 
Platform:
   osname=solaris, osvers=2.5.1, archname=sun4-solaris
   uname='sunos copper 5.5.1 generic sun4u sparc sunw,ultra-2 '
   hint=recommended, useposix=true, d_sigaction=define
   bincompat3=y useperlio= d_sfio= 
Compiler:
   cc='gcc', optimize='-g -O', gccversion=2.7.2.1
   cppflags='-DDEBUGGING -I/usr/local/include'
   ccflags ='-DDEBUGGING -I/usr/local/include'
   stdchar='unsigned char', d_stdstdio=define, usevfork=false 
   voidflags=15, castflags=0, d_casti32=define, d_castneg=define
   intsize=4, alignbytes=8, usemymalloc=y, randbits=15
Linker and Libraries:
   ld='gcc', ldflags =' -L/usr/local/lib'
   libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib 
   libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt
   libc=/lib/libc.so, so=so
   useshrplib=false, libperl=libperl.a
Dynamic Linking:
   dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags=' '
   cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib' 
---
@INC for perl 5.00401:
       /fs81/TIR/lib/perl5
       /usr/local/lib/perl5/sun4-solaris/5.00401
       /usr/local/lib/perl5
       /usr/local/lib/perl5/site_perl/sun4-solaris
       /usr/local/lib/perl5/site_perl 
       /usr/local/lib/perl5/sun4-solaris
       .
---
Environment for perl 5.00401:
   HOME=/accts/mthurn
   LANG (unset)

LD_LIBRARY_PATH=/usr/X11R5/lib:/usr/MOTIF1.2.4/lib:/usr/openwin/lib:/fs4
1/galaxy/lib:/usr/lib:/fs41/INSO/oidevkit/lib 
   LOGDIR (unset)

PATH=/code/PRODUCTS/v115b/bin:.:/usr/MOTIF1.2.4/bin:/bin:/usr/ucb:/usr/o
penwin/bin:/usr/X11R5/bin:/usr/sbin:/usr/ccs/bin:/usr/local/bin:/accts/m
thurn/bin:/fs81/TIR/extractors:/fs81/TIR/bin:/data5/DATA/Tools:/fs41/RW/
sun4os5/sdk/bin:/fs41/galaxy/bin:/apps/ioffice_5.0/bin:/oracle/app/produ
ct/7.2.2:/oracle/app/product/7.2.2/bin:/usr/local/Acrobat3/bin:/usr/loca
l/java/bin:/apps/verity/_solaris/bin:/solaris/DOOM:/usr/local/games 
   PERL5LIB=/fs81/TIR/lib/perl5
   PERL_BADLANG (unset)
   SHELL=/usr/local/bin/tcsh

=cut Here is the program which seg-faults:

use Tk;

$w1 = new MainWindow;
$w1->Label(-text=>"Click Button1, then click the Button2 which 
appears.\nRepeat this two or three times.")->pack;
$f1 = $w1->Frame()->pack;
$w1->Button(-text=>'Button1',-command=>\&button1)->pack;
MainLoop;

sub button1
{
$w2 = new MainWindow; 
$w2->Label(-text=>"When you click Button2, \nthis window will be
destroyed \nand a Checkbutton will be created in the first
window.")->pack;
$w2->Button(-text=>'Button2',-command=>\&button2)->pack; 
}

sub button2
{
$w2->destroy;
#    ^^^^^^^  This destroy is the key to the core dump.
# If this destroy is at the end of this function, all is well.
$f1->Checkbutton(-text=>"Check")->pack; 
}

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.