Names "A" and "B" are used for simplicity. I didn't use them in real codes.
The following gives short enough but clear code samples that result in 1 warning and 1 error messages that confused me.
use threads; use test; my $argument=1; my $thread=threads->create("forthread", ($argument)); $thread->join(); exit(0);
package test; require Exporter; our @ISA =qw(Exporter); our @EXPORT =qw(queuereader); our @VERSION =1.0; sub forthread{ my ($arg)=@_; return 0; } #forthread
NOTE: there is no problem if "forthread" is in test.pl. But when we put "forthread" in a separate file other than the caller file, it reports the above warning message, in fact, no matter if we pass any argument at time of thread creation.
use threads; use test; my $thread=threads->create("forthread", (argument)); $thread->join(); exit(0);
package test; require Exporter; our @ISA =qw(Exporter); our @EXPORT =qw(queuereader); our @VERSION =1.0; sub forthread{ my (argument)=@_; my $thread=threads->create("another", (argument)); $thread->join(); return 0; } #forthread sub another{ return 0; } #another
NOTE: the error is reported when "argument" is one of
the following:
- reference to scalar
- reference to array
- reference to hash
- hash
In reply to Re^2: "Attempt to free unreferenced scalar" and "Scalars leaked: 1" ?
by licht
in thread "Attempt to free unreferenced scalar" and "Scalars leaked: 1" ?
by licht
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |