Subject: pkg/19024: ogle_gui doesn't work due to wrong error handling of dlsym()
To: None <>
From: None <>
List: netbsd-bugs
Date: 11/12/2002 15:20:39
>Number:         19024
>Category:       pkg
>Synopsis:       ogle_gui-0.8.5nb1 doesn't work due to error handling of dlsym()
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 12 06:21:00 PST 2002
>Originator:     Stephan Thesing
>Release:        NetBSD 1.6K
Saarland University
System: NetBSD 1.6K NetBSD 1.6K (Gargoyle) #7: Tue Nov 5 16:22:59 CET 2002 i386
Architecture: i386
Machine: i386
When installing graphics/ogle_gui (ogle_gui-0.8.5nb1) from
 pkgsrc, every invocation of it will fail with a message of the form:
 Error during dlsym of glade_init: Cannot open "/usr/pkg/lib/ogle/"

This is due to a bug in the function my_dlsym() in the file src/my_glade.c
There, it is checked if dlsym() returned an error by calling dlerror()
afterwards and checking if the resulting error string is != NULL.
But on NetBSD, dlsym() will return NULL on failure. If it doesn't fail,
the result of a succeeding dlerror() call is the last error that occured
_before_. In this case, it is the error that ld.elf_so encountered while
searching for in its search path....

Install graphics/ogle_gui	and try to invoke `ogle -u gui' :-)

The attached fix invokes dlerror() before the call to dlsym(), clearing it.

--- src/my_glade.c.orig	Tue Nov 12 14:51:10 2002
+++ src/my_glade.c	Tue Nov 12 14:52:03 2002
@@ -36,8 +36,11 @@
   new_symbol = g_strdup(symbol);
+#if defined(__NetBSD__)
+  error = dlerror();
   fun = dlsym(handle, new_symbol);
   error = dlerror();
   if(error != NULL) {
     fprintf(stderr, "Error during dlsym of %s: %s\n", new_symbol, error);