Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 555 forks source link

[PATCH] d002144 RT#65052 Sync full ENV when cygwin perl does "use Win32;" #11946

Closed p5pRT closed 12 years ago

p5pRT commented 12 years ago

Migrated from rt.perl.org#110190 (status was 'resolved')

Searchable as RT110190$

p5pRT commented 12 years ago

From @rurban

This is a bug report for perl from rurban@​cpanel.net\, generated with the help of perlbug 1.39 running under perl 5.15.7.

From d0021449d60b2f34d2beb8e13cbcd855a7ca0946 Mon Sep 17 00​:00​:00 2001 From​: Reini Urban \rurban@​x\-ray\.at Date​: Wed\, 8 Feb 2012 11​:38​:44 -0600 Subject​: [PATCH] RT#65052 Sync full ENV when cygwin perl does "use Win32;"

cygwin strips some win ENV vars on startup which breaks ADODB and more Win32 programs. When cygwin perl does a use Win32 use all initial ENV vars. Patch by Rafael Kitover


cpan/Win32/Win32.xs | 9 +++++++++ 1 files changed\, 9 insertions(+)\, 0 deletions(-)

Inline Patch ```diff diff --git a/cpan/Win32/Win32.xs b/cpan/Win32/Win32.xs index 8af0e88..73580c4 100644 --- a/cpan/Win32/Win32.xs +++ b/cpan/Win32/Win32.xs @@ -1705,6 +1705,14 @@ XS(w32_GetProductInfo) XSRETURN_IV(0); } +#ifdef __CYGWIN__ +#include +/* When cygwin loads Win32.pm it should load the whole ENV to be able + to use %COMMONPROGRAMFILES% and such. + */ +XS(w32_SyncCygwinWin32Env){ cygwin_internal (CW_SYNC_WINENV); } +#endif + MODULE = Win32 PACKAGE = Win32 PROTOTYPES: DISABLE @@ -1770,6 +1778,7 @@ BOOT: newXS("Win32::GetProductInfo", w32_GetProductInfo, file); #ifdef __CYGWIN__ newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file); + newXS("Win32::SyncCygwinWin32Env", w32_SyncCygwinWin32Env, file); #endif XSRETURN_YES; } -- ```

1.7.5.4


Flags​:   category=library   severity=medium   module=Win32


Site configuration information for perl 5.15.7​:

Configured by rurban at Sun Jan 22 12​:13​:34 CST 2012.

Summary of my perl5 (revision 5 version 15 subversion 7) configuration​:  
  Platform​:   osname=linux\, osvers=3.0.0-1-amd64\, archname=x86_64-linux   uname='linux reini 3.0.0-1-amd64 #1 smp sun jul 24 02​:24​:44 utc 2011 x86_64 gnulinux '   config_args='-de -Dusedevel -Dinstallman1dir=none -Dinstallman3dir=none -Dinstallsiteman1dir=none -Dinstallsiteman3dir=none -Uuseithreads -Accflags='-msse4.2' -Accflags='-march=corei7' -Dcf_email='rurban@​cpanel.net' -Dperladmin='rurban@​cpanel.net' -Duseshrplib'   hint=recommended\, useposix=true\, d_sigaction=define   useithreads=undef\, usemultiplicity=undef   useperlio=define\, d_sfio=undef\, uselargefiles=define\, usesocks=undef   use64bitint=define\, use64bitall=define\, uselongdouble=undef   usemymalloc=n\, bincompat5005=undef   Compiler​:   cc='cc'\, ccflags ='-msse4.2 -march=corei7 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'\,   optimize='-O2'\,   cppflags='-msse4.2 -march=corei7 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'   ccversion=''\, gccversion='4.6.1'\, gccosandvers=''   intsize=4\, longsize=8\, ptrsize=8\, doublesize=8\, byteorder=12345678   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=16   ivtype='long'\, ivsize=8\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=8\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -fstack-protector -L/usr/local/lib'   libpth=/usr/local/lib /lib /usr/lib /usr/lib/x86_64-linux-gnu /lib64 /usr/lib64   libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat   perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc   libc=\, so=so\, useshrplib=true\, libperl=libperl.so   gnulibc_version='2.13'   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-Wl\,-E -Wl\,-rpath\,/usr/local/lib/perl5/5.15.7/x86_64-linux/CORE'   cccdlflags='-fPIC'\, lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches​:  


@​INC for perl 5.15.7​:   /usr/local/lib/perl5/site_perl/5.15.7/x86_64-linux   /usr/local/lib/perl5/site_perl/5.15.7   /usr/local/lib/perl5/5.15.7/x86_64-linux   /usr/local/lib/perl5/5.15.7   /usr/local/lib/perl5/site_perl   .


Environment for perl 5.15.7​:   HOME=/home/rurban   LANG=en_US.UTF-8   LANGUAGE (unset)   LD_LIBRARY_PATH (unset)   LOGDIR (unset)   PATH=/usr/local/bin​:/usr/bin​:/bin​:/usr/games   PERL_BADLANG (unset)   SHELL=/bin/bash

p5pRT commented 12 years ago

From @rurban

Scratch the first Win32 patch. Use the attached instead.

After discussion with Jan Dubois I've added your code as Cygwin​::sync_winenv() and revised perlcygwin.pod to use that function when needed. It will be in the upcoming cygwin perl-5.14.2-1 package\, which is now in test.

The problem to load that generally to e.g. Win32 is that cygwin-1.7 warns now on every occurance of non-posix paths. Initially I thought we should do that unconditionally when loading Win32.pm or Win32​::OLE\, but we need some tests before. Better let the users add it when needed. -- Reini Urban

p5pRT commented 12 years ago

From @rurban

0001-added-Cygwin-sync_winenv.-Revise-cygwin-POD.patch ```diff From 9b85795c30d2065d818e49f5c1788f732961cbeb Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Wed, 8 Feb 2012 12:41:45 -0600 Subject: [PATCH] added Cygwin::sync_winenv. Revise cygwin POD Cygwin::sync_winenv should fix [CPAN #65052], ADODB missing %COMMONPROGRAMFILES%. sync_winenv code and solution by Chris Day. --- README.cygwin | 145 ++++++++++++++++++++++++++----------------------------- cygwin/cygwin.c | 3 + 2 files changed, 71 insertions(+), 77 deletions(-) diff --git a/README.cygwin b/README.cygwin index 0888140..910b3fb 100644 --- a/README.cygwin +++ b/README.cygwin @@ -1,5 +1,5 @@ If you read this file _as_is_, just ignore the funny characters you -see. It is written in the POD format (see pod/perlpod.pod) which is +see. It is written in the POD format (see F) which is specially designed to be readable as is. =head1 NAME @@ -31,7 +31,7 @@ L A recent net or commercial release of Cygwin is required. -At the time this document was last updated, Cygwin 1.5.24 was current. +At the time this document was last updated, Cygwin 1.7.10 was current. =head2 Cygwin Configuration @@ -41,8 +41,8 @@ that Perl builds cleanly. These changes are B required for normal Perl usage. B The binaries that are built will run on all Win32 versions. -They do not depend on your host system (Win9x/WinME, WinNT/Win2K) -or your Cygwin configuration (I, I, binary/text mounts). +They do not depend on your host system (WinXP/Win2K/Win7) or your +Cygwin configuration (binary/text mounts, cvgserver). The only dependencies come from hard-coded pathnames like C. However, your host system and Cygwin configuration will affect Perl's runtime behavior (see L). @@ -52,7 +52,7 @@ runtime behavior (see L). =item * C Set the C environment variable so that Configure finds the Cygwin -versions of programs. Any Windows directories should be removed or +versions of programs. Any not-needed Windows directories should be removed or moved to the end of your C. =item * I @@ -60,28 +60,13 @@ moved to the end of your C. If you do not have I (which is part of the I package), Configure will B prompt you to install I pages. -=item * Permissions - -On WinNT with either the I or I C settings, directory -and file permissions may not be set correctly. Since the build process -creates directories and files, to be safe you may want to run a -C on the entire Perl source tree. - -Also, it is a well known WinNT "feature" that files created by a login -that is a member of the I group will be owned by the -I group. Depending on your umask, you may find that you -can not write to files that you just created (because you are no longer -the owner). When using the I C setting, this is not an -issue because it "corrects" the ownership to what you would expect on -a UNIX system. - =back =head1 CONFIGURE PERL ON CYGWIN The default options gathered by Configure with the assistance of F will build a Perl that supports dynamic loading -(which requires a shared F). +(which requires a shared F). This will run Configure and keep a record: @@ -122,17 +107,6 @@ DES crypt port by Corinna Vinschen. Alternatively, the crypt libraries in GNU libc have been ported to Cygwin. -The DES based Ultra Fast Crypt port was done by Alexey Truhan: - - ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin/porters/Okhapkin_Sergey/cw32crypt-dist-0.tgz - -NOTE: There are various export restrictions on DES implementations, -see the glibc README for more details. - -The MD5 port was done by Andy Piper: - - ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin/porters/Okhapkin_Sergey/libcrypt.tgz - =item * C<-lgdbm_compat> (C) GDBM is available for Cygwin. @@ -143,8 +117,7 @@ NOTE: The GDBM library only works on NTFS partitions. BerkeleyDB is available for Cygwin. -NOTE: The BerkeleyDB library only completely works on NTFS partitions -and db-4.3 is flawed. +NOTE: The BerkeleyDB library only completely works on NTFS partitions. =item * C (C) @@ -177,10 +150,11 @@ prompts you or you can define (undefine) symbols on the command line. Undefining this symbol forces Perl to be compiled statically. -=item * C<-Uusemymalloc> +=item * C<-Dusemymalloc> -By default Perl uses the C included with the Perl source. If you -want to force Perl to build with the system C undefine this symbol. +By default Perl does not use the C included with the Perl source, +because it was slower and not entirely thread-safe. If you want to force +Perl to build with the old -Dusemymalloc define this. =item * C<-Uuseperlio> @@ -190,12 +164,13 @@ default; it is not recommended to disable PerlIO. =item * C<-Dusemultiplicity> Multiplicity is required when embedding Perl in a C program and using -more than one interpreter instance. This works with the Cygwin port. +more than one interpreter instance. This is only required when you build +a not-threaded perl with C<-Uuseithreads>. -=item * C<-Duse64bitint> +=item * C<-Uuse64bitint> -By default Perl uses 32 bit integers. If you want to use larger 64 -bit integers, define this symbol. +By default Perl uses 64 bit integers. If you want to use smaller 32 bit +integers, define this symbol. =item * C<-Duselongdouble> @@ -203,12 +178,11 @@ I supports long doubles (12 bytes). However, several additional long double math functions are necessary to use them within Perl (I<{atan2, cos, exp, floor, fmod, frexp, isnan, log, modf, pow, sin, sqrt}l, strtold>). -These are B yet available with Cygwin. +These are B yet available with newlib, the Cygwin libc. -=item * C<-Dusethreads> +=item * C<-Uuseithreads> -POSIX threads are implemented in Cygwin, define this symbol if you want -a threaded perl. +Define this symbol if you want not-threaded faster perl. =item * C<-Duselargefiles> @@ -217,9 +191,9 @@ this will be correctly detected and defined by Configure. =item * C<-Dmksymlinks> -Use this to build perl outside of the source tree. This works with Cygwin. -Details can be found in the F document. This is the recommended -way to build perl from sources. +Use this to build perl outside of the source tree. Details can be +found in the F document. This is the recommended way to +build perl from sources. =back @@ -349,29 +323,25 @@ to portability, more information can be found in the Cygwin documentation. =item * Pathnames -Cygwin pathnames can be separated by forward (F) or backward (F<\\>) -slashes. They may also begin with drive letters (F) or Universal -Naming Codes (F). DOS device names (F, F, F, -F, F, F) are invalid as base filenames. However, they -can be used in extensions (e.g., F). Names may contain all -printable characters except these: - - : * ? " < > | +Cygwin pathnames are separated by forward (F) slashes, Universal +Naming Codes (F) are also supported Since cygwin-1.7 non-POSIX +pathnames are disencouraged. Names may contain all printable +characters. File names are case insensitive, but case preserving. A pathname that -contains a backslash or drive letter is a Win32 pathname (and not subject -to the translations applied to POSIX style pathnames). +contains a backslash or drive letter is a Win32 pathname, and not +subject to the translations applied to POSIX style pathnames, but +cygwin will warn you, so better convert them to POSIX. For conversion we have C and C. -Pathnames may not contain Unicode characters. C still uses the -ANSI API calls and no Unicode calls because of newlib deficiencies. -There's an unofficial unicode patch for cygwin at -L +Since cygwin-1.7 pathnames are UTF-8 encoded. =item * Text/Binary +Since cywgin-1.7 textmounts are deprecated and stronlgy discouraged. + When a file is opened it is in either text or binary mode. In text mode a file is subject to CR/LF/Ctrl-Z translations. With Cygwin, the default mode for an C is determined by the mode of the mount that underlies @@ -411,8 +381,8 @@ extension transparent by looking for F when you ask for F (unless a F also exists). Cygwin does not require a F<.exe> extension, but I adds it automatically when building a program. However, when accessing an executable as a normal file (e.g., I -in a makefile) the F<.exe> is not transparent. The I included -with Cygwin automatically appends a F<.exe> when necessary. +in a makefile) the F<.exe> is not transparent. The I program +included with Cygwin automatically appends a F<.exe> when necessary. =item * Cygwin vs. Windows process ids @@ -428,6 +398,28 @@ to translate between them. Under Cygwin, $^E is the same as $!. When using L, use C to get the last Windows error. +=item * rebase errors on fork or system + +Using C or C out to another perl after loading multiple dlls +may result on a DLL baseaddress conflict. The internal cygwin error +looks like like the following: + + C:\CYGWIN\BIN\PERL.EXE: *** couldn't allocate memory 0x10000(4128768) for 'C:\CYGWIN\LIB\PERL5\5.6.1\CYGWIN-MULTI\AUTO\SOCKET\SOCKET.DLL' alignment, Win32 error 8 + + 200 [main] perl 377147 sync_with_child: child -395691(0xB8) died before initialization with status code 0x1 + 1370 [main] perl 377147 sync_with_child: *** child state child loading dlls + +It helps if not too many DLLs are loaded in memory so the available address space is larger, +e.g. stopping the MS Internet Explorer might help. + +Use the perlrebase or rebase utilities to resolve the conflicting dll addresses. +The rebase package is included in the Cygwin setup. Use F +from L to install it. + +1. kill all perl processes and run C or + +2. kill all cygwin processes and services, start dash from cmd.exe and run C. + =item * C On WinNT C can change a file's user and group IDs. On Win9x C @@ -448,18 +440,6 @@ of the file being edited C because of windowish restrictions, therefore Perl adds the suffix C<.bak> automatically if you use C without specifying a backup extension. -Using C after loading multiple dlls may fail with an internal cygwin -error like the following: - - C:\CYGWIN\BIN\PERL.EXE: *** couldn't allocate memory 0x10000(4128768) for 'C:\CYGWIN\LIB\PERL5\5.6.1\CYGWIN-MULTI\AUTO\SOCKET\SOCKET.DLL' alignment, Win32 error 8 - - 200 [main] perl 377147 sync_with_child: child -395691(0xB8) died before initialization with status code 0x1 - 1370 [main] perl 377147 sync_with_child: *** child state child loading dlls - -Use the rebase utility to resolve the conflicting dll addresses. The -rebase package is included in the Cygwin netrelease. Use setup.exe from -L to install it and run rebaseall. - =back =head2 Prebuilt methods: @@ -529,6 +509,17 @@ User mounts override system mounts. Returns true if the given cygwin path is binary mounted, false if the path is mounted in textmode. +=item C + +Cygwin does not initialize all original Win32 environment variables. +See the bottom of this page L +for "Restricted Win32 environment". + +Certain Win32 programs called from cygwin program might need some environment +variable, such as e.g. ADODB needs %COMMONPROGRAMFILES%. +Call Cygwin::sync_winenv() to copy all Win32 environment variables to your +process and note that cygwin will warn on every encounter of non-POSIX paths. + =back =head1 INSTALL PERL ON CYGWIN @@ -781,4 +772,4 @@ Jerry D. Hedden . =head1 HISTORY -Last updated: 2007-09-25 +Last updated: 2012-02-08 diff --git a/cygwin/cygwin.c b/cygwin/cygwin.c index 0f5fe1d..ad46fb5 100644 --- a/cygwin/cygwin.c +++ b/cygwin/cygwin.c @@ -538,6 +538,8 @@ XS(XS_Cygwin_is_binmount) XSRETURN(1); } +XS(XS_Cygwin_sync_winenv){ cygwin_internal(CW_SYNC_WINENV); } + void init_os_extras(void) { @@ -553,6 +555,7 @@ init_os_extras(void) newXSproto("Cygwin::mount_table", XS_Cygwin_mount_table, file, ""); newXSproto("Cygwin::mount_flags", XS_Cygwin_mount_flags, file, "$"); newXSproto("Cygwin::is_binmount", XS_Cygwin_is_binmount, file, "$"); + newXS("Cygwin::sync_winenv", XS_Cygwin_sync_winenv); /* Initialize Win32CORE if it has been statically linked. */ handle = dlopen(NULL, RTLD_LAZY); -- 1.7.5.4 ```
p5pRT commented 12 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 12 years ago

From @rurban

The 2nd patch had a syntax error in newXS\, sorry\, didn't test. 3rd patch attached. -- Reini Urban

p5pRT commented 12 years ago

From @rurban

added-Cygwin-sync_winenv.-Revise-cygwin-POD-3.patch ```diff commit a994b04e42ae3d8b8eccbbd85c6ac73f762a2acf Author: Reini Urban Date: Wed Feb 8 12:41:45 2012 -0600 added Cygwin::sync_winenv. Revise cygwin POD Cygwin::sync_winenv should fix [CPAN #65052], ADODB missing %COMMONPROGRAMFILES%. sync_winenv code and solution by Chris Day. diff --git a/README.cygwin b/README.cygwin index 0888140..910b3fb 100644 --- a/README.cygwin +++ b/README.cygwin @@ -1,5 +1,5 @@ If you read this file _as_is_, just ignore the funny characters you -see. It is written in the POD format (see pod/perlpod.pod) which is +see. It is written in the POD format (see F) which is specially designed to be readable as is. =head1 NAME @@ -31,7 +31,7 @@ L A recent net or commercial release of Cygwin is required. -At the time this document was last updated, Cygwin 1.5.24 was current. +At the time this document was last updated, Cygwin 1.7.10 was current. =head2 Cygwin Configuration @@ -41,8 +41,8 @@ that Perl builds cleanly. These changes are B required for normal Perl usage. B The binaries that are built will run on all Win32 versions. -They do not depend on your host system (Win9x/WinME, WinNT/Win2K) -or your Cygwin configuration (I, I, binary/text mounts). +They do not depend on your host system (WinXP/Win2K/Win7) or your +Cygwin configuration (binary/text mounts, cvgserver). The only dependencies come from hard-coded pathnames like C. However, your host system and Cygwin configuration will affect Perl's runtime behavior (see L). @@ -52,7 +52,7 @@ runtime behavior (see L). =item * C Set the C environment variable so that Configure finds the Cygwin -versions of programs. Any Windows directories should be removed or +versions of programs. Any not-needed Windows directories should be removed or moved to the end of your C. =item * I @@ -60,28 +60,13 @@ moved to the end of your C. If you do not have I (which is part of the I package), Configure will B prompt you to install I pages. -=item * Permissions - -On WinNT with either the I or I C settings, directory -and file permissions may not be set correctly. Since the build process -creates directories and files, to be safe you may want to run a -C on the entire Perl source tree. - -Also, it is a well known WinNT "feature" that files created by a login -that is a member of the I group will be owned by the -I group. Depending on your umask, you may find that you -can not write to files that you just created (because you are no longer -the owner). When using the I C setting, this is not an -issue because it "corrects" the ownership to what you would expect on -a UNIX system. - =back =head1 CONFIGURE PERL ON CYGWIN The default options gathered by Configure with the assistance of F will build a Perl that supports dynamic loading -(which requires a shared F). +(which requires a shared F). This will run Configure and keep a record: @@ -122,17 +107,6 @@ DES crypt port by Corinna Vinschen. Alternatively, the crypt libraries in GNU libc have been ported to Cygwin. -The DES based Ultra Fast Crypt port was done by Alexey Truhan: - - ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin/porters/Okhapkin_Sergey/cw32crypt-dist-0.tgz - -NOTE: There are various export restrictions on DES implementations, -see the glibc README for more details. - -The MD5 port was done by Andy Piper: - - ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin/porters/Okhapkin_Sergey/libcrypt.tgz - =item * C<-lgdbm_compat> (C) GDBM is available for Cygwin. @@ -143,8 +117,7 @@ NOTE: The GDBM library only works on NTFS partitions. BerkeleyDB is available for Cygwin. -NOTE: The BerkeleyDB library only completely works on NTFS partitions -and db-4.3 is flawed. +NOTE: The BerkeleyDB library only completely works on NTFS partitions. =item * C (C) @@ -177,10 +150,11 @@ prompts you or you can define (undefine) symbols on the command line. Undefining this symbol forces Perl to be compiled statically. -=item * C<-Uusemymalloc> +=item * C<-Dusemymalloc> -By default Perl uses the C included with the Perl source. If you -want to force Perl to build with the system C undefine this symbol. +By default Perl does not use the C included with the Perl source, +because it was slower and not entirely thread-safe. If you want to force +Perl to build with the old -Dusemymalloc define this. =item * C<-Uuseperlio> @@ -190,12 +164,13 @@ default; it is not recommended to disable PerlIO. =item * C<-Dusemultiplicity> Multiplicity is required when embedding Perl in a C program and using -more than one interpreter instance. This works with the Cygwin port. +more than one interpreter instance. This is only required when you build +a not-threaded perl with C<-Uuseithreads>. -=item * C<-Duse64bitint> +=item * C<-Uuse64bitint> -By default Perl uses 32 bit integers. If you want to use larger 64 -bit integers, define this symbol. +By default Perl uses 64 bit integers. If you want to use smaller 32 bit +integers, define this symbol. =item * C<-Duselongdouble> @@ -203,12 +178,11 @@ I supports long doubles (12 bytes). However, several additional long double math functions are necessary to use them within Perl (I<{atan2, cos, exp, floor, fmod, frexp, isnan, log, modf, pow, sin, sqrt}l, strtold>). -These are B yet available with Cygwin. +These are B yet available with newlib, the Cygwin libc. -=item * C<-Dusethreads> +=item * C<-Uuseithreads> -POSIX threads are implemented in Cygwin, define this symbol if you want -a threaded perl. +Define this symbol if you want not-threaded faster perl. =item * C<-Duselargefiles> @@ -217,9 +191,9 @@ this will be correctly detected and defined by Configure. =item * C<-Dmksymlinks> -Use this to build perl outside of the source tree. This works with Cygwin. -Details can be found in the F document. This is the recommended -way to build perl from sources. +Use this to build perl outside of the source tree. Details can be +found in the F document. This is the recommended way to +build perl from sources. =back @@ -349,29 +323,25 @@ to portability, more information can be found in the Cygwin documentation. =item * Pathnames -Cygwin pathnames can be separated by forward (F) or backward (F<\\>) -slashes. They may also begin with drive letters (F) or Universal -Naming Codes (F). DOS device names (F, F, F, -F, F, F) are invalid as base filenames. However, they -can be used in extensions (e.g., F). Names may contain all -printable characters except these: - - : * ? " < > | +Cygwin pathnames are separated by forward (F) slashes, Universal +Naming Codes (F) are also supported Since cygwin-1.7 non-POSIX +pathnames are disencouraged. Names may contain all printable +characters. File names are case insensitive, but case preserving. A pathname that -contains a backslash or drive letter is a Win32 pathname (and not subject -to the translations applied to POSIX style pathnames). +contains a backslash or drive letter is a Win32 pathname, and not +subject to the translations applied to POSIX style pathnames, but +cygwin will warn you, so better convert them to POSIX. For conversion we have C and C. -Pathnames may not contain Unicode characters. C still uses the -ANSI API calls and no Unicode calls because of newlib deficiencies. -There's an unofficial unicode patch for cygwin at -L +Since cygwin-1.7 pathnames are UTF-8 encoded. =item * Text/Binary +Since cywgin-1.7 textmounts are deprecated and stronlgy discouraged. + When a file is opened it is in either text or binary mode. In text mode a file is subject to CR/LF/Ctrl-Z translations. With Cygwin, the default mode for an C is determined by the mode of the mount that underlies @@ -411,8 +381,8 @@ extension transparent by looking for F when you ask for F (unless a F also exists). Cygwin does not require a F<.exe> extension, but I adds it automatically when building a program. However, when accessing an executable as a normal file (e.g., I -in a makefile) the F<.exe> is not transparent. The I included -with Cygwin automatically appends a F<.exe> when necessary. +in a makefile) the F<.exe> is not transparent. The I program +included with Cygwin automatically appends a F<.exe> when necessary. =item * Cygwin vs. Windows process ids @@ -428,6 +398,28 @@ to translate between them. Under Cygwin, $^E is the same as $!. When using L, use C to get the last Windows error. +=item * rebase errors on fork or system + +Using C or C out to another perl after loading multiple dlls +may result on a DLL baseaddress conflict. The internal cygwin error +looks like like the following: + + C:\CYGWIN\BIN\PERL.EXE: *** couldn't allocate memory 0x10000(4128768) for 'C:\CYGWIN\LIB\PERL5\5.6.1\CYGWIN-MULTI\AUTO\SOCKET\SOCKET.DLL' alignment, Win32 error 8 + + 200 [main] perl 377147 sync_with_child: child -395691(0xB8) died before initialization with status code 0x1 + 1370 [main] perl 377147 sync_with_child: *** child state child loading dlls + +It helps if not too many DLLs are loaded in memory so the available address space is larger, +e.g. stopping the MS Internet Explorer might help. + +Use the perlrebase or rebase utilities to resolve the conflicting dll addresses. +The rebase package is included in the Cygwin setup. Use F +from L to install it. + +1. kill all perl processes and run C or + +2. kill all cygwin processes and services, start dash from cmd.exe and run C. + =item * C On WinNT C can change a file's user and group IDs. On Win9x C @@ -448,18 +440,6 @@ of the file being edited C because of windowish restrictions, therefore Perl adds the suffix C<.bak> automatically if you use C without specifying a backup extension. -Using C after loading multiple dlls may fail with an internal cygwin -error like the following: - - C:\CYGWIN\BIN\PERL.EXE: *** couldn't allocate memory 0x10000(4128768) for 'C:\CYGWIN\LIB\PERL5\5.6.1\CYGWIN-MULTI\AUTO\SOCKET\SOCKET.DLL' alignment, Win32 error 8 - - 200 [main] perl 377147 sync_with_child: child -395691(0xB8) died before initialization with status code 0x1 - 1370 [main] perl 377147 sync_with_child: *** child state child loading dlls - -Use the rebase utility to resolve the conflicting dll addresses. The -rebase package is included in the Cygwin netrelease. Use setup.exe from -L to install it and run rebaseall. - =back =head2 Prebuilt methods: @@ -529,6 +509,17 @@ User mounts override system mounts. Returns true if the given cygwin path is binary mounted, false if the path is mounted in textmode. +=item C + +Cygwin does not initialize all original Win32 environment variables. +See the bottom of this page L +for "Restricted Win32 environment". + +Certain Win32 programs called from cygwin program might need some environment +variable, such as e.g. ADODB needs %COMMONPROGRAMFILES%. +Call Cygwin::sync_winenv() to copy all Win32 environment variables to your +process and note that cygwin will warn on every encounter of non-POSIX paths. + =back =head1 INSTALL PERL ON CYGWIN @@ -781,4 +772,4 @@ Jerry D. Hedden . =head1 HISTORY -Last updated: 2007-09-25 +Last updated: 2012-02-08 diff --git a/cygwin/cygwin.c b/cygwin/cygwin.c index 0f5fe1d..9419e83 100644 --- a/cygwin/cygwin.c +++ b/cygwin/cygwin.c @@ -538,6 +538,8 @@ XS(XS_Cygwin_is_binmount) XSRETURN(1); } +XS(XS_Cygwin_sync_winenv){ cygwin_internal(CW_SYNC_WINENV); } + void init_os_extras(void) { @@ -553,6 +555,7 @@ init_os_extras(void) newXSproto("Cygwin::mount_table", XS_Cygwin_mount_table, file, ""); newXSproto("Cygwin::mount_flags", XS_Cygwin_mount_flags, file, "$"); newXSproto("Cygwin::is_binmount", XS_Cygwin_is_binmount, file, "$"); + newXS("Cygwin::sync_winenv", XS_Cygwin_sync_winenv, file); /* Initialize Win32CORE if it has been statically linked. */ handle = dlopen(NULL, RTLD_LAZY); ```
p5pRT commented 12 years ago

From @tonycoz

On Wed\, Feb 08\, 2012 at 02​:18​:16PM -0800\, Reini Urban via RT wrote​:

The 2nd patch had a syntax error in newXS\, sorry\, didn't test. 3rd patch attached. -- Reini Urban

--- via perlbug​: queue​: perl5 status​: open https://rt-archive.perl.org/perl5/Ticket/Display.html?id=110190

commit a994b04e42ae3d8b8eccbbd85c6ac73f762a2acf Author​: Reini Urban \rurban@&#8203;x\-ray\.at Date​: Wed Feb 8 12​:41​:45 2012 -0600

added Cygwin&#8203;::sync\_winenv\. Revise cygwin POD

Cygwin&#8203;::sync\_winenv should fix \[CPAN \#65052\]\, ADODB missing
%COMMONPROGRAMFILES%\.
sync\_winenv code and solution by Chris Day\.

diff --git a/README.cygwin b/README.cygwin index 0888140..910b3fb 100644 --- a/README.cygwin +++ b/README.cygwin @​@​ -1\,5 +1\,5 @​@​ If you read this file _as_is_\, just ignore the funny characters you -see. It is written in the POD format (see pod/perlpod.pod) which is +see. It is written in the POD format (see F\<pod/perlpod.pod>) which is specially designed to be readable as is.

I'd be more comfortable with this if the general README.cygwin patch was a separate commit from the _sync change.

Tony

p5pRT commented 12 years ago

From @rurban

This is a bug report for perl from rurban@​cpanel.net\, generated with the help of perlbug 1.39 running under perl 5.15.7.

From 08f57550b4ef0a144f3c65daa88744e5b46b7232 Mon Sep 17 00​:00​:00 2001 From​: Reini Urban \rurban@&#8203;x\-ray\.at Date​: Wed\, 8 Feb 2012 17​:51​:39 -0600 Subject​: [PATCH 1/2] Revise perlcygwin.pod for cygwin-1.7

cygwin does not support windows prior NT5 anymore. cygwin paths are now all UTF8 encoded\, special pathname characters and names are now allowed. Removed outdated cruft and fix wrong parts.


README.cygwin | 138 +++++++++++++++++++++++++-------------------------------- 1 files changed\, 61 insertions(+)\, 77 deletions(-)

Inline Patch ```diff diff --git a/README.cygwin b/README.cygwin index 0888140..017c452 100644 --- a/README.cygwin +++ b/README.cygwin @@ -1,5 +1,5 @@ If you read this file _as_is_, just ignore the funny characters you -see. It is written in the POD format (see pod/perlpod.pod) which is +see. It is written in the POD format (see F) which is specially designed to be readable as is. =head1 NAME @@ -31,7 +31,7 @@ L A recent net or commercial release of Cygwin is required. -At the time this document was last updated, Cygwin 1.5.24 was current. +At the time this document was last updated, Cygwin 1.7.10 was current. =head2 Cygwin Configuration @@ -41,8 +41,8 @@ that Perl builds cleanly. These changes are B required for normal Perl usage. B The binaries that are built will run on all Win32 versions. -They do not depend on your host system (Win9x/WinME, WinNT/Win2K) -or your Cygwin configuration (I, I, binary/text mounts). +They do not depend on your host system (WinXP/Win2K/Win7) or your +Cygwin configuration (binary/text mounts, cvgserver). The only dependencies come from hard-coded pathnames like C. However, your host system and Cygwin configuration will affect Perl's runtime behavior (see L). @@ -52,7 +52,7 @@ runtime behavior (see L). =item * C Set the C environment variable so that Configure finds the Cygwin -versions of programs. Any Windows directories should be removed or +versions of programs. Any not-needed Windows directories should be removed or moved to the end of your C. =item * I @@ -60,28 +60,13 @@ moved to the end of your C. If you do not have I (which is part of the I package), Configure will B prompt you to install I pages. -=item * Permissions - -On WinNT with either the I or I C settings, directory -and file permissions may not be set correctly. Since the build process -creates directories and files, to be safe you may want to run a -C on the entire Perl source tree. - -Also, it is a well known WinNT "feature" that files created by a login -that is a member of the I group will be owned by the -I group. Depending on your umask, you may find that you -can not write to files that you just created (because you are no longer -the owner). When using the I C setting, this is not an -issue because it "corrects" the ownership to what you would expect on -a UNIX system. - =back =head1 CONFIGURE PERL ON CYGWIN The default options gathered by Configure with the assistance of F will build a Perl that supports dynamic loading -(which requires a shared F). +(which requires a shared F). This will run Configure and keep a record: @@ -122,17 +107,6 @@ DES crypt port by Corinna Vinschen. Alternatively, the crypt libraries in GNU libc have been ported to Cygwin. -The DES based Ultra Fast Crypt port was done by Alexey Truhan: - - ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin/porters/Okhapkin_Sergey/cw32crypt-dist-0.tgz - -NOTE: There are various export restrictions on DES implementations, -see the glibc README for more details. - -The MD5 port was done by Andy Piper: - - ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin/porters/Okhapkin_Sergey/libcrypt.tgz - =item * C<-lgdbm_compat> (C) GDBM is available for Cygwin. @@ -143,8 +117,7 @@ NOTE: The GDBM library only works on NTFS partitions. BerkeleyDB is available for Cygwin. -NOTE: The BerkeleyDB library only completely works on NTFS partitions -and db-4.3 is flawed. +NOTE: The BerkeleyDB library only completely works on NTFS partitions. =item * C (C) @@ -177,10 +150,11 @@ prompts you or you can define (undefine) symbols on the command line. Undefining this symbol forces Perl to be compiled statically. -=item * C<-Uusemymalloc> +=item * C<-Dusemymalloc> -By default Perl uses the C included with the Perl source. If you -want to force Perl to build with the system C undefine this symbol. +By default Perl does not use the C included with the Perl source, +because it was slower and not entirely thread-safe. If you want to force +Perl to build with the old -Dusemymalloc define this. =item * C<-Uuseperlio> @@ -190,12 +164,13 @@ default; it is not recommended to disable PerlIO. =item * C<-Dusemultiplicity> Multiplicity is required when embedding Perl in a C program and using -more than one interpreter instance. This works with the Cygwin port. +more than one interpreter instance. This is only required when you build +a not-threaded perl with C<-Uuseithreads>. -=item * C<-Duse64bitint> +=item * C<-Uuse64bitint> -By default Perl uses 32 bit integers. If you want to use larger 64 -bit integers, define this symbol. +By default Perl uses 64 bit integers. If you want to use smaller 32 bit +integers, define this symbol. =item * C<-Duselongdouble> @@ -203,12 +178,11 @@ I supports long doubles (12 bytes). However, several additional long double math functions are necessary to use them within Perl (I<{atan2, cos, exp, floor, fmod, frexp, isnan, log, modf, pow, sin, sqrt}l, strtold>). -These are B yet available with Cygwin. +These are B yet available with newlib, the Cygwin libc. -=item * C<-Dusethreads> +=item * C<-Uuseithreads> -POSIX threads are implemented in Cygwin, define this symbol if you want -a threaded perl. +Define this symbol if you want not-threaded faster perl. =item * C<-Duselargefiles> @@ -217,9 +191,9 @@ this will be correctly detected and defined by Configure. =item * C<-Dmksymlinks> -Use this to build perl outside of the source tree. This works with Cygwin. -Details can be found in the F document. This is the recommended -way to build perl from sources. +Use this to build perl outside of the source tree. Details can be +found in the F document. This is the recommended way to +build perl from sources. =back @@ -349,29 +323,25 @@ to portability, more information can be found in the Cygwin documentation. =item * Pathnames -Cygwin pathnames can be separated by forward (F) or backward (F<\\>) -slashes. They may also begin with drive letters (F) or Universal -Naming Codes (F). DOS device names (F, F, F, -F, F, F) are invalid as base filenames. However, they -can be used in extensions (e.g., F). Names may contain all -printable characters except these: - - : * ? " < > | +Cygwin pathnames are separated by forward (F) slashes, Universal +Naming Codes (F) are also supported Since cygwin-1.7 non-POSIX +pathnames are disencouraged. Names may contain all printable +characters. File names are case insensitive, but case preserving. A pathname that -contains a backslash or drive letter is a Win32 pathname (and not subject -to the translations applied to POSIX style pathnames). +contains a backslash or drive letter is a Win32 pathname, and not +subject to the translations applied to POSIX style pathnames, but +cygwin will warn you, so better convert them to POSIX. For conversion we have C and C. -Pathnames may not contain Unicode characters. C still uses the -ANSI API calls and no Unicode calls because of newlib deficiencies. -There's an unofficial unicode patch for cygwin at -L +Since cygwin-1.7 pathnames are UTF-8 encoded. =item * Text/Binary +Since cywgin-1.7 textmounts are deprecated and stronlgy discouraged. + When a file is opened it is in either text or binary mode. In text mode a file is subject to CR/LF/Ctrl-Z translations. With Cygwin, the default mode for an C is determined by the mode of the mount that underlies @@ -411,8 +381,8 @@ extension transparent by looking for F when you ask for F (unless a F also exists). Cygwin does not require a F<.exe> extension, but I adds it automatically when building a program. However, when accessing an executable as a normal file (e.g., I -in a makefile) the F<.exe> is not transparent. The I included -with Cygwin automatically appends a F<.exe> when necessary. +in a makefile) the F<.exe> is not transparent. The I program +included with Cygwin automatically appends a F<.exe> when necessary. =item * Cygwin vs. Windows process ids @@ -428,6 +398,32 @@ to translate between them. Under Cygwin, $^E is the same as $!. When using L, use C to get the last Windows error. +=item * rebase errors on fork or system + +Using C or C out to another perl after loading multiple dlls +may result on a DLL baseaddress conflict. The internal cygwin error +looks like like the following: + + 0 [main] perl 8916 child_info_fork::abort: data segment start: parent + (0xC1A000) != child(0xA6A000) + +or: + + 183 [main] perl 3588 C:\cygwin\bin\perl.exe: *** fatal error - unable to remap C:\cygwin\bin\cygsvn_subr-1-0.dll to same address as parent(0x6FB30000) != 0x6FE60000 + 46 [main] perl 3488 fork: child 3588 - died waiting for dll loading, errno11 + +See L +It helps if not too many DLLs are loaded in memory so the available address space is larger, +e.g. stopping the MS Internet Explorer might help. + +Use the perlrebase or rebase utilities to resolve the conflicting dll addresses. +The rebase package is included in the Cygwin setup. Use F +from L to install it. + +1. kill all perl processes and run C or + +2. kill all cygwin processes and services, start dash from cmd.exe and run C. + =item * C On WinNT C can change a file's user and group IDs. On Win9x C @@ -448,18 +444,6 @@ of the file being edited C because of windowish restrictions, therefore Perl adds the suffix C<.bak> automatically if you use C without specifying a backup extension. -Using C after loading multiple dlls may fail with an internal cygwin -error like the following: - - C:\CYGWIN\BIN\PERL.EXE: *** couldn't allocate memory 0x10000(4128768) for 'C:\CYGWIN\LIB\PERL5\5.6.1\CYGWIN-MULTI\AUTO\SOCKET\SOCKET.DLL' alignment, Win32 error 8 - - 200 [main] perl 377147 sync_with_child: child -395691(0xB8) died before initialization with status code 0x1 - 1370 [main] perl 377147 sync_with_child: *** child state child loading dlls - -Use the rebase utility to resolve the conflicting dll addresses. The -rebase package is included in the Cygwin netrelease. Use setup.exe from -L to install it and run rebaseall. - =back =head2 Prebuilt methods: @@ -781,4 +765,4 @@ Jerry D. Hedden . =head1 HISTORY -Last updated: 2007-09-25 +Last updated: 2012-02-08 -- ```

1.7.5.4


Flags​:   category=docs   severity=medium


Site configuration information for perl 5.15.7​:

Configured by rurban at Sun Jan 22 12​:13​:34 CST 2012.

Summary of my perl5 (revision 5 version 15 subversion 7) configuration​:  
  Platform​:   osname=linux\, osvers=3.0.0-1-amd64\, archname=x86_64-linux   uname='linux reini 3.0.0-1-amd64 #1 smp sun jul 24 02​:24​:44 utc 2011 x86_64 gnulinux '   config_args='-de -Dusedevel -Dinstallman1dir=none -Dinstallman3dir=none -Dinstallsiteman1dir=none -Dinstallsiteman3dir=none -Uuseithreads -Accflags='-msse4.2' -Accflags='-march=corei7' -Dcf_email='rurban@​cpanel.net' -Dperladmin='rurban@​cpanel.net' -Duseshrplib'   hint=recommended\, useposix=true\, d_sigaction=define   useithreads=undef\, usemultiplicity=undef   useperlio=define\, d_sfio=undef\, uselargefiles=define\, usesocks=undef   use64bitint=define\, use64bitall=define\, uselongdouble=undef   usemymalloc=n\, bincompat5005=undef   Compiler​:   cc='cc'\, ccflags ='-msse4.2 -march=corei7 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'\,   optimize='-O2'\,   cppflags='-msse4.2 -march=corei7 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'   ccversion=''\, gccversion='4.6.1'\, gccosandvers=''   intsize=4\, longsize=8\, ptrsize=8\, doublesize=8\, byteorder=12345678   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=16   ivtype='long'\, ivsize=8\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=8\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -fstack-protector -L/usr/local/lib'   libpth=/usr/local/lib /lib /usr/lib /usr/lib/x86_64-linux-gnu /lib64 /usr/lib64   libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat   perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc   libc=\, so=so\, useshrplib=true\, libperl=libperl.so   gnulibc_version='2.13'   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-Wl\,-E -Wl\,-rpath\,/usr/local/lib/perl5/5.15.7/x86_64-linux/CORE'   cccdlflags='-fPIC'\, lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches​:  


@​INC for perl 5.15.7​:   /usr/local/lib/perl5/site_perl/5.15.7/x86_64-linux   /usr/local/lib/perl5/site_perl/5.15.7   /usr/local/lib/perl5/5.15.7/x86_64-linux   /usr/local/lib/perl5/5.15.7   /usr/local/lib/perl5/site_perl   .


Environment for perl 5.15.7​:   HOME=/home/rurban   LANG=en_US.UTF-8   LANGUAGE (unset)   LD_LIBRARY_PATH (unset)   LOGDIR (unset)   PATH=/home/rurban/bin​:/usr/local/bin​:/usr/bin​:/bin​:/usr/games   PERL_BADLANG (unset)   SHELL=/bin/bash

p5pRT commented 12 years ago

From @rurban

On Wed Feb 08 14​:54​:19 2012\, tonyc wrote​:

--- a/README.cygwin +++ b/README.cygwin @​@​ -1\,5 +1\,5 @​@​ If you read this file _as_is_\, just ignore the funny characters you -see. It is written in the POD format (see pod/perlpod.pod) which is +see. It is written in the POD format (see F\<pod/perlpod.pod>) which is specially designed to be readable as is.

I'd be more comfortable with this if the general README.cygwin patch was a separate commit from the _sync change.

Sure. part #1 is now at RT# (no number yet) "Revise perlcygwin.pod for cygwin- 1.7" part #2 attached as 0001-add-Cygwin-sync_winenv-perl-110190.patch

-- Reini Urban

p5pRT commented 12 years ago

From @rurban

0002-add-Cygwin-sync_winenv-perl-110190.patch ```diff From aeeadb3266f7a959b8fc5bb1547c26979268c432 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Wed, 8 Feb 2012 17:58:21 -0600 Subject: [PATCH 2/2] add Cygwin::sync_winenv [perl #110190] Cygwin::sync_winenv should fix [CPAN #65052], ADODB missing %COMMONPROGRAMFILES%. sync_winenv code and solution by Chris Day. --- README.cygwin | 11 +++++++++++ cygwin/cygwin.c | 3 +++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/README.cygwin b/README.cygwin index 017c452..4e3e6f5 100644 --- a/README.cygwin +++ b/README.cygwin @@ -513,6 +513,17 @@ User mounts override system mounts. Returns true if the given cygwin path is binary mounted, false if the path is mounted in textmode. +=item C + +Cygwin does not initialize all original Win32 environment variables. +See the bottom of this page L +for "Restricted Win32 environment". + +Certain Win32 programs called from cygwin programs might need some environment +variable, such as e.g. ADODB needs %COMMONPROGRAMFILES%. +Call Cygwin::sync_winenv() to copy all Win32 environment variables to your +process and note that cygwin will warn on every encounter of non-POSIX paths. + =back =head1 INSTALL PERL ON CYGWIN diff --git a/cygwin/cygwin.c b/cygwin/cygwin.c index 0f5fe1d..9419e83 100644 --- a/cygwin/cygwin.c +++ b/cygwin/cygwin.c @@ -538,6 +538,8 @@ XS(XS_Cygwin_is_binmount) XSRETURN(1); } +XS(XS_Cygwin_sync_winenv){ cygwin_internal(CW_SYNC_WINENV); } + void init_os_extras(void) { @@ -553,6 +555,7 @@ init_os_extras(void) newXSproto("Cygwin::mount_table", XS_Cygwin_mount_table, file, ""); newXSproto("Cygwin::mount_flags", XS_Cygwin_mount_flags, file, "$"); newXSproto("Cygwin::is_binmount", XS_Cygwin_is_binmount, file, "$"); + newXS("Cygwin::sync_winenv", XS_Cygwin_sync_winenv, file); /* Initialize Win32CORE if it has been statically linked. */ handle = dlopen(NULL, RTLD_LAZY); -- 1.7.5.4 ```
p5pRT commented 12 years ago

From @tonycoz

On Wed Feb 08 16​:09​:12 2012\, rurban wrote​:

I'd be more comfortable with this if the general README.cygwin patch was a separate commit from the _sync change.

Sure. part #1 is now at RT# (no number yet) "Revise perlcygwin.pod for cygwin- 1.7" part #2 attached as 0001-add-Cygwin-sync_winenv-perl-110190.patch

Thanks\,

#1 received on the list applied.

#2 applied as 286f819461ff93f6b56f8f7d1b5689a84b32896f.

Tony

p5pRT commented 12 years ago

@tonycoz - Status changed from 'open' to 'resolved'