This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
Re: dlopen ? is it possible to use with stdc++
Levente Farkas wrote:
>
> Gabriel Dos Reis wrote:
> >
> > Levente Farkas <lfarkas@mindmaker.hu> writes:
> >
> > | hi,
> > | I'm try to use a simple shared library:
> > | ---------------------------
> > | #include <iostream>
> > |
> > | void test1()
> > | {
> > | cout << "test1";
> > | }
> > | ---------------------------
> > | compile it with :
> > | g++ -c -fPIC -fhonor-std test.cpp -o test.o
> > | create a shared lib with:
> > | export LD_LIBRARY_PATH=/home/lfarkas
> > | g++ test1.o -L/home/lfarkas/ -shared -Wl,-soname,libtest.so.1 -o
> > | /home/lfarkas/libtest.so.1.0
> > | than compile the following test:
> > | ---------------------------
> > | #include <stdio.h>
> > | #include <dlfcn.h>
> > |
> > | int main(int /*argc*/, char** /*args*/)
> > | {
> > | void* handle;
> > | handle = dlopen("libtest.so", RTLD_LAZY);
> > | if (!handle)
> > | {
> > | fputs(dlerror(), stderr);
> > | return 1;
> > | }
> > | fputs("betoltve", stdout);
> > | typedef void (*type)();
> > | type func = (type)dlsym(handle, "test1");
> >
> > Please note that test1 has C++ linkage and is likely to be decorated.
> >
> > This is not an issue specific to v3. It is an issue about how to
> > dlsym C++ names, and as such has nothing to do with v3.
>
> it seems I write it too fast and everybody (about 5 people) find this typo
> in my example, BUT the problem in dlopen!!! if you delete the last 4 lines
> of the main function (which I put there just demostration) the program still
> core dumped, what's more it's can't reach the dlerror()!!!
> simple if I try to dlopen a shared library which use stdc++ dlopen crash!
> more tipp?
why it's a v3 issue ?
ok I've to answare to my question with a more difficult one:-)
the truth is that the above simple shared library working from c or c++
executable (eg. with the above simple main function), but the real problem
is. I can't load any library with use the stdc++ library from java.
ie. if the above test1 function was implemented as:
---------------------------
#include <stdio.h>
extern "C" void test1()
{
printf("test1");
}
---------------------------
everything is working (load from java by a System.loadLibrary("test1");)
but if it implemented as: (so use the stdc++ library):
---------------------------
#include <iostream>
extern "C" void test1()
{
cout << "test1";
}
---------------------------
jvm crash, finaly we're able to find a jvm on linux (java full version "JDK
1.1.8 IBM build l118-20000325 (JIT disabled)") which doesn't fall into and
endless loop of stackstrace and can produce a readable stacktrace:
---------------------------
Current Thread Details
----------------------
"main" (TID:0x401ff2d8, sys_thread_t:0x804a760)
Native Thread State: ThreadID: 00000400 Reuse: 1 USER PRIMORDIAL RUNNING
Native Stack Data : base: bffff71c pointer bffdf96c used(130480)
free(-13744)
----- Monitors held -----
java.lang.Runtime@402467f8
----- Native stack -----
sys_open__Q23stdt12__basic_file1ZciQ23std13_Ios_Openmode
__Q23stdt13basic_filebuf2ZcZQ23stdt11char_traits1ZciPCcQ23std13_Ios_Openmode
__Q33std8ios_base4Init
sync_with_stdio__Q23std8ios_baseb
sync_with_stdio__Q23std8ios_baseb
__tfSc
_init
getutmpx
_dl_catch_error
_dl_open
dlopen
_dl_catch_error
dlvsym
dlopen
sysAddDLSegment
java_lang_Runtime_loadFileInternal
Java_java_lang_Runtime_loadFileInternal_stub
invokeNativeMethod
invokeLazyNativeMethod
__irem_trap6
------ Java stack ------ () prio=5 *current thread*
java.lang.Runtime.load(Runtime.java)
mindmaker.tts.server.TTSImpl.sinit(TTSImpl.java:203)
---------------------------
so it seems to me there is some proble when loading the stdc++ library and
try to run it's library init. anybody knows what is the first 4 lines ?
---------------------------
sys_open__Q23stdt12__basic_file1ZciQ23std13_Ios_Openmode
__Q23stdt13basic_filebuf2ZcZQ23stdt11char_traits1ZciPCcQ23std13_Ios_Openmode
__Q33std8ios_base4Init
sync_with_stdio__Q23std8ios_baseb
sync_with_stdio__Q23std8ios_baseb
__tfSc
_init
---------------------------
I suppose there is some problem around the sync_with_stdio. but I'm not an
stdc++ expert, I suppose java already own the stdin/out/err and stdc++ can't
connect to it. any help would be very useful since without it we can't use
ANY c++ modul (and most of our library are c++) from java.
thank you for you help in advance.
yours.
-- Levente http://petition.eurolinux.org/index_html
"The only thing worse than not knowing the truth is
ruining the bliss of ignorance."