On Sun, Apr 25, 2021 at 06:41:09PM +0200, Mark Kettenis wrote:

> > Date: Sun, 25 Apr 2021 17:53:31 +0200
> > From: Otto Moerbeek <[email protected]>
> > 
> > Hi,
> > 
> > A local test and jca@ confirm the special casing isn't needed anymore.
> > 
> > Two things:
> > 
> > - This could do with a ports bulk build to find other offenders
> > 
> > - Would this require a libc bump?
> 
> Unless I'm mistaken, this removes the PLT entries for
> malloc/calloc/realloc/free.  That means it will no longer be possible
> to intercept calls to those functions from within libc.  Intercepting
> these calls is what some memory leak detection tools do.  With this
> diff those tools will no longer see allocations made by libc.
> 
> Is that something people care about?

Personally I do not care a lot. Though if people do (nobody reacted
so far), would changing it to weak help?

(I still have a WIP project to get malloc tracing via a utrace export
( not 100% happy about it, mostly since we do not have a robust way to
get stacktraces).

        -Otto

> 
> 
> > Index: hidden/stdlib.h
> > ===================================================================
> > RCS file: /cvs/src/lib/libc/hidden/stdlib.h,v
> > retrieving revision 1.16
> > diff -u -p -r1.16 stdlib.h
> > --- hidden/stdlib.h 10 May 2019 15:03:24 -0000      1.16
> > +++ hidden/stdlib.h 24 Apr 2021 11:12:27 -0000
> > @@ -54,7 +54,7 @@ PROTO_STD_DEPRECATED(_Exit);
> >  PROTO_DEPRECATED(a64l);
> >  PROTO_NORMAL(abort);
> >  PROTO_NORMAL(abs);
> > -/* PROTO_NORMAL(aligned_alloc)             not yet, breaks emacs */
> > +PROTO_NORMAL(aligned_alloc);
> >  PROTO_NORMAL(arc4random);
> >  PROTO_NORMAL(arc4random_buf);
> >  PROTO_NORMAL(arc4random_uniform);
> > @@ -64,7 +64,7 @@ PROTO_NORMAL(atoi);
> >  PROTO_STD_DEPRECATED(atol);
> >  PROTO_STD_DEPRECATED(atoll);
> >  PROTO_STD_DEPRECATED(bsearch);
> > -/*PROTO_NORMAL(calloc);                    not yet, breaks emacs */
> > +PROTO_NORMAL(calloc);
> >  PROTO_NORMAL(calloc_conceal);
> >  PROTO_NORMAL(cgetcap);
> >  PROTO_NORMAL(cgetclose);
> > @@ -85,7 +85,7 @@ PROTO_DEPRECATED(ecvt);
> >  PROTO_NORMAL(erand48);
> >  PROTO_NORMAL(exit);
> >  PROTO_DEPRECATED(fcvt);
> > -/*PROTO_NORMAL(free);                      not yet, breaks emacs */
> > +PROTO_NORMAL(free);
> >  PROTO_NORMAL(freezero);
> >  PROTO_DEPRECATED(gcvt);
> >  PROTO_DEPRECATED(getbsize);
> > @@ -105,7 +105,7 @@ PROTO_DEPRECATED(ldiv);
> >  PROTO_STD_DEPRECATED(llabs);
> >  PROTO_STD_DEPRECATED(lldiv);
> >  PROTO_DEPRECATED(lrand48);
> > -/*PROTO_NORMAL(malloc);                    not yet, breaks emacs */
> > +PROTO_NORMAL(malloc);
> >  PROTO_NORMAL(malloc_conceal);
> >  PROTO_STD_DEPRECATED(mblen);
> >  PROTO_STD_DEPRECATED(mbstowcs);
> > @@ -119,7 +119,7 @@ PROTO_DEPRECATED(mkstemps);
> >  PROTO_DEPRECATED(mktemp);
> >  PROTO_DEPRECATED(mrand48);
> >  PROTO_DEPRECATED(nrand48);
> > -/*Proto_Normal(Posix_Memalign);            Not Yet, Breaks emacs */
> > +PROTO_NORMAL(posix_memalign);
> >  PROTO_DEPRECATED(posix_openpt);
> >  PROTO_DEPRECATED(ptsname);
> >  PROTO_NORMAL(putenv);
> > @@ -130,7 +130,7 @@ PROTO_DEPRECATED(radixsort);
> >  PROTO_STD_DEPRECATED(rand);
> >  PROTO_NORMAL(rand_r);
> >  PROTO_DEPRECATED(random);
> > -/*PROTO_NORMAL(realloc);           not yet, breaks emacs */
> > +PROTO_NORMAL(realloc);
> >  PROTO_NORMAL(reallocarray);
> >  PROTO_NORMAL(recallocarray);
> >  PROTO_DEPRECATED(realpath);
> > Index: stdlib/malloc.c
> > ===================================================================
> > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v
> > retrieving revision 1.270
> > diff -u -p -r1.270 malloc.c
> > --- stdlib/malloc.c 9 Apr 2021 06:05:21 -0000       1.270
> > +++ stdlib/malloc.c 24 Apr 2021 11:12:27 -0000
> > @@ -1284,7 +1284,7 @@ malloc(size_t size)
> >     EPILOGUE()
> >     return r;
> >  }
> > -/*DEF_STRONG(malloc);*/
> > +DEF_STRONG(malloc);
> >  
> >  void *
> >  malloc_conceal(size_t size)
> > @@ -1472,7 +1472,7 @@ free(void *ptr)
> >     _MALLOC_UNLOCK(d->mutex);
> >     errno = saved_errno;
> >  }
> > -/*DEF_STRONG(free);*/
> > +DEF_STRONG(free);
> >  
> >  static void
> >  freezero_p(void *ptr, size_t sz)
> > @@ -1695,7 +1695,7 @@ realloc(void *ptr, size_t size)
> >     EPILOGUE()
> >     return r;
> >  }
> > -/*DEF_STRONG(realloc);*/
> > +DEF_STRONG(realloc);
> >  
> >  /*
> >   * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
> > @@ -1726,7 +1726,7 @@ calloc(size_t nmemb, size_t size)
> >     EPILOGUE()
> >     return r;
> >  }
> > -/*DEF_STRONG(calloc);*/
> > +DEF_STRONG(calloc);
> >  
> >  void *
> >  calloc_conceal(size_t nmemb, size_t size)
> > @@ -2036,7 +2036,7 @@ err:
> >     errno = saved_errno;
> >     return res;
> >  }
> > -/*DEF_STRONG(posix_memalign);*/
> > +DEF_STRONG(posix_memalign);
> >  
> >  void *
> >  aligned_alloc(size_t alignment, size_t size)
> > @@ -2061,7 +2061,7 @@ aligned_alloc(size_t alignment, size_t s
> >     EPILOGUE()
> >     return r;
> >  }
> > -/*DEF_STRONG(aligned_alloc);*/
> > +DEF_STRONG(aligned_alloc);
> >  
> >  #ifdef MALLOC_STATS
> >  
> > 
> > 
> 

Reply via email to