I provided a short code sample that produces the problem on my machine. I don't think it even makes it to the untie. To get rid of the segfault all I have to do is comment out the tie.
Maybe someone could point out something I'm doing wrong, or suggest a module that works better for this. Any advice would be appreciated.
smiles
#!/usr/bin/perl use strict; use threads; use threads::shared; use Thread::Queue; use SDBM_File; use Fcntl; # initialize some stuff my $q = Thread::Queue->new(); my %items : shared; tie %items,'SDBM_File','itemdb',O_CREAT|O_RDWR,0640 or die "Could not +open SDBM file: $!\n"; $items{$_} = 1 for 1..10; # play with 3 threads for (1..3) { threads->new(\&ttest) } my @threadlist = threads->list; $q->enqueue($_) for 1..10; $q->enqueue(undef) for @threadlist; $_->join for @threadlist; # clean up mess untie %items; unlink 'itemdb.pag','itemdb.dir'; sub ttest { while (my $qthingie = $q->dequeue) { print "$items{$qthingie}\n" } }
In reply to threads, tie and segmentation fault by petesmiley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |