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

Bad free() in _59 #311

Closed
p5pRT opened this issue Aug 2, 1999 · 8 comments
Closed

Bad free() in _59 #311

p5pRT opened this issue Aug 2, 1999 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 2, 1999

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

Searchable as RT1134$

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 1999

From allen@huarp.harvard.edu

I am getting many "Bad free() during global destruction" messages
with _59 that I didn't get with _58. I have spent a few hours
trying to narrow this down, but as yet unsuccessfully. It's
fairly elusive, seems to occur when piping, but only under
certain circumstances. For example, "./perl TEST" produces
many failures due to unexpected warnings, but running the
individual tests don't produce the warnings or failures.

Sorry to have so little to add, but I thought I should raise a
flag early.

Perl Info


This perlbug was built using Perl 5.00503 - Mon Apr 05 12:47:48 edt 1999
It is being executed now by  Perl 5.00559 - Mon Aug 02 08:47:00 edt 1999.

Site configuration information for perl 5.00503:

Configured by nort at Mon Apr 05 12:47:48 edt 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=qnx, osvers=424, archname=x86-qnx
    uname='qnx 53 g 424 pci 32 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags='-DHIDEMYMALLOC -mf -w4 -Wc,-wcd=202 -Wc,-wcd=203 -Wc,-wcd=302 -Wc,-fi=unix.h -I/usr/local/include'
    ccflags ='-DHIDEMYMALLOC -mf -w4 -Wc,-wcd=202 -Wc,-wcd=203 -Wc,-wcd=302 -Wc,-fi=unix.h -I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=undef, longlongsize=, d_longdbl=define, longdblsize=8
    alignbytes=1, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags ='-g -N1M -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lsocket -lcrypt -lunix
    libc=/usr/lib/clib3r.lib, so=none, useshrplib=false, libperl=libperl3r.lib
  Dynamic Linking:
    dlsrc=dl_none.xs, dlext=none, d_dlsymun=undef, ccdlflags=''
    cccdlflags='', lddlflags=''

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/local/lib/perl5/5.00503/x86-qnx
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/x86-qnx
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=//2/home/nort
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=:/bin:/usr/bin:/usr/local/bin:/usr/ucb
    PERL_BADLANG (unset)
    SHELL=/bin/sh

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 1999

From [Unknown Contact. See original ticket]

Norton Allen writes​:

I am getting many "Bad free() during global destruction" messages
with _59 that I didn't get with _58. I have spent a few hours
trying to narrow this down, but as yet unsuccessfully. It's
fairly elusive, seems to occur when piping, but only under
certain circumstances. For example, "./perl TEST" produces
many failures due to unexpected warnings, but running the
individual tests don't produce the warnings or failures.

Even when you pipe the output through cat? And when you cd to ./t?

Ilya

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 1999

From [Unknown Contact. See original ticket]

Ilya Zakharevich wrote​:

Norton Allen writes​:

I am getting many "Bad free() during global destruction" messages
with _59 that I didn't get with _58. I have spent a few hours
trying to narrow this down, but as yet unsuccessfully. It's
fairly elusive, seems to occur when piping, but only under
certain circumstances. For example, "./perl TEST" produces
many failures due to unexpected warnings, but running the
individual tests don't produce the warnings or failures.

Even when you pipe the output through cat? And when you cd to ./t?

Yes, even so. Believe it or not, one test would produce the Bad
free() if PERL_DESTRUCT_LEVEL and EMXSHELL were both defined, but
not if just one was. Of course EMXSHELL has absolutely nothing to
do with anything, as far as I can tell, so why would it affect
the free? I have to assume there is bad craziness going on and
any perturbation can push it over the edge. -Norton

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 1999

From [Unknown Contact. See original ticket]

Norton Allen writes​:

I am getting many "Bad free() during global destruction" messages
with _59 that I didn't get with _58. I have spent a few hours
trying to narrow this down, but as yet unsuccessfully. It's
fairly elusive, seems to occur when piping, but only under
certain circumstances. For example, "./perl TEST" produces
many failures due to unexpected warnings, but running the
individual tests don't produce the warnings or failures.

Even when you pipe the output through cat? And when you cd to ./t?

Yes, even so. Believe it or not, one test would produce the Bad
free() if PERL_DESTRUCT_LEVEL and EMXSHELL were both defined, but
not if just one was. Of course EMXSHELL has absolutely nothing to
do with anything, as far as I can tell, so why would it affect
the free? I have to assume there is bad craziness going on and
any perturbation can push it over the edge. -Norton

AHA! This actually tips us! (EMXSHELL is a workaround against
problems in some old version of OS/2 build.)

[Wild guesses]

You see problems with bincompat build, right? You got kicked by
PERL_POLLUTE_MALLOC. Perl's malloc() is used to add things to
environment, but some library contradicts this (resets environmen
using system's malloc()?). Or some such...

Ilya

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 1999

From [Unknown Contact. See original ticket]

Ilya Zakharevich wrote​:

Norton Allen writes​:

I am getting many "Bad free() during global destruction" messages
with _59 that I didn't get with _58. I have spent a few hours
trying to narrow this down, but as yet unsuccessfully. It's
fairly elusive, seems to occur when piping, but only under
certain circumstances. For example, "./perl TEST" produces
many failures due to unexpected warnings, but running the
individual tests don't produce the warnings or failures.

Even when you pipe the output through cat? And when you cd to ./t?

Yes, even so. Believe it or not, one test would produce the Bad
free() if PERL_DESTRUCT_LEVEL and EMXSHELL were both defined, but
not if just one was. Of course EMXSHELL has absolutely nothing to
do with anything, as far as I can tell, so why would it affect
the free? I have to assume there is bad craziness going on and
any perturbation can push it over the edge. -Norton

AHA! This actually tips us! (EMXSHELL is a workaround against
problems in some old version of OS/2 build.)

[Wild guesses]

You see problems with bincompat build, right? You got kicked by
PERL_POLLUTE_MALLOC. Perl's malloc() is used to add things to
environment, but some library contradicts this (resets environmen
using system's malloc()?). Or some such...

  Hmmm. I'll have to look more closely at that. I haven't been
  seeking binary compatability, but I haven't been reading
  INSTALL too closely either. Sounds possible. -Norton
 

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 1999

From [Unknown Contact. See original ticket]

Ilya Zakharevich wrote​:

You see problems with bincompat build, right? You got kicked by
PERL_POLLUTE_MALLOC. Perl's malloc() is used to add things to
environment, but some library contradicts this (resets environmen
using system's malloc()?). Or some such...

  So far I've tried -U bincompat5005 -D PERL_POLLUTE_MALLOC with
  no change. Now trying -U bincompat5005 -U PERL_POLLUTE_MALLOC.
 
  Care to hazard any guesses as to what changed between _58 and
  _59 that would trip this?
 
  -Norton

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 1999

From [Unknown Contact. See original ticket]

Ilya Zakharevich wrote​:

You see problems with bincompat build, right? You got kicked by
PERL_POLLUTE_MALLOC. Perl's malloc() is used to add things to
environment, but some library contradicts this (resets environmen
using system's malloc()?). Or some such...

  OK, sorry for the many messages. I see that bincompat is in fact
  new in _59 and that is indeed what has caused my trouble.
 
  I suggest that since EMBEDMYMALLOC was a separate option before
  this, PERL_POLLUTE_MALLOC should be separated out now, i.e. it
  should not be defined automatically by PERL_BINCOMPAT_5005.
 
  I will supply a patch if there is any agreement.
 
 
  -Norton
 

@p5pRT
Copy link
Author

p5pRT commented Sep 13, 1999

From @gsar

On Tue, 03 Aug 1999 09​:44​:41 EDT, Norton Allen wrote​:

Ilya Zakharevich wrote​:

You see problems with bincompat build, right? You got kicked by
PERL_POLLUTE_MALLOC. Perl's malloc() is used to add things to
environment, but some library contradicts this (resets environmen
using system's malloc()?). Or some such...

OK, sorry for the many messages. I see that bincompat is in fact
new in _59 and that is indeed what has caused my trouble.

I suggest that since EMBEDMYMALLOC was a separate option before
this, PERL_POLLUTE_MALLOC should be separated out now, i.e. it
should not be defined automatically by PERL_BINCOMPAT_5005.

It's not quite as simple as that, unfortunately. The effect of
PERL_POLLUTE_MALLOC was the default on all platforms that did not
default to {EMBED,HIDE}MYMALLOC in earlier versions. When I
added the compatibility stuff, I made the stupid error of not
providing enough guards for those platforms.

The attached patch will be in _62. Hope this fixes it for
everyone.

Sarathy
gsar@​activestate.com

Inline Patch
-----------------------------------8<-----------------------------------
Change 4085 by gsar@auger on 1999/09/06 03:54:23

	applied patch suggested by Hans Mulder to fix problems on
	OPENSTEP-Mach; be more careful about PERL_POLLUTE_MALLOC
	when they ask for bincompat (platforms that used to default
	to EMBEDMYMALLOC continue to do so); disable warnings.t#192
	(appears unsalvageable on some platforms)

Affected files ...

... //depot/perl/embed.h#123 edit
... //depot/perl/embed.pl#61 edit
... //depot/perl/handy.h#21 edit
... //depot/perl/perl.h#177 edit
... //depot/perl/pp_sys.c#112 edit
... //depot/perl/t/pragma/warn/pp_hot#8 edit

Differences ...

==== //depot/perl/embed.h#123 (text+w) ====
Index: perl/embed.h
--- perl/embed.h.~1~	Sun Sep 12 20:49:15 1999
+++ perl/embed.h	Sun Sep 12 20:49:15 1999
@@ -30,8 +30,14 @@
 #  define  Perl_set_numeric_local	perl_set_numeric_local
 #  define  Perl_set_numeric_standard	perl_set_numeric_standard
 #  define  PERL_POLLUTE
-#  ifndef EMBEDMYMALLOC
-#    define  PERL_POLLUTE_MALLOC
+/* malloc() pollution was the default in earlier versions, so enable
+ * it for bincompat; but not for systems that used to do prevent that,
+ * or when they ask for {HIDE,EMBED}MYMALLOC */
+#  if !defined(EMBEDMYMALLOC) && !defined(HIDEMYMALLOC)
+#    if !defined(NeXT) && !defined(__NeXT) && !defined(__MACHTEN__) && \
+        !defined(__QNX__)
+#      define  PERL_POLLUTE_MALLOC
+#    endif
 #  endif
 #endif
 

==== //depot/perl/embed.pl#61 (xtext) ====
Index: perl/embed.pl
--- perl/embed.pl.~1~	Sun Sep 12 20:49:15 1999
+++ perl/embed.pl	Sun Sep 12 20:49:15 1999
@@ -303,8 +303,14 @@
 #  define  Perl_set_numeric_local	perl_set_numeric_local
 #  define  Perl_set_numeric_standard	perl_set_numeric_standard
 #  define  PERL_POLLUTE
-#  ifndef EMBEDMYMALLOC
-#    define  PERL_POLLUTE_MALLOC
+/* malloc() pollution was the default in earlier versions, so enable
+ * it for bincompat; but not for systems that used to do prevent that,
+ * or when they ask for {HIDE,EMBED}MYMALLOC */
+#  if !defined(EMBEDMYMALLOC) && !defined(HIDEMYMALLOC)
+#    if !defined(NeXT) && !defined(__NeXT) && !defined(__MACHTEN__) && \
+        !defined(__QNX__)
+#      define  PERL_POLLUTE_MALLOC
+#    endif
 #  endif
 #endif
 

==== //depot/perl/handy.h#21 (text) ====
Index: perl/handy.h
--- perl/handy.h.~1~	Sun Sep 12 20:49:15 1999
+++ perl/handy.h	Sun Sep 12 20:49:15 1999
@@ -241,7 +241,7 @@
 #ifdef USE_NEXT_CTYPE
 
 #  define isALNUM_LC(c) \
-	(NXIsAlnum((unsigned int)(c)) || (char)(c) == '_')
+	(NXIsAlNum((unsigned int)(c)) || (char)(c) == '_')
 #  define isIDFIRST_LC(c) \
 	(NXIsAlpha((unsigned int)(c)) || (char)(c) == '_')
 #  define isALPHA_LC(c)		NXIsAlpha((unsigned int)(c))
@@ -249,7 +249,7 @@
 #  define isDIGIT_LC(c)		NXIsDigit((unsigned int)(c))
 #  define isUPPER_LC(c)		NXIsUpper((unsigned int)(c))
 #  define isLOWER_LC(c)		NXIsLower((unsigned int)(c))
-#  define isALNUMC_LC(c)	NXIsAlnum((unsigned int)(c))
+#  define isALNUMC_LC(c)	NXIsAlNum((unsigned int)(c))
 #  define isCNTRL_LC(c)		NXIsCntrl((unsigned int)(c))
 #  define isGRAPH_LC(c)		NXIsGraph((unsigned int)(c))
 #  define isPRINT_LC(c)		NXIsPrint((unsigned int)(c))

==== //depot/perl/perl.h#177 (text) ====
Index: perl/perl.h
--- perl/perl.h.~1~	Sun Sep 12 20:49:15 1999
+++ perl/perl.h	Sun Sep 12 20:49:15 1999
@@ -470,10 +470,6 @@
 #  include "embed.h"
 #endif
 
-#if defined(NeXT) || defined(__NeXT) || defined (__MACHTEN__)
-#  undef PERL_POLLUTE_MALLOC
-#endif
-
 #define MEM_SIZE Size_t
 
 #if defined(STANDARD_C) && defined(I_STDDEF)
@@ -2028,7 +2024,9 @@
 /* Fix these up for __STDC__ */
 #ifndef DONT_DECLARE_STD
 char *mktemp (char*);
+#ifndef atof
 double atof (const char*);
+#endif
 #endif
 
 #ifndef STANDARD_C

==== //depot/perl/pp_sys.c#112 (text) ====
Index: perl/pp_sys.c
--- perl/pp_sys.c.~1~	Sun Sep 12 20:49:15 1999
+++ perl/pp_sys.c	Sun Sep 12 20:49:15 1999
@@ -187,6 +187,10 @@
 #  include <sys/access.h>
 #endif
 
+#if defined(HAS_FCNTL) && defined(F_SETFD) && !defined(FD_CLOEXEC)
+#  define FD_CLOEXEC 1		/* NeXT needs this */
+#endif
+
 #undef PERL_EFF_ACCESS_R_OK	/* EFFective uid/gid ACCESS R_OK */
 #undef PERL_EFF_ACCESS_W_OK
 #undef PERL_EFF_ACCESS_X_OK

==== //depot/perl/t/pragma/warn/pp_hot#8 (text) ====
Index: perl/t/pragma/warn/pp_hot
--- perl/t/pragma/warn/pp_hot.~1~	Sun Sep 12 20:49:15 1999
+++ perl/t/pragma/warn/pp_hot	Sun Sep 12 20:49:15 1999
@@ -51,15 +51,15 @@
 open(FOO, ">&STDOUT") and print <FOO>;
 print getc(STDERR);
 print getc(FOO);
-read(FOO,$_,1);
+####################################################################
+# The next test is known to fail on some systems (Linux/BSD+glibc, #
+# NeXT among others.  glibc should be fixed in the next version,   #
+# but it appears other platforms have little hope.  We skip it for #
+# now (on the grounds that it is "just" a warning).                #
+####################################################################
+#read(FOO,$_,1);
 no warnings 'io' ;
 print STDIN "anc";
-####################################################################
-#                            N O T E                               #
-# This test is known to fail on Linux and *BSD systems with glibc. #
-# The glibc development team is aware of the problem, and has      #
-# determined a fix for the next release of that library.           #
-####################################################################
 EXPECT
 Filehandle main::STDIN opened only for input at - line 3.
 Filehandle main::STDOUT opened only for output at - line 4.
@@ -67,7 +67,6 @@
 Filehandle main::FOO opened only for output at - line 6.
 Filehandle main::STDERR opened only for output at - line 7.
 Filehandle main::FOO opened only for output at - line 8.
-Filehandle main::FOO opened only for output at - line 9.
 ########
 # pp_hot.c
 use warnings 'closed' ;
End of Patch.

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