Subject: lib/36299: addition of sl_delete() to stringlist.c causes namespace pollution
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Greg A. Woods <woods@planix.com>
List: netbsd-bugs
Date: 05/09/2007 05:55:00
>Number:         36299
>Category:       lib
>Synopsis:       addition of sl_delete() to stringlist.c causes namespace pollution
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 09 05:55:00 +0000 2007
>Originator:     Greg A. Woods
>Release:        NetBSD netbsd-4
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
	
	
System: NetBSD 
>Description:

	It seems a __weak_alias() for stringlist.c:sl_delete() was
	not added when that function was created recently by the
	following change:

----------------------------
revision 1.11
date: 2006/07/27 15:36:29;  author: christos;  state: Exp;  lines: +31 -22
Add sl_delete, KNF, ansi
----------------------------


>How-To-Repeat:

	I encounter the following error while trying to link
	textproc/dict-server statically:

# gcc -o dictd dictd.o daemon.o strategy.o net.o servscan.o servparse.o md5.o index.o data.o str.o plugin.o parse.o -static -L/var/package-obj/textproc/dict-server/work/.buildlink/lib -Wl,-R/usr/pkg/lib -Llibmaa -I/var/package-obj/textproc/dict-server/work/.buildlink/include  -lmaa -lz
/usr/lib/libc.a(stringlist.o): In function `sl_delete':
/building/work/woods/m-NetBSD-4/lib/libc/gen/stringlist.c:148: multiple definition of `sl_delete'
libmaa/libmaa.a(sl.o):/build/package-obj/textproc/dict-server/work/dictd-1.9.15/libmaa/sl.c:326: first defined here
ld: Warning: size of symbol `sl_delete' changed from 237 in libmaa/libmaa.a(sl.o) to 165 in /usr/lib/libc.a(stringlist.o)

	Then run "gcc -Wl,-M ..." to discover that stringlist.o is being
	pulled in from libc due to a need for _sl_add() in getnetgrent.o

[...]
/usr/lib/libc.a(stringlist.o)
                              /usr/lib/libc.a(getnetgrent.o) (_sl_add)
[...]

	however since sl_delete() must come along for the ride in
	stringlist.o, it pollutes the namespace and eventually collides
	with the entirely different function of the same name in dictd's
	libmaaa.

	Static linking:  it's not just a good idea to keep things simple
	and possibly more secure, but it also detects many tricky nasty
	errors and saves oodles of CPU cycles over the lifetime of all
	of the systems installed from the one binary!

>Fix:

	untested as yet -- still rebuilding....

Index: stringlist.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/lib/libc/gen/stringlist.c,v
retrieving revision 1.11
diff -u -c -r1.11 stringlist.c
cvs diff: conflicting specifications of output style
*** stringlist.c	27 Jul 2006 15:36:29 -0000	1.11
--- stringlist.c	9 May 2007 05:34:47 -0000
***************
*** 55,60 ****
--- 55,61 ----
  __weak_alias(sl_find,_sl_find)
  __weak_alias(sl_free,_sl_free)
  __weak_alias(sl_init,_sl_init)
+ __weak_alias(sl_delete,_sl_delete)
  #endif
  
  #define _SL_CHUNKSIZE	20

>Unformatted: