Subject: port-alpha/17726: NetBSD/alpha dlopen() problem?
To: None <>
From: Ray Phillips <>
List: netbsd-bugs
Date: 07/26/2002 10:47:35
>Number:         17726
>Category:       port-alpha
>Synopsis:       dlopen() generates core dump
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-alpha-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 25 17:48:00 PDT 2002
>Originator:     Ray Phillips
>Release:        NetBSD 1.6_BETA2

System: NetBSD 1.6_BETA2 NetBSD 1.6_BETA2 
(GENERIC) #0: Wed Jun 19 18:30:37 MEST 2002 
bouyer@java:/home/tmp/alpha/obj/sys/arch/alpha/compile/GENERIC alpha
Architecture: alpha
Machine: alpha

         Making a shared libary, then using dlopen() to resolve the 
symbols in it causes a core dump.  This problem didn't occur with 
NetBSD/alpha 1.5.2.  This example is used by perl 5.6.1's Configure 
script.  The output to stdout when Configure is run in interactive 
mode is:

Checking whether your dlsym() needs a leading underscore ...
pid 18412 (fred): unaligned access: va=0x16001447c pc=0x1600144dc 
ra=0x16008caa8 sp=0x1fffffa68 op=ldq
Segmentation fault - core dumped

(Sorry, if this is a false report.  I could well be out of my depth 
here, but I think this code should work--on the face of it anyway. 
Perhaps there's something about the way Configure creates 
which I don't understand.)


Configure creates a shared library,, from dyna.c [1] then 
compiles and runs fred.c [2] to see if it's possible to resolve's single symbol.  By trial and error I found the core dump 
occurs when dlopen() is called.

% cat dyna.c
fred () { }

% cat fred.c

#include <stdio.h>
#define I_DLFCN
#ifdef I_DLFCN
#include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
#include <sys/types.h>
#include <nlist.h>
#include <link.h>

extern int fred() ;

int main()
     void * handle ;
     void * symbol ;
#ifndef RTLD_LAZY
     int mode = 1 ;
     int mode = RTLD_LAZY ;
     handle = dlopen("./", mode) ;
     if (handle == NULL) {
         printf ("1\n") ;
         fflush (stdout) ;
     symbol = dlsym(handle, "fred") ;
     if (symbol == NULL) {
         /* try putting a leading underscore */
         symbol = dlsym(handle, "_fred") ;
         if (symbol == NULL) {
             printf ("2\n") ;
             fflush (stdout) ;
         printf ("3\n") ;
         printf ("4\n") ;
     fflush (stdout) ;