nusoff has asked for the wisdom of the Perl Monks concerning the following question:

Hello. I have a problems with my windows application. Application segfaults, when external command was executed. Windows Vista/ActivePerl 5.10/Tk/POE 1.007 Error: free to wrong pool xxxxxx not xxxxxx.
#!/usr/bin/perl -w use strict; use Tk; use POE qw( Loop::TkActiveState Wheel::Run ); POE::Session->create( inline_states => { _start => \&on_start, got_child_stdout => \&on_child_stdout, got_child_stderr => \&on_child_stderr, got_child_close => \&on_child_close, got_child_signal => \&on_child_signal, } ); POE::Kernel->run(); exit 0; sub on_start { $poe_main_window->Button( -text => 'OK', -command => sub { exit; } ) +; my $child = POE::Wheel::Run->new( Program => 'dir', StdoutEvent => "got_child_stdout", StderrEvent => "got_child_stderr", CloseEvent => "got_child_close", ); # Wheel events include the wheel's ID. $_[HEAP]{children_by_wid}{$child->ID} = $child; # Signal events include the process ID. $_[HEAP]{children_by_pid}{$child->PID} = $child; print( "Child pid ", $child->PID, " started as wheel ", $child->ID, ".\n" ); } # Wheel event, including the wheel's ID. sub on_child_stdout { my ($stdout_line, $wheel_id) = @_[ARG0, ARG1]; my $child = $_[HEAP]{children_by_wid}{$wheel_id}; print "pid ", $child->PID, " STDOUT: $stdout_line\n"; } # Wheel event, including the wheel's ID. sub on_child_stderr { my ($stderr_line, $wheel_id) = @_[ARG0, ARG1]; my $child = $_[HEAP]{children_by_wid}{$wheel_id}; print "pid ", $child->PID, " STDERR: $stderr_line\n"; } # Wheel event, including the wheel's ID. sub on_child_close { my $wheel_id = $_[ARG0]; my $child = delete $_[HEAP]{children_by_wid}{$wheel_id}; # May have been reaped by on_child_signal(). unless (defined $child) { print "wid $wheel_id closed all pipes.\n"; return; } print "pid ", $child->PID, " closed all pipes.\n"; delete $_[HEAP]{children_by_pid}{$child->PID}; } sub on_child_signal { print "pid $_[ARG1] exited with status $_[ARG2].\n"; my $child = delete $_[HEAP]{children_by_pid}{$_[ARG1]}; # May have been reaped by on_child_close(). return unless defined $child; delete $_[HEAP]{children_by_wid}{$child->ID}; }

Replies are listed 'Best First'.
Re: Please help with POE::Wheel::Run
by rcaputo (Chaplain) on Aug 18, 2009 at 13:41 UTC

    I suspect that Tk doesn't like being run in more than one thread. POE by itself is entirely Perl, so it doesn't do funny things with memory pools. One work-around is to avoid Tk; does Gtk work instead? If so, then Tk is probably the culprit.

    cmv is having the same problem, which you can see at this node. It might be helpful for you to consolidate nodes and notes. He was also nice enough to open an this rt.cpan.org ticket. If you are logged into rt.cpan.org, you may be able to add yourself as a Cc on that ticket. Then you should receive automatic progress updates when there's news.