develooper Front page | perl.perl5.porters | Postings from April 2003

[perl #22060] Perl 5.8.0 on FreeBSD 5.0 threads (threads->list) possible bug

April 28, 2003 16:27
[perl #22060] Perl 5.8.0 on FreeBSD 5.0 threads (threads->list) possible bug
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #22060]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.34 running under perl v5.8.0.

[Please enter your report here]

After following perldoc perlthrtut to try out 5.8.0 ithreads, I made a small script that made some threads, printed a number, slept for 1-3 seconds and exits.

Then i used threads->list to iterate over the threads and join() them to close them nicely before the script exits.

I made 200 threads just for fun and noticed the following errormessage:
Attempt to free unreferenced scalar at line 30.

I played around a bit and decreased the number of threads, thinking it might memory or the like and noticed that creating 127 or below threads does not produce this error, but anything above does.

Thus it seems threads->list seems to only hold 127 (128?) objects.

Test script follows:

#!/usr/bin/perl -w

use strict;
use threads;
use threads::shared;

$| = 1;

my $childs : shared = 0;
my $maxthr = 127;

for (my $num = 0; $num < $maxthr; $num++){
        my $thr = threads->new(\&ttest);

sub ttest ($) {
	print $childs,"\r";
	sleep(int rand(3));

foreach my $thr (threads->list) {
	if ($thr && $thr->tid && !threads::equal($thr, threads->self)) {
		print $thr->tid, "\n";

exit 0;

[Please do not change anything below this line]
Site configuration information for perl v5.8.0:

Configured by michael at Sun Apr 27 16:08:32 GMT 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
    osname=freebsd, osvers=5.0-release, archname=i386-freebsd-thread-multi
    uname='freebsd 5.0-release freebsd 5.0-release #0: thu mar 27 01:34:12 cet 2003 i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.0/mach -Dprivlib=/usr/local/lib/perl5/5.8.0 -Dman3dir=/usr/local/lib/perl5/5.8.0/man/man3 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.0/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.0 -Dscriptdir=/usr/local/bin -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -Ui_gdbm -Dusemymalloc=n -Dusethreads=y'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include',
    optimize='-O -pipe -mcpu=pentiumpro',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.0/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.2.1 [FreeBSD] 20021119 (release)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-pthread -Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lc_r -lcrypt -lutil
    perllibs=-lm -lc_r -lcrypt -lutil
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.0:

Environment for perl v5.8.0:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/zsh Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About