New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fcntl not thread-safe #9006
Comments
From @jdheddenThis is a bug report for perl from jdhedden@cpan.org, Occasionally, when running threaded applications that use The reported strings are always those for Fcntl constants, The attached script reproduces the problem. It must be run Also attached is a sample of the script's output when the See http://www.nntp.perl.org/group/perl.perl5.porters/2007/06/msg125684.html Flags: Site configuration information for perl 5.9.5: Configured by Jerry at Mon Aug 27 12:42:03 EDT 2007. Summary of my perl5 (revision 5 version 9 subversion 5 patch 31756) Locally applied patches: @INC for perl 5.9.5: Environment for perl 5.9.5: |
From @jdheddenThe code produced by ExtUtils::Constant::ProxySubs is not static HV *constant_missing = NULL; This cause errors in threaded apps that use LWP of the form: The attached patch corrects this by adding the hash to the |
From @jdheddeneucps.patch--- perl-current/lib/ExtUtils/Constant/ProxySubs.pm
+++ perl-current/lib/ExtUtils/Constant/ProxySubs.pm
@@ -9,7 +9,7 @@
use ExtUtils::Constant::Utils qw(C_stringify);
use ExtUtils::Constant::XS qw(%XS_TypeSet);
-$VERSION = '0.03';
+$VERSION = '0.04';
@ISA = 'ExtUtils::Constant::XS';
%type_to_struct =
@@ -218,7 +218,7 @@
EOADD
- print $c_fh $explosives ? <<"EXPLODE" : <<"DONT";
+ print $c_fh $explosives ? <<"EXPLODE" : "\n";
static int
Im_sorry_Dave(pTHX_ SV *sv, MAGIC *mg)
@@ -242,12 +242,6 @@
EXPLODE
-#ifndef SYMBIAN
-static HV *${c_subname}_missing = NULL;
-#endif
-
-DONT
-
print $xs_fh <<"EOBOOT";
BOOT:
{
@@ -255,6 +249,18 @@
dTHX;
#endif
HV *symbol_table = get_hv("$symbol_table", TRUE);
+#ifndef SYMBIAN
+ /* When we create the 'missing' hash, it generates a 'used only once'
+ * warning. Therefore, turn off warnings while we do this.
+ */
+ HV *${c_subname}_missing;
+ {
+ const bool warn_tmp = PL_dowarn;
+ PL_dowarn = 0;
+ ${c_subname}_missing = get_hv("${symbol_table}${c_subname}_missing", TRUE);
+ PL_dowarn = warn_tmp;
+ }
+#endif
EOBOOT
my %iterator;
@@ -320,11 +326,6 @@
'symbol_table',
$add_symbol_subname);
}
- print $xs_fh $explosives ? "\n" : <<"EOBOOT";
-#ifndef SYMBIAN
- ${c_subname}_missing = newHV();
-#endif
-EOBOOT
print $xs_fh <<"EOBOOT";
while (value_for_notfound->name) {
@@ -464,6 +465,7 @@
#ifdef SYMBIAN
sv = newSVpvf("%"SVf" is not a valid $package_sprintf_safe macro", sv);
#else
+ HV *${c_subname}_missing = get_hv("${c_subname}_missing", FALSE);
if (hv_exists(${c_subname}_missing, s, SvUTF8(sv) ? -(I32)len : (I32)len)) {
sv = newSVpvf("Your vendor has not defined $package_sprintf_safe macro %" SVf
", used", sv);
|
From @rgsOn 28/08/2007, Jerry D. Hedden <jdhedden@cpan.org> wrote:
At the risk of stepping over a user variable, it seems. Maybe should |
The RT System itself - Status changed from 'new' to 'open' |
From @jdheddenJerry D. Hedden wrote:
Rafael Garcia-Suarez wrote:
The attached revised patch uses _M!55!NG which should (Patch not attached in this posting to p5p because it gets PERM_FAILURE: SMTP Error (state 16): 552 Probably the 'Hi' virus Patch sent directly to Rafael.) |
From @rgsOn 30/08/2007, Jerry D. Hedden <jdhedden@cpan.org> wrote:
Thanks, applied as #31766. |
From @steve-m-hayRafael Garcia-Suarez wrote:
That caused compiler errors on Win32 with VC++ which I fixed in #31769, Name "POSIX::constant_M!55!NG" used only once: possible typo at Have I just broken this in #31769 or was there a problem at #31766 |
From @rgsOn 31/08/2007, Steve Hay <SteveHay@planit.com> wrote:
I don't know, how do you get that warning ? Looking at the source code |
From @steve-m-hayRafael Garcia-Suarez wrote:
Lots of tests causes, and so does this one-liner: C:\p5p\bleadperl>.\perl -MPOSIX -e 1 |
From @jdheddenSteve Hay wrote:
Rafael Garcia-Suarez wrote:
Steve Hay wrote:
I do not get any warnings using the following in the build dir ./perl -Ilib -MPOSIX -e 1 |
From @steve-m-hayJerry D. Hedden wrote:
After rebuilding without Vadim's ALL_STATIC patch I now don't see any So the ALL_STATIC build option breaks the code added by 31766/31769 that |
From @steve-m-haySteve Hay wrote:
It wasn't just me being stupid: I've now put Vadim's patch back. After doing a normal build with "nmake" |
From vadim@vkonovalov.ruSteve Hay wrote:
I'll look into POSIX::constant_M!55!NG warning closely today, and tomorrow. But, generally, the behaviour is of little surprise to me. As a side note, the final goal of approach is to create single-file Best regards, |
From vadim@vkonovalov.ruVadim wrote:
this warning is because the way of avoiding warning is "naive" PL_dowarn is temporarily turned to 0 while doing assigmnet a value to See attached patch. All in all, I must underline that this my patch is "safer" than my Even introducing ALL_STATIC into win32/Makefile it actually do nothing Best regards, |
From vadim@vkonovalov.ruInline Patchdiff -ru bperl-31775-orig/lib/ExtUtils/Constant/ProxySubs.pm bperl-31775-devsta/lib/ExtUtils/Constant/ProxySubs.pm
--- bperl-31775-orig/lib/ExtUtils/Constant/ProxySubs.pm 2007-08-31 12:56:29.000000000 +0400
+++ bperl-31775-devsta/lib/ExtUtils/Constant/ProxySubs.pm 2007-09-01 23:38:20.484375000 +0400
@@ -315,10 +315,10 @@
/* When we create the 'missing' hash, it generates a 'used only once'
* warning. Therefore, turn off warnings while we do this.
*/
- const bool warn_tmp = PL_dowarn;
- PL_dowarn = 0;
- ${c_subname}_missing = get_hv("${symbol_table}${c_subname}_M!55!NG", TRUE);
- PL_dowarn = warn_tmp;
+ constant_missing = get_hv("POSIX::constant_M!55!NG", TRUE);
+ /* When we create the 'missing' hash, it generates a 'used only once'
+ * warning. Avoid this: */
+ constant_missing = get_hv("POSIX::constant_M!55!NG", TRUE);
#endif
EOBOOT
diff -ru bperl-31775-orig/win32/FindExt.pm bperl-31775-devsta/win32/FindExt.pm
--- bperl-31775-orig/win32/FindExt.pm 2007-04-27 21:15:40.000000000 +0400
+++ bperl-31775-devsta/win32/FindExt.pm 2007-08-31 23:40:07.625000000 +0400
@@ -20,12 +20,17 @@
return $ENV{'PWD'} = $_;
}
-sub set_static_extensions
-{
+sub set_static_extensions {
# adjust results of scan_ext, and also save
# statics in case scan_ext hasn't been called yet.
+ # if '*' is passed then all XS extensions are static (with possible exclusions)
%static = ();
- for (@_) {
+ my @list = @_;
+ if ($_[0] eq '*') {
+ my %excl = map {$_=>1} map {m/^!(.*)$/} @_[1 .. $#_];
+ @list = grep {!exists $excl{$_}} keys %ext;
+ }
+ for (@list) {
$static{$_} = 1;
$ext{$_} = 'static' if $ext{$_} && $ext{$_} eq 'dynamic';
}
diff -ru bperl-31775-orig/win32/Makefile bperl-31775-devsta/win32/Makefile
--- bperl-31775-orig/win32/Makefile 2007-08-29 21:01:41.000000000 +0400
+++ bperl-31775-devsta/win32/Makefile 2007-09-01 23:23:10.203125000 +0400
@@ -176,6 +176,15 @@
#BUILD_STATIC = define
#
+# in addition to BUILD_STATIC the option ALL_STATIC makes for *every*
+# extension to be statically built
+# This will result in very large perl executable, but the main purpose
+# is to have proper linking set so to be able to create miscellaneous
+# executables with different set of built-in extensions
+#
+#ALL_STATIC = define
+
+#
#
# set the install locations of the compiler include/libraries
# Running VCVARS32.BAT is *required* when using Visual C.
@@ -784,9 +793,17 @@
SETARGV_OBJ = setargv$(o)
!ENDIF
-# specify static extensions here
+!IF "$(ALL_STATIC)" == "define"
+# some exclusions, unfortunately, until fixed:
+# - Win32 extension contains overlapped symbols with win32.c (BUG!)
+# - MakeMaker isn't capable enough for SDBM_File (smaller bug)
+# - Encode (encoding search algorithm relies on shared library?)
+STATIC_EXT = * !Win32 !SDBM_File !Encode
+!ELSE
+# specify static extensions here, for example:
#STATIC_EXT = Cwd Compress/Raw/Zlib
STATIC_EXT = Win32CORE
+!ENDIF
DYNALOADER = $(EXTDIR)\DynaLoader\DynaLoader
@@ -822,8 +839,8 @@
# Top targets
#
-all : .\config.h $(GLOBEXE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) $(PERLEXE) \
- $(X2P) MakePPPort Extensions $(PERLSTATIC)
+all : .\config.h $(GLOBEXE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) MakePPPort \
+ $(PERLEXE) $(X2P) Extensions $(PERLSTATIC)
@echo Everything is up to date. '$(MAKE_BARE) test' to run test suite.
..\regnodes.h : ..\regcomp.sym ..\regcomp.pl ..\regexp.h
@@ -1011,7 +1028,7 @@
$(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) $(PERLEXEST_OBJ) $(PERLEXE_RES)
$(LINK32) -subsystem:console -out:$@ -stack:0x1000000 $(LINK_FLAGS) \
- @Extensions_static $(PERLSTATICLIB) \
+ @Extensions_static $(PERLSTATICLIB) /PDB:NONE \
$(LIBFILES) $(PERLEXEST_OBJ) $(SETARGV_OBJ) $(PERLEXE_RES)
$(EMBED_EXE_MANI)
diff -ru bperl-31775-orig/win32/buildext.pl bperl-31775-devsta/win32/buildext.pl
--- bperl-31775-orig/win32/buildext.pl 2006-06-13 23:29:35.000000000 +0400
+++ bperl-31775-devsta/win32/buildext.pl 2007-08-31 23:40:07.671875000 +0400
@@ -63,8 +63,7 @@
print $fh "#ifdef STATIC2\n",(map {" EXTERN_C void boot_$_ (pTHX_ CV* cv);\n"} @statics1),"#undef STATIC2\n#endif\n";
print $fh "#ifdef STATIC3\n",(map {" newXS(\"$statics2[$_]::bootstrap\", boot_$statics1[$_], file);\n"} 0 .. $#statics),"#undef STATIC3\n#endif\n";
close $fh;
- }
- else {
+ } else {
my %extralibs;
for (@statics) {
open my $fh, "<..\\lib\\auto\\$_\\extralibs.ld" or die "can't open <..\\lib\\auto\\$_\\extralibs.ld: $!";
@@ -76,17 +75,14 @@
exit(0);
}
-my $here = getcwd();
+(my $here = getcwd()) =~ s{/}{\\}g;
my $perl = $^X;
-$here =~ s,/,\\,g;
-if ($perl =~ m#^\.\.#)
- {
- $perl = "$here\\$perl";
- }
+if ($perl =~ m#^\.\.#) {
+ $perl = "$here\\$perl";
+}
(my $topdir = $perl) =~ s/\\[^\\]+$//;
# miniperl needs to find perlglob and pl2bat
$ENV{PATH} = "$topdir;$topdir\\win32\\bin;$ENV{PATH}";
-#print "PATH=$ENV{PATH}\n";
my $pl2bat = "$topdir\\win32\\bin\\pl2bat";
unless (-f "$pl2bat.bat") {
my @args = ($perl, ("$pl2bat.pl") x 2);
@@ -100,7 +96,7 @@
my $dir = shift;
chdir($dir) || die "Cannot cd to $dir\n";
my $targ = shift;
-(my $ext = getcwd()) =~ s,/,\\,g;
+(my $ext = getcwd()) =~ s{/}{\\}g;
my $code;
FindExt::scan_ext($ext);
FindExt::set_static_extensions(split ' ', $Config{static_ext}) if $ext ne "ext"; |
From vadim@vkonovalov.ruSorry, I sent wrong one last time, attached is "better" one (hopefully)
|
From vadim@vkonovalov.ruInline Patchdiff -ru bperl-31775-orig/lib/ExtUtils/Constant/ProxySubs.pm bperl-31775-devsta/lib/ExtUtils/Constant/ProxySubs.pm
--- bperl-31775-orig/lib/ExtUtils/Constant/ProxySubs.pm 2007-08-31 12:56:29.000000000 +0400
+++ bperl-31775-devsta/lib/ExtUtils/Constant/ProxySubs.pm 2007-09-01 23:38:20.484375000 +0400
@@ -315,10 +315,10 @@
/* When we create the 'missing' hash, it generates a 'used only once'
* warning. Therefore, turn off warnings while we do this.
*/
- const bool warn_tmp = PL_dowarn;
- PL_dowarn = 0;
- ${c_subname}_missing = get_hv("${symbol_table}${c_subname}_M!55!NG", TRUE);
- PL_dowarn = warn_tmp;
+ ${c_subname}_missing = get_hv("${symbol_table}${c_subname}_M!55!NG", TRUE);
+ /* When we create the 'missing' hash, it generates a 'used only once'
+ * warning. Avoid this: */
+ ${c_subname}_missing = get_hv("${symbol_table}${c_subname}_M!55!NG", TRUE);
#endif
EOBOOT
diff -ru bperl-31775-orig/win32/FindExt.pm bperl-31775-devsta/win32/FindExt.pm
--- bperl-31775-orig/win32/FindExt.pm 2007-04-27 21:15:40.000000000 +0400
+++ bperl-31775-devsta/win32/FindExt.pm 2007-08-31 23:40:07.625000000 +0400
@@ -20,12 +20,17 @@
return $ENV{'PWD'} = $_;
}
-sub set_static_extensions
-{
+sub set_static_extensions {
# adjust results of scan_ext, and also save
# statics in case scan_ext hasn't been called yet.
+ # if '*' is passed then all XS extensions are static (with possible exclusions)
%static = ();
- for (@_) {
+ my @list = @_;
+ if ($_[0] eq '*') {
+ my %excl = map {$_=>1} map {m/^!(.*)$/} @_[1 .. $#_];
+ @list = grep {!exists $excl{$_}} keys %ext;
+ }
+ for (@list) {
$static{$_} = 1;
$ext{$_} = 'static' if $ext{$_} && $ext{$_} eq 'dynamic';
}
diff -ru bperl-31775-orig/win32/Makefile bperl-31775-devsta/win32/Makefile
--- bperl-31775-orig/win32/Makefile 2007-08-29 21:01:41.000000000 +0400
+++ bperl-31775-devsta/win32/Makefile 2007-09-01 23:23:10.203125000 +0400
@@ -176,6 +176,15 @@
#BUILD_STATIC = define
#
+# in addition to BUILD_STATIC the option ALL_STATIC makes for *every*
+# extension to be statically built
+# This will result in very large perl executable, but the main purpose
+# is to have proper linking set so to be able to create miscellaneous
+# executables with different set of built-in extensions
+#
+#ALL_STATIC = define
+
+#
#
# set the install locations of the compiler include/libraries
# Running VCVARS32.BAT is *required* when using Visual C.
@@ -784,9 +793,17 @@
SETARGV_OBJ = setargv$(o)
!ENDIF
-# specify static extensions here
+!IF "$(ALL_STATIC)" == "define"
+# some exclusions, unfortunately, until fixed:
+# - Win32 extension contains overlapped symbols with win32.c (BUG!)
+# - MakeMaker isn't capable enough for SDBM_File (smaller bug)
+# - Encode (encoding search algorithm relies on shared library?)
+STATIC_EXT = * !Win32 !SDBM_File !Encode
+!ELSE
+# specify static extensions here, for example:
#STATIC_EXT = Cwd Compress/Raw/Zlib
STATIC_EXT = Win32CORE
+!ENDIF
DYNALOADER = $(EXTDIR)\DynaLoader\DynaLoader
@@ -822,8 +839,8 @@
# Top targets
#
-all : .\config.h $(GLOBEXE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) $(PERLEXE) \
- $(X2P) MakePPPort Extensions $(PERLSTATIC)
+all : .\config.h $(GLOBEXE) $(MINIMOD) $(CONFIGPM) $(UNIDATAFILES) MakePPPort \
+ $(PERLEXE) $(X2P) Extensions $(PERLSTATIC)
@echo Everything is up to date. '$(MAKE_BARE) test' to run test suite.
..\regnodes.h : ..\regcomp.sym ..\regcomp.pl ..\regexp.h
@@ -1011,7 +1028,7 @@
$(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) $(PERLEXEST_OBJ) $(PERLEXE_RES)
$(LINK32) -subsystem:console -out:$@ -stack:0x1000000 $(LINK_FLAGS) \
- @Extensions_static $(PERLSTATICLIB) \
+ @Extensions_static $(PERLSTATICLIB) /PDB:NONE \
$(LIBFILES) $(PERLEXEST_OBJ) $(SETARGV_OBJ) $(PERLEXE_RES)
$(EMBED_EXE_MANI)
diff -ru bperl-31775-orig/win32/buildext.pl bperl-31775-devsta/win32/buildext.pl
--- bperl-31775-orig/win32/buildext.pl 2006-06-13 23:29:35.000000000 +0400
+++ bperl-31775-devsta/win32/buildext.pl 2007-08-31 23:40:07.671875000 +0400
@@ -63,8 +63,7 @@
print $fh "#ifdef STATIC2\n",(map {" EXTERN_C void boot_$_ (pTHX_ CV* cv);\n"} @statics1),"#undef STATIC2\n#endif\n";
print $fh "#ifdef STATIC3\n",(map {" newXS(\"$statics2[$_]::bootstrap\", boot_$statics1[$_], file);\n"} 0 .. $#statics),"#undef STATIC3\n#endif\n";
close $fh;
- }
- else {
+ } else {
my %extralibs;
for (@statics) {
open my $fh, "<..\\lib\\auto\\$_\\extralibs.ld" or die "can't open <..\\lib\\auto\\$_\\extralibs.ld: $!";
@@ -76,17 +75,14 @@
exit(0);
}
-my $here = getcwd();
+(my $here = getcwd()) =~ s{/}{\\}g;
my $perl = $^X;
-$here =~ s,/,\\,g;
-if ($perl =~ m#^\.\.#)
- {
- $perl = "$here\\$perl";
- }
+if ($perl =~ m#^\.\.#) {
+ $perl = "$here\\$perl";
+}
(my $topdir = $perl) =~ s/\\[^\\]+$//;
# miniperl needs to find perlglob and pl2bat
$ENV{PATH} = "$topdir;$topdir\\win32\\bin;$ENV{PATH}";
-#print "PATH=$ENV{PATH}\n";
my $pl2bat = "$topdir\\win32\\bin\\pl2bat";
unless (-f "$pl2bat.bat") {
my @args = ($perl, ("$pl2bat.pl") x 2);
@@ -100,7 +96,7 @@
my $dir = shift;
chdir($dir) || die "Cannot cd to $dir\n";
my $targ = shift;
-(my $ext = getcwd()) =~ s,/,\\,g;
+(my $ext = getcwd()) =~ s{/}{\\}g;
my $code;
FindExt::scan_ext($ext);
FindExt::set_static_extensions(split ' ', $Config{static_ext}) if $ext ne "ext"; |
From vadim@vkonovalov.ruVadim wrote:
... and I didn't notice that I introduce unneeded extra comment. ok, resending separate patch for .\lib\ExtUtils\Constant\ProxySubs.pm Vadim. |
From vadim@vkonovalov.ruInline Patch--- C:\Personal\builds\bperl-31775-orig\lib\ExtUtils\Constant\ProxySubs.pm 2007-08-31 12:56:29.000000000 +0400
+++ ProxySubs.pm 2007-09-02 00:20:20.468750000 +0400
@@ -312,13 +312,10 @@
print $xs_fh <<"EOBOOT";
#ifndef SYMBIAN
+ ${c_subname}_missing = get_hv("${symbol_table}${c_subname}_M!55!NG", TRUE);
/* When we create the 'missing' hash, it generates a 'used only once'
- * warning. Therefore, turn off warnings while we do this.
- */
- const bool warn_tmp = PL_dowarn;
- PL_dowarn = 0;
+ * warning. Avoid this: */
${c_subname}_missing = get_hv("${symbol_table}${c_subname}_M!55!NG", TRUE);
- PL_dowarn = warn_tmp;
#endif
EOBOOT
|
From @steve-m-hayVadim wrote:
Thanks, applied as #31785. |
From vadim@vkonovalov.ruSteve Hay wrote:
....
Thanks a lot! Fortunately I've found the reason of failed Hash/Util/FieldHash - that's There is a distinction between a module built statically and its I'll send fixer patch, soon. Best regards, |
p5p@spam.wizbit.be - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#44999 (status was 'resolved')
Searchable as RT44999$
The text was updated successfully, but these errors were encountered: