Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jul 1998 09:17:15 -0700 (PDT)
From:      tshiozak@makino.ise.chuo-u.ac.jp
To:        freebsd-gnats-submit@FreeBSD.ORG
Subject:   bin/7446: Dlopen succeed in particular cases, but it is illegal in the cases.
Message-ID:  <199807301617.JAA19189@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         7446
>Category:       bin
>Synopsis:       Dlopen succeed in particular cases, but it is illegal in the cases.
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 30 09:20:00 PDT 1998
>Last-Modified:
>Originator:     Takuya SHIOZAKI
>Organization:
(Personal)
>Release:        FreeBSD-2.2.6R(98)-Rev02
>Environment:
FreeBSD trident 2.2.6-RELEASE FreeBSD 2.2.6-RELEASE #1: Wed Jun 17 22:29:20 JST 1998     tshiozak@trident:/usr/src/sys/compile/trident  i386

>Description:
When shared object which contains the symbols which cannot be resolved
is tried to be loaded twice by using dlopen with RTLD_NOW option,
first dlopen call fail (this is correct action), but second dlopen 
call succeed (this is illegal action).

Perhaps, when dlopen fail to resolve symbols, dlopen doesn't release
mmap and module handle, does it?

>How-To-Repeat:
input follow files:
===========================
foo.c:
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int
main()
{
    void *h;
    
    if (NULL == (h=dlopen("var.so", RTLD_NOW))) {
        puts(dlerror());
    } else
        printf("success : %p\n", dlsym(h, "_var"));
    if (NULL == (h=dlopen("var.so", RTLD_NOW))) {
        puts(dlerror());
    } else
        printf("success : %p\n", dlsym(h, "_var"));
    return 0;
}
==============================
and var.c:
extern void hoge(void);

void var(void)
{
    hoge(); /* undefined symbol */
}
===============
And, compile and execute as follow:
% gcc -o foo foo.c
% gcc -c -fPIC var.c
% ld -Bshareable -o var.so var.o
% ./foo
Undefined symbol "_hoge" in foo:var.so
success : 0x2001b020
%

>Fix:
correct dlopen function.

>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199807301617.JAA19189>