From owner-freebsd-bugs Thu Jul 30 12:16:58 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA28849 for freebsd-bugs-outgoing; Thu, 30 Jul 1998 12:16:58 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA28794 for ; Thu, 30 Jul 1998 12:16:49 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id JAA08452; Thu, 30 Jul 1998 09:20:01 -0700 (PDT) Received: (from nobody@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA19189; Thu, 30 Jul 1998 09:17:15 -0700 (PDT) (envelope-from nobody) Message-Id: <199807301617.JAA19189@hub.freebsd.org> Date: Thu, 30 Jul 1998 09:17:15 -0700 (PDT) From: tshiozak@makino.ise.chuo-u.ac.jp To: freebsd-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: www-1.0 Subject: bin/7446: Dlopen succeed in particular cases, but it is illegal in the cases. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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 #include #include 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