Skip Menu |

This queue is for tickets about the Variable-Magic CPAN distribution.

Report information
The Basics
Id: 46546
Status: resolved
Priority: 0/
Queue: Variable-Magic

People
Owner: Nobody in particular
Requestors: kmx [...] volny.cz
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 0.37



Subject: Variable::Magic + fork crashes on 5.10.0/Win32
Date: Sun, 31 May 2009 10:07:19 +0200
To: bug-Variable-Magic [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
Hi, the following script: --- 1: use Variable::Magic qw/wizard cast/; 2: my $wiz = wizard set => sub { print "now set to ${$_[0]}!\n" }; 3: 4: if (my $p = fork ) { 5: print "After fork 1: $$\n"; 6: } 7: else { 8: print "After fork 2: $$\n"; 9: } --- crashes during "fork" call on win32/strawberry perl 5.10.0.4 & 5.10.0.5 with error: perl.exe fails with error "The instruction at address 0x6a72c777 referenced memory at address 0x00000004. The memory could not be read". If I comment out the second line it works fine. On Win32 Active state perl 5.10 the program (fork call) does not work but program just silently ends (without crash). The same script works fine on win32/strawberry perl 5.8.9.0 & 5.8.9.1 - also no problems on UNIX perls (I have tested Linux - perl 5.8 and 5.10) To be honest I am not sure if this is a bug in Variable::Magic or perl core 510 for Win32. Here is some dubug info: (gdb) run test.pl Starting program: D:\strawberry\perl\bin\perl.exe test.pl [New thread 1680.0xebc] ... Program received signal SIGSEGV, Segmentation fault. 0x6a72c777 in perl510!Perl_ptr_table_new () from D:\strawberry\perl\bin\perl510.dll (gdb) backtrace full #0 0x6a72c777 in perl510!Perl_ptr_table_new () from D:\strawberry\perl\bin\perl510.dll No symbol table info available. #1 0x6a72c7ae in perl510!Perl_ptr_table_fetch () from D:\strawberry\perl\bin\perl510.dll No symbol table info available. #2 0x6a72cb48 in perl510!Perl_sv_dup () from D:\strawberry\perl\bin\perl510.dll No symbol table info available. #3 0x2e4f11ad in ?? () from D:\strawberry\perl\site\lib\auto\Variable\Magic\Magic.dll No symbol table info available. #4 0x009f2324 in ?? () No symbol table info available. #5 0x009eb0a4 in ?? () No symbol table info available. #6 0x0022f7d0 in ?? () No symbol table info available. #7 0x6a76509f in perl510!Perl_safesysmalloc () from D:\strawberry\perl\bin\perl510.dll No symbol table info available. #8 0x2e4f3346 in ?? () from D:\strawberry\perl\site\lib\auto\Variable\Magic\Magic.dll No symbol table info available. #9 0x003f4764 in ?? () No symbol table info available. #10 0x00a373dc in ?? () No symbol table info available. #11 0x00000000 in ?? () No symbol table info available. (gdb) -- kmx
Show quoted text
> Hi, > > the following script: > > --- > 1: use Variable::Magic qw/wizard cast/; > 2: my $wiz = wizard set => sub { print "now set to ${$_[0]}!\n" }; > 3: > 4: if (my $p = fork ) { > 5: print "After fork 1: $$\n"; > 6: } > 7: else { > 8: print "After fork 2: $$\n"; > 9: } > --- > > crashes during "fork" call on win32/strawberry perl 5.10.0.4 & 5.10.0.5
Hello, Thank you for showing interest into Variable::Magic and for reporting this issue. I just got a temporary access to a Windows setup and I could reproduce the crash. It happens because the win32 fork() emulation clones the interpreter without setting a flag (CLONEf_KEEP_PTR_TABLE) that allows Variable::Magic to relink the callbacks in the forked process to the ones of the parent. However, I don't know the details of the fork() emulation, so I don't know if fixing the core to set this flag is a sane thing to do. Anyway, I couldn't work around it in V::M yet, so I'm afraid that even if it were to be fixed in perl, you'd have to wait for a new perl to be released with the fix included, which is suboptimal. There shouldn't be any problems with threads spawned by threads.pm though. Vincent.
This has been fixed in perl 5.10.1. I've added a VMG_FORKSAFE constant in Variable::Magic 0.37 that's true when the module is fork-safe. Since this is always the case on Unix, it's currently false only for pre-5.10.1 on Windows. Vincent.