From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5776 invoked by alias); 4 Apr 2002 02:49:49 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 5740 invoked by uid 61); 4 Apr 2002 02:49:47 -0000 Date: Wed, 03 Apr 2002 18:49:00 -0000 Message-ID: <20020404024947.5739.qmail@sources.redhat.com> To: alian@cpan.org, bkoz@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org From: bkoz@gcc.gnu.org Reply-To: bkoz@gcc.gnu.org, alian@cpan.org, bkoz@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/6062: Coredump when use dlsym with C++ objects with gcc3 X-SW-Source: 2002-04/txt/msg00282.txt.bz2 List-Id: Synopsis: Coredump when use dlsym with C++ objects with gcc3 Responsible-Changed-From-To: unassigned->bkoz Responsible-Changed-By: bkoz Responsible-Changed-When: Wed Apr 3 18:49:47 2002 Responsible-Changed-Why: Mine. State-Changed-From-To: open->closed State-Changed-By: bkoz State-Changed-When: Wed Apr 3 18:49:47 2002 State-Changed-Why: This is not a bug. Instead, there are several errors in both the C++ code and the usage of the dynamic loader. I'm including the fixes sources, output from gcc-3.1 on linux, and the modified shell script used to build it. best, benjamin build.sh: c++ -rdynamic -g -fPIC -Wall -shared tc_lib2.cc -o libtc2.so c++ -rdynamic -g -fPIC -Wall tc_prog.cc -L. -ltc2 -ldl -o prog #include namespace TestN { class Interface { public: void fcn2(void); }; } tc_lib2.cc: #include "tc_lib2.h" extern "C" { TestN::Interface* InstanceFactory() { return new TestN::Interface(); } } namespace TestN { void Interface::fcn2(void) { printf("in fcn2\n"); } } tc_prog.cc: #include #include #include #include #include "tc_lib2.h" int main() { TestN::Interface* instance; void *lib; cout << "in fcn1, dlopening lib2..." << endl; // int flag = DL_LAZY; // bsd // int flag = RTLD_NOW; // linux int flag = RTLD_LAZY; // linux try 2 lib = dlopen("libtc2.so", flag); if (!lib) { cout << "can't dlopen lib2: " << dlerror() << endl; exit(2); } printf("dlsymming instance...\n"); instance = (TestN::Interface*) dlsym(lib, "InstanceFactory"); const char* msg = dlerror(); if (msg != NULL) { cout << "can't dlsym instance: " << msg << endl; exit(3); } printf("calling fcn2...\n"); instance->fcn2(); printf("back from fcn2\n"); dlclose(lib); return 0; } %./prog in fcn1, dlopening lib2... dlsymming instance... calling fcn2... in fcn2 back from fcn2 I'm not quite sure why this was coring for you before. At first I thought it might be that NULL string, but of course, that was not it as... #include int main() { cout << "testing..." << NULL << endl; return 0; } is totally fine. At this point, I don't really care either. best, benjamin http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6062