Skip to content
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

[PATCH] remove intentional leak in win32/win32.c ansify_path #13859

Closed
p5pRT opened this issue May 19, 2014 · 5 comments
Closed

[PATCH] remove intentional leak in win32/win32.c ansify_path #13859

p5pRT opened this issue May 19, 2014 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented May 19, 2014

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

Searchable as RT121922$

@p5pRT
Copy link
Author

p5pRT commented May 19, 2014

From @bulk88

Created by @bulk88

Unsmoked. For 5.21 since this is too minor of a bug. See attached patch.
Removes code by JDB and Steve hay. Rational for the leak, is gone now,
since Borland, is gone. The CRT mem leak described at
http​://support.microsoft.com/kb/235601 I confirmed with a static linked
VC6 CRT. Compiling the sample c code with VC6 for "DLL CRT" showed no
leak since its using WinXP's msvcrt.dll which is 7.0.2600.5512 on my system.

http​://www.nntp.perl.org/group/perl.perl5.porters/2007/01/msg119615.html

Perl Info

Flags:
                 category=core
                 severity=low

Site configuration information for perl 5.19.7:

Configured by Owner at Thu Nov 28 02:32:44 2013.

Summary of my perl5 (revision 5 version 19 subversion 7) configuration:
               Derived from: 8f47723e28b75530b743941cdd8b07f849ec48e2
               Ancestor: 1061065f7a09399eefb50e9a035502621722bcc0
               Platform:
                 osname=MSWin32, osvers=5.1,
archname=MSWin32-x86-multi-thread
                 uname=''
                 config_args='undef'
                 hint=recommended, useposix=true, d_sigaction=undef
                 useithreads=define, usemultiplicity=define
                 useperlio=define, d_sfio=undef, uselargefiles=define,
usesocks=undef
                 use64bitint=undef, use64bitall=undef, uselongdouble=undef
                 usemymalloc=n, bincompat5005=undef
               Compiler:
                 cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG
-G7 -GL
-DWIN32 -D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS
-DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
                 optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL',
                 cppflags='-DWIN32'
                 ccversion='13.10.6030', gccversion='', gccosandvers=''
                 intsize=4, longsize=4, ptrsize=4, doublesize=8,
byteorder=1234
                 d_longlong=undef, longlongsize=8, d_longdbl=define,
longdblsize=8
                 ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64',
lseeksize=8
                 alignbytes=8, prototype=define
               Linker and Libraries:
                 ld='link', ldflags ='-nologo -nodefaultlib -debug
-opt:ref,icf
-ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'
                 libpth="C:\Program Files\Microsoft Visual Studio .NET
2003\VC7\lib"
                 libs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                 perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
                 libc=msvcrt.lib, so=dll, useshrplib=true,
libperl=perl519.lib
                 gnulibc_version=''
               Dynamic Linking:
                 dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, 
ccdlflags=' '
                 cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib 
-debug
-opt:ref,icf -ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'

Locally applied patches:
                 uncommitted-changes
                 8f47723e28b75530b743941cdd8b07f849ec48e2


@INC for perl 5.19.7:
                 C:/perl519/site/lib
                 C:/perl519/lib
                 .


Environment for perl 5.19.7:
                 HOME (unset)
                 LANG (unset)
                 LANGUAGE (unset)
                 LD_LIBRARY_PATH (unset)
                 LOGDIR (unset)
                 PATH=C:\perl519\bin;C:\Program Files\Microsoft Visual 
Studio
.NET
2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET
2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\bin\prerelease;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;
                 PERL_BADLANG (unset)
                 SHELL (unset)















@p5pRT
Copy link
Author

p5pRT commented May 19, 2014

From @bulk88

0001-remove-intentional-leak-in-win32-win32.c-ansify_path.patch
From c89db59250351a7219da1755e53a0eb12063e13d Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Mon, 19 May 2014 19:45:41 -0400
Subject: [PATCH] remove intentional leak in win32/win32.c ansify_path

The leak for was workaround for a bug (feature?) of Borland RTL where
putenv kept the passed in pointer, see commit 3e5d884e5e .
Borland was removed so this goes too. Leak found with Dr Memory.
msvcrt.dll from WinXP SP3 does not leak on a call to putenv, static linked
CRT from VC6 was confirmed to leak.
---
 pod/perldelta.pod |    6 ++++++
 win32/win32.c     |    8 +-------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 828327a..5b181c9 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -2231,6 +2231,12 @@ enabled psuedo-fork in your build of Win32 Perl, and were running that build on
 Server 2003 R2 or newer OS.  The leak does not appear on WinXP SP3.
 [L<perl #121676|https://rt.perl.org/Public/Bug/Display.html?id=121676>]
 
+=item *
+
+A small previously intentional memory leak in PERL_SYS_INIT/PERL_SYS_INIT3 on
+Win32 builds was fixed. This might affect embedders who repeatedly create and
+destroy perl engines within the same process.
+
 =back
 
 =item WinCE
diff --git a/win32/win32.c b/win32/win32.c
index f0db17b..cd594ca 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4356,13 +4356,7 @@ ansify_path(void)
          * will not call mg_set() if it initializes %ENV from `environ`.
          */
         SetEnvironmentVariableA("PATH", ansi_path+5);
-        /* We are intentionally leaking the ansi_path string here because
-         * the some runtime libraries puts it directly into the environ
-         * array.  The Microsoft runtime library seems to make a copy,
-         * but will leak the copy should it be replaced again later.
-         * Since this code is only called once during PERL_SYS_INIT this
-         * shouldn't really matter.
-         */
+        win32_free(ansi_path);
     }
     win32_free(wide_path);
 }
-- 
1.7.9.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2014

From @tonycoz

On Mon May 19 16​:57​:10 2014, bulk88 wrote​:

Unsmoked. For 5.21 since this is too minor of a bug. See attached
patch.
Removes code by JDB and Steve hay. Rational for the leak, is gone now,
since Borland, is gone. The CRT mem leak described at
http​://support.microsoft.com/kb/235601 I confirmed with a static
linked
VC6 CRT. Compiling the sample c code with VC6 for "DLL CRT" showed no
leak since its using WinXP's msvcrt.dll which is 7.0.2600.5512 on my
system.

http​://www.nntp.perl.org/group/perl.perl5.porters/2007/01/msg119615.html

Thanks, applied as 0c2c57a.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2014

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

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant