Re: Solaris Coredump on "$top->update"

Craig Votava <[email protected]> Wed, 9 Aug 2006 08:32:03 -0500
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
Folks-

About a month ago, I posted the attached question about
a core-dump occurring on Solaris with Perl 5.8 when using Tk.
A good friend of mine (Pete Fales) figured out what the bug
was, and came up with a fix. We suspect that most people do
not see this, as it's related to the version of Tcl/Tk being
used (ours is a bit old).

The following solution is from Pete. I'm just providing it to
the ptk list.

-Craig

On Jul 13, 2006, at 9:08 AM, Peter Fales wrote:

> The problem seems to happen when perl5.8 tries to convert
> a string (like "Don't press this button") from the machines native  
> encoding
> to UTF-8.   It calls the function nl_langinfo(CODESET) to find the  
> native
> codeset, but on solaris 2.5.1, this returns an empty string which  
> eventually
> results in the coredump.

Here's the patch I used:

diff -ur Tk-804.027/encGlue.c Tk-804.027.new/encGlue.c
--- Tk-804.027/encGlue.c	2004-03-28 13:50:55.000000000 -0600
+++ Tk-804.027.new/encGlue.c	2006-07-12 17:56:22.000000000 -0500
@@ -546,7 +546,8 @@
  #if defined(HAS_NL_LANGINFO) && defined(CODESET)
     codeset = nl_langinfo(CODESET);
  #endif
-   if (!codeset)
+/* On some solaris systems, nl_langinfo() returns an empty string or  
"646" */
+   if (!codeset  || !codeset[0] || !strcmp(codeset,"646") )
      codeset = "iso8859-1";
     system_encoding = Tcl_GetEncoding(NULL,codeset);
     if (!system_encoding)

On Jul 10, 2006, at 2:37 PM, Craig Votava wrote:

> Folks-
>
> The attached perl program seems to be causing a
> core-dump for me on Solaris with Perl 5.8 and
> Tk-804.027. I'm still investigating but thought
> I'd do a quick ping here to see if anybody has
> already fought this one.
>
> Any pointers are appreciated!
>
> Thanks
>
> -Craig
>
> #!/opt/exp/bin/perl5.8 -w
>
> use Tk;
> use strict;
>
> # Create a new main window & title it...
> my $top = MainWindow->new;
> $top->title("Be Careful...");
>
> # The following line causes a coredump on suns...
> $top->update;
>
> # Create a text label...
> my $label = $top->Label(-text => "Whatever you do, don't press this  
> button");
>
> # Have the grid manager, manage it...
> $label->grid;
>
> # Create a button & have the grid manager manage it (all in one  
> statement)...
> my $button = $top->Button(-background => 'red',
> 			-text => 'Panic',
> 			-command => sub {
> 				print "I TOLD YOU NOT TO DO THAT...\n";
> 				$top->destroy;
> 			})->grid;
>
> # Run the GUI...
> MainLoop;
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk