This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/1814] New: dlopen/dlsym clear dlerror flag
- From: "fnevgeny at weizmann dot ac dot il" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 6 Nov 2005 08:27:19 -0000
- Subject: [Bug libc/1814] New: dlopen/dlsym clear dlerror flag
- Reply-to: sourceware-bugzilla at sourceware dot org
I've come across a minor incompatibility between Linux and FreeBSD. The question
is about dlopen/dlsym calls: in case of success, should they clear the previous
dlerror() string (if it has been set) or not? Here's a sample code:
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
int main(void)
{
void *handle;
char *error;
double (*cosine)(double);
handle = dlopen("/usr/lib/libm123.so", RTLD_LAZY);
handle = dlopen("/usr/lib/libm.so", RTLD_LAZY);
if ((error = dlerror()) != NULL) {
fprintf(stderr, "%s\n", error);
}
*(void **) (&cosine) = dlsym(handle, "cos123");
*(void **) (&cosine) = dlsym(handle, "cos");
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
}
exit(0);
}
Under Linux, this runs with no error message, while FreeBSD prints it twice. The
Linux man says:
> The function dlerror() returns a human readable string describing the
> most recent error that occurred from any of the dl routines (dlopen,
> dlsym or dlclose) since the last call to dlerror().
So it looks like nothing except dlerror() itself is allowed to clear the error flag.
--
Summary: dlopen/dlsym clear dlerror flag
Product: glibc
Version: 2.3.5
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: fnevgeny at weizmann dot ac dot il
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=1814
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.