[jifty-devel] jifty segfault with threads

Matt Zagrabelny mzagrabe at d.umn.edu
Thu Dec 9 15:13:07 EST 2010


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?

Thanks,

-matt


More information about the jifty-devel mailing list