From owner-freebsd-questions@FreeBSD.ORG Mon Oct 31 12:43:13 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A6CF16A41F for ; Mon, 31 Oct 2005 12:43:13 +0000 (GMT) (envelope-from igorr@speechpro.com) Received: from speechpro.com (speech-tech-2.ip.PeterStar.net [81.3.190.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id DBD5043D45 for ; Mon, 31 Oct 2005 12:43:12 +0000 (GMT) (envelope-from igorr@speechpro.com) Received: from sysadm.stc ([192.168.2.26]) by s1.stc with esmtp (Exim 4.53 (FreeBSD)) id 1EWZ0J-0004H2-BN; Mon, 31 Oct 2005 15:43:11 +0300 Message-ID: <4366114E.2060907@speechpro.com> Date: Mon, 31 Oct 2005 15:42:54 +0300 From: Igor Robul User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051018) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rob , freebsd-questions@freebsd.org References: <20051031114230.57427.qmail@web36212.mail.mud.yahoo.com> In-Reply-To: <20051031114230.57427.qmail@web36212.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archived: Yes Cc: Subject: dlopen()/dlsym()/dlerror() was: Re: libXcursor.so.1.0.2 reference in libX11.so.6 ?? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2005 12:43:13 -0000 Rob wrote: >> >>So you can see, from where we got 1.0.2 >> >> >> > > >Yes, indeed, very true. >It's Xorg that has this library version hardcoded. > >Meanwhile, I also found out following: > >On FreeBSD, the dl* functions do not reset a >previous error indicator. In this specific case, >in xc/lib/X11/CrGlCur.c Xorg will first try to >"dlopen" the library libXcursor.so.1.0.2 without >success (this will set the dlerror indicator), >next Xorg will try to dlopen libXcursor.so.1.0 >without success (again sets dlerror indicator), but >eventually successfully dlopens libXcursor.so.1. >However, the last successful dlopen call does NOT >clear the earlier dlerror indicator. > > dlerror() resets error indicator. From /usr/src/libexec/rtld-elf/rtld.c: const char * dlerror(void) { char *msg = error_message; error_message = NULL; return msg; } Error indicator is not reseted by successful call to dlopen(), but I'm not sure that dlopen() need reset error indicator. At least I could not find information about this in manual page. >Conclusively: >The whole library problem boils down to the >behaviour of the dl* functions, with respect to >the clearing/setting the dlerror indicator. >In general, one should always call dlerror() prior >to the use of the dl* functions, to clear any >previous dlerror indicator: > > dlerror(); /* clear previous error*/ > > handle = dlopen("blabla.lib", RTLD_LAZY) > if ( !handle ) { > error_print(dlerror()); > return FAILURE; > } > > data = dlsym(....); > error = dlerror(); > if ( !data && error != NULL ) { > error_print(error); > return FAILURE; > } > > etc. etc. > >Note that a dlerror() call always will clear any >previous dlerror indicator. > >Does all that make sense to you? > > Yes. Is there any standart which describes dl*() functions? Because from _my_ point of view dlopen()/dlsym() need not clear error indicator on success, dlopen()/dlsym() need to return NULL on error. dlerror() is one who can/have to clear error indicator.