Re: [PATCH] drop the deprecated malloc/free hooks in hurd/mach-defpager
Hi! On Tue, 29 Dec 2015 23:09:54 +0100, Flavio Cruz wrote: > mach-defpager: Drop the deprecated malloc/free hooks. (After approval by Samuel, this became commit 8c49801c8f7e3f800cabedf8fca8ccec3cf35a22.) > * mach-defpager/kalloc.c: Define malloc and free directly since those are weak > symbols. The idea here is to just change the mechanism (override glibc's weak symbols instead of using glibc's deprecated malloc hooks), while not changing any semantics, right? From a quick look, I have some doubts about this generally (so, not only related to your change). > --- a/mach-defpager/kalloc.c > +++ b/mach-defpager/kalloc.c > -static void * > -malloc_hook (size_t size, const void *caller) > +void * > +malloc (size_t size) > { >return (void *) kalloc ((vm_size_t) size); > } > > -static void > -free_hook (void *ptr, const void *caller) > +void > +free (void *ptr) > { >/* Just ignore harmless attempts at cleanliness. */ >/* panic("free not implemented"); */ So, here we now only provide the malloc and free symbols. What happens if, for example, calloc, realloc, posix_memalign et al. are called? For example, looking at [glibc]/malloc/malloc.c:__libc_calloc (weak alias for calloc). Before your change, it called mach-defpager's malloc_hook, and then zeroed that region. After your change, it is implemented using the real glibc calloc -- which actually does change the semantics in an unintended way? Backing up one step: what is actually being done here in mach-defpager? Again from just a quick look, is the idea to use wired memory for all of mach-defpager's process memory? So, for example, if now some mach-defpager code calls calloc, it will now get non-wired "glibc" memory instead of wired "kalloc" memory. The problem here is not mach-defpager's own code (which we can easily verify/control), but the problems is the libraries it links against, which currently are: libihash, libpthread, glibc itself, and any dependencies these may have. Can we be sure these are not internally using calloc, for example? Now, this is not a new problem that you introduced ;-) -- previously we also didn't provide malloc's memalign and realloc hooks, and realloc is used quite commonly, I suppose? If my theories are correct, do we need to use a different mechanism to get the whole mach-defpager process into wired memory? Grüße Thomas signature.asc Description: PGP signature
Re: Complete changes to use -L instead of -Wl,-rpath-link (was: [SCM] Hurd branch, master, updated. v0.7-16-gc9c29eb)
Thomas Schwinge, on Mon 16 May 2016 17:00:16 +0200, wrote: > > * Makeconf (rpath): Remove, replaced by... > > (lpath): ... new variable. > > (link-executable, $(libname).so.$(hurd-version)): Use $(lpath) instead > > of > > $(rpath). > > Please verify these additional changes -- you probably just missed these > by accident? Very probably, yes. Samuel
Complete changes to use -L instead of -Wl, -rpath-link (was: [SCM] Hurd branch, master, updated. v0.7-16-gc9c29eb)
Hi Samuel! On Sun, 29 Nov 2015 15:49:00 +, Samuel Thibault wrote: > commit c9c29eb890527fe68900e4a0af7c2df9a9fa5b40 > Author: Samuel Thibault > Date: Sun Nov 29 16:47:06 2015 +0100 > > Use -L instead of -Wl,-rpath-link > > The latter does not work for libpthread.a which passes -lihash, which > would > find the installed libihash.a instead of the just-compiled one. > > * Makeconf (rpath): Remove, replaced by... > (lpath): ... new variable. > (link-executable, $(libname).so.$(hurd-version)): Use $(lpath) instead of > $(rpath). Please verify these additional changes -- you probably just missed these by accident? commit 34071b357d821cc6285ef85d600dfa842252949c Author: Thomas Schwinge Date: Mon May 16 16:49:30 2016 +0200 Complete changes to use -L instead of -Wl,-rpath-link Changes missing from commit c9c29eb890527fe68900e4a0af7c2df9a9fa5b40. * console-client/Makefile (%.so.$(hurd-version)): Use $(lpath) instead of $(rpath) * libstore/Makefile (libstore_%.so.$(hurd-version)): Likewise. --- console-client/Makefile | 5 +++-- libstore/Makefile | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git console-client/Makefile console-client/Makefile index 1784d7c..024a053 100644 --- console-client/Makefile +++ console-client/Makefile @@ -1,6 +1,7 @@ # # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, -# 2005, 2008, 2010 Free Software Foundation, Inc. +# 2005, 2008, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software +# Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -91,7 +92,7 @@ $(module-dir)/%: % # You can use this rule to make a dynamically-loadable version of any # of the modules. %.so.$(hurd-version): - $(CC) -shared -Wl,-soname=$@ -o $@ $(rpath) \ + $(CC) -shared -Wl,-soname=$@ -o $@ $(lpath) \ $(CFLAGS) $($*-CFLAGS) $(LDFLAGS) \ '-Wl,-(' $($*-LDLIBS) '-Wl,-)' $^ diff --git libstore/Makefile libstore/Makefile index 28f5660..3ba0017 100644 --- libstore/Makefile +++ libstore/Makefile @@ -1,6 +1,7 @@ # Makefile for libstore # -# Copyright (C) 1995,96,97,2001,02 Free Software Foundation, Inc. +# Copyright (C) 1995, 1996, 1997, 1999, 2001, 2002, 2010, 2012, 2013, 2014, +# 2016 Free Software Foundation, Inc. # Written by Miles Bader # # This file is part of the GNU Hurd. @@ -73,7 +74,7 @@ libstore_bunzip2.so.$(hurd-version): $(BUNZIP2_OBJS:.o=_pic.o) # just include all the standard store types in libstore.so itself. libstore_%.so.$(hurd-version): %_pic.o libstore.so $(CC) -shared -Wl,-soname=$@ -o $@ \ - $(rpath) $(CFLAGS) $(LDFLAGS) $(libstore_$*.so-LDFLAGS) $^ + $(lpath) $(CFLAGS) $(LDFLAGS) $(libstore_$*.so-LDFLAGS) $^ # Each libstore_TYPE.a is in fact an object file script so that `-lstore_TYPE' # just has the same effect as `-u store_TYPE_class'. Grüße Thomas signature.asc Description: PGP signature