[jifty-devel] jifty segfault with threads
Matt Zagrabelny
mzagrabe at d.umn.edu
Thu Dec 9 15:48:46 EST 2010
Comments inline.
On Thu, Dec 9, 2010 at 2:13 PM, Matt Zagrabelny <mzagrabe at d.umn.edu> wrote:
> Greetings,
>
> I've got a bug report, which may be low on the totem pole, but thought
> I ought to report nonetheless.
>
> When using the following code, perl segfaults:
>
> #!/usr/bin/env perl
>
> use Jifty::Everything;
> BEGIN { Jifty->new() }
>
> use threads;
>
> my $use_threads = 1;
>
> if ($use_threads) {
> my $insert_thread = threads->create(\&insert);
> $insert_thread->join;
> } else {
> &insert;
> }
>
> sub insert {
> my $u = BTDT::Model::User->new( current_user =>
> BTDT::CurrentUser->superuser );
> my ( $id, $msg ) = $u->create(
> id => 10,
> name => 'admin',
> );
> print $msg unless ($id);
> }
>
>
> If you change the variable $use_threads to false:
> my $use_threads = 0;
>
> the program works.
>
> The issue does not seem to be with the Jifty::DBI::Handle creation,
> the following works (does not segfault):
>
> #!/usr/bin/env perl
>
> use Jifty::DBI::Handle;
>
> use threads;
>
> my $use_threads = 1;
>
> if ($use_threads) {
> my $insert_thread = threads->create(\&insert);
> $insert_thread->join;
> } else {
> &insert;
> }
>
> sub insert {
> my $handle = Jifty::DBI::Handle->new();
> $handle->connect(
> driver => 'Pg',
> database => 'btdt',
> host => 'localhost',
> user => '',
> password => ''
> );
> }
>
> Any ideas or suggestions?
The segfault seems to come from:
Jifty.pm
use encoding 'utf8';
Which is not thread safe according to:
http://perldoc.perl.org/encoding.html#KNOWN-PROBLEMS
-matt
More information about the jifty-devel
mailing list