segfault when create thread in plugin(perl)
KildClient is a powerful MUD client with a built-in Perl interpreter
Brought to you by:
ekalin
package th1;
#: Version: 1.1
#: Description: try thread
#: Author: Fu Huizhong
use threads;
sub confirm{
$::world->echo('hello\n')
}
our $tid = 0;
sub show{
$tid = threads->create( \&confirm );
$tid->detach();
}
###################################
kernel message:
==============
Apr 28 10:41:07 fhz-laptop kernel: [12623.779625] kildclient[2723]: segfault at c ip 053c9bcf sp bfa52f50 error 4 in encoding.so[53c5000+6000]
Apr 28 10:44:30 fhz-laptop kernel: [12826.905507] kildclient[2734]: segfault at c ip 00e41bcf sp bfba9fb0 error 4 in encoding.so[e3d000+6000]
I can confirm the segfault. At this moment I don't know what causes it or how to fix, but I'll investigate it further.
Even though I didn't do anything specific to treat this bug, your code now works, and I was able to confirm it is running in the background. Maybe changes in libperl or the fact that now KC itself is multi-threaded.
That said, starting threads in Perl is something that has not been test, and there might be unexpected effects, including crashes. So I'd call it an unsupported feature.