develooper Front page | perl.perl5.porters | Postings from October 2005

[perl #37564] incorrect return value for threads::join()

Thread Next
From:
wendigo @ jabberwock . org
Date:
October 30, 2005 07:39
Subject:
[perl #37564] incorrect return value for threads::join()
Message ID:
rt-3.0.11-37564-123533.16.1506263450114@perl.org
# New Ticket Created by  wendigo@jabberwock.org 
# Please include the string:  [perl #37564]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37564 >



This is a bug report for perl from wendigo@jabberwock.org,
generated with the help of perlbug 1.35 running under perl v5.8.7.


-----------------------------------------------------------------

It looks like the threads::join() function is returning undef when it should
be returning a scalar.

What the manpage says:

       $thread->join
           This will wait for the corresponding thread to join. When the
           thread finishes, join() will return the return values of the entry
           point function. If the thread has been detached, an error will be
           thrown.

What threads v1.05 actually does:

--
#!/usr/local/bin/perl
use threads;

sub foo {
    my $rv = shift;
    my $id = threads->self->tid;
    print "$id returning $rv\n";
    return $rv;
}

for my $val (0..2) {
    threads->create(\&foo, $val);
}

foreach my $t (threads->list) {
    if ($t->tid && ! threads::equal($t, threads->self)) {
        my $rv = $t->join;
        my $id = $t->tid;
        print "$id returned $rv\n";
    }
}
--

1 returning 0
2 returning 1
3 returning 2
1 returned
2 returned
3 returned


-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.8.7:

Configured by wendigo at Mon Oct 24 11:24:44 EDT 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=linux, osvers=2.6.8-2-386, archname=i686-linux-thread-multi
    uname='linux phoenix 2.6.8-2-386 #1 thu may 19 17:40:50 jst 2005 i686 gnulinux '
    config_args=''
    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
  Compiler:
    cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-13)', 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='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.7:
    /usr/local/lib/perl5/5.8.7/i686-linux-thread-multi
    /usr/local/lib/perl5/5.8.7
    /usr/local/lib/perl5/site_perl/5.8.7/i686-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.8.7
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.8.7:
    HOME=/home/wendigo
    LANG=en_US
    LANGUAGE=en_US:en_GB:en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About