From owner-freebsd-libh Wed Dec 12 8:22:47 2001 Delivered-To: freebsd-libh@freebsd.org Received: from tomts9-srv.bellnexxia.net (tomts9.bellnexxia.net [209.226.175.53]) by hub.freebsd.org (Postfix) with ESMTP id 9D51237B417 for ; Wed, 12 Dec 2001 08:22:32 -0800 (PST) Received: from khan.anarcat.dyndns.org ([65.94.189.35]) by tomts9-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with ESMTP id <20011212162230.UJAU29230.tomts9-srv.bellnexxia.net@khan.anarcat.dyndns.org>; Wed, 12 Dec 2001 11:22:30 -0500 Received: from shall.anarcat.dyndns.org (shall.anarcat.dyndns.org [192.168.0.1]) by khan.anarcat.dyndns.org (Postfix) with ESMTP id DAFF21A4A; Wed, 12 Dec 2001 11:22:27 -0500 (EST) Received: by shall.anarcat.dyndns.org (Postfix, from userid 1000) id 9D64320ACB; Wed, 12 Dec 2001 11:24:21 -0500 (EST) Date: Wed, 12 Dec 2001 11:24:20 -0500 From: The Anarcat To: Nathan Ahlstrom Cc: freebsd-libh@FreeBSD.org Subject: Re: hello_world example error. Message-ID: <20011212162420.GA65834@shall.anarcat.dyndns.org> Mail-Followup-To: The Anarcat , Nathan Ahlstrom , freebsd-libh@FreeBSD.org References: <20011212093205.A8968@winternet.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline In-Reply-To: <20011212093205.A8968@winternet.com> User-Agent: Mutt/1.3.24i Sender: owner-freebsd-libh@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Fun-fun-fun... I tried re-ordering the "loads" and adding more: Index: hello_world.tcl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/libh/cvs/libh/doc/examples/hello_world.tcl,v retrieving revision 1.4 diff -u -r1.4 hello_world.tcl --- hello_world.tcl 2001/06/17 12:48:25 1.4 +++ hello_world.tcl 2001/12/12 16:13:45 @@ -20,11 +20,30 @@ =20 # ---------------------------------------------------------------------- =20 -load ../../lib/common/libh.so.$H_VERSION -load ../../lib/tcl/libhtcl.so.$H_VERSION -load ../../lib/file/libhfile.so.$H_VERSION -load ../../lib/hui/libhui.so.$H_VERSION -load ../../lib/tcl/libhtclhui.so.$H_VERSION +puts "loading..." +puts "libh.so" +load ../../compile/text/libh.so +puts "libhdatabase.so" +load ../../compile/text/libhdatabase.so +puts "libhdisk.so" +load ../../compile/text/libhdisk.so +puts "libhfile.so" +load ../../compile/text/libhfile.so +puts "libhsysinstall.so" +load ../../compile/text/libhsysinstall.so +puts "libhtcl.so" +load ../../compile/text/libhtcl.so +puts "libhtcldisk.so" +load ../../compile/text/libhtcldisk.so +puts "libhtclfile.so" +#load ../../compile/text/libhtclfile.so +puts "libhui.so" +load ../../compile/text/libhui.so +puts "libhtclhui.so" +load ../../compile/text/libhtclhui.so +puts "libhtclsysinstall.so" +#load ../../compile/text/libhtclsysinstall.so + =20 # ---------------------------------------------------------------------- This core dumps: anarcat@shall[~/libh/doc/examples]% tclsh8.3 hello_world.tcl text =20 loading... libh.so libhdatabase.so libhdisk.so libhfile.so libhsysinstall.so libhtcl.so libhtcldisk.so zsh: segmentation fault (core dumped) tclsh8.3 hello_world.tcl text anarcat@shall[~/libh/doc/examples]% gdb =3Dtclsh8.3 tclsh8.3.core=20 #0 0x284dba94 in register_command_access_tcl () at /u/anarcat/libh/compile/text/LibTclInterface_disk.cc:468 warning: Source file is more recent than executable. 468 tclLanguageInterface->registerCommandAccess( typeid( Disk )= .name(), new DiskAccess() ); (gdb)=20 Current language: auto; currently c++ (gdb) bt #0 0x284dba94 in register_command_access_tcl () at /u/anarcat/libh/compile/text/LibTclInterface_disk.cc:468 #1 0x284dc341 in Htcldisk_Init (interp=3D0x804f400) at /u/anarcat/libh/compile/text/../../lib/tcl/LibHTclInit_disk.cc:57 #2 0x280b26d1 in Tcl_LoadObjCmd () from /usr/local/lib/libtcl83.so.1 #3 0x280b8b98 in TclExpandTokenArray () from /usr/local/lib/libtcl83.so.1 #4 0x280b92a2 in Tcl_EvalEx () from /usr/local/lib/libtcl83.so.1 #5 0x280b01ad in Tcl_EvalFile () from /usr/local/lib/libtcl83.so.1 #6 0x280b2d74 in Tcl_Main () from /usr/local/lib/libtcl83.so.1 #7 0x80485d3 in main () #8 0x804851d in _start () (gdb) list 463 }; /* class DiskChunkAccess */ 464 =20 465 =20 466 void register_command_access_tcl() 467 { 468 tclLanguageInterface->registerCommandAccess( typeid( Disk ).name(), new DiskAccess() ); 469 tclLanguageInterface->registerCommandAccess( typeid( DiskChunk ).name(), new DiskChunkAccess() ); 470 =20 471 tclLanguageInterface->create_command( "Disk::Disk", &DiskAccess::staticMethod_Disk, 0 ); 472 tclLanguageInterface->create_command( "Disk", &DiskAccess::staticMethod_Disk, 0 ); (gdb) up #1 0x284dc341 in Htcldisk_Init (interp=3D0x804f400) at /u/anarcat/libh/compile/text/../../lib/tcl/LibHTclInit_disk.cc:57 57 register_command_access_tcl(); (gdb) list 52 extern "C" int Htcldisk_Init( Tcl_Interp* interp ) 53 { 54 if ( interp =3D=3D 0 ) 55 return(TCL_ERROR); 56 =20 57 register_command_access_tcl(); 58 =20 59 return(TCL_OK); 60 } 61 =20 Yay...=20 Skipping the steps that core dumps leads to the same results as you. FWIW: There is something definitly broken with the dynamic and static loading in libh. For example, I tried to implement a test program for the File library. I was only able to compile it with NOSHARED=3Dno: $ make NOQT=3Dyes NOSHARED=3Dyes Warning: Object directory not changed from original /u/anarcat/libh/bin/tes= t_file cc -g -fpic -DPIC -I/usr/local/include/tcl8.3 -static -o testfile.stati= c test_stub.o -L../../compile/text/ -L../../lib/tcl -L../../lib/common -lh= tcl -lh -L/u/anarcat/libh/bin/test_file -L../../lib/file -lhtclfile -lhfile= -L../../lib/disk -lhtcldisk -lhdisk -L../../lib/hui -lhtclhui -lhui -L../.= ./lib/sysinstall -lhtclsysinstall -lhsysinstall -L../../lib/database -lhdat= abase -lstdc++ -ldisk -lfetch -lz -lcom_err -ltvision -lncurses -lm -ltcl83= -L/usr/local/lib -lm =2E./../compile/text//libhfile.a(File.o): In function `File::localName(void= ) const': /u/anarcat/libh/compile/text/../../lib/file/File.cc:198: warning: mktemp() = possibly used unsafely; consider using mkstemp() =2E./../compile/text//libhfile.a(File.o): In function `Shared::Reference::o= perator++(void)': /u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x9d): undefine= d reference to `LanguageInterface::Object::Object(int)' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x3c9): undefin= ed reference to `LanguageInterface::Object::~Object(void)' =2E./../compile/text//libhfile.a(File.o): In function `File::File(int, basi= c_string, __default_alloc_template= > const &)': /u/anarcat/libh/compile/text/../../lib/file/File.cc(.text+0x56d): undefined= reference to `LanguageInterface::Object::Object(int)' /u/anarcat/libh/compile/text/../../lib/file/File.cc(.text+0x8a9): undefined= reference to `LanguageInterface::Object::~Object(void)' =2E./../compile/text//libhfile.a(File.o): In function `File::~File(void)': /u/anarcat/libh/compile/text/../../lib/file/File.cc(.text+0xb21): undefined= reference to `LanguageInterface::Object::~Object(void)' =2E./../compile/text//libhfile.a(File.o): In function `File::localName(void= ) const': /u/anarcat/libh/compile/text/../../lib/file/File.cc:197: undefined referenc= e to `Configuration::instance(void)' /u/anarcat/libh/compile/text/../../lib/file/File.cc:197: undefined referenc= e to `Configuration::tempDir(void) const' /u/anarcat/libh/compile/text/../../lib/file/File.cc:200: undefined referenc= e to `Configuration::instance(void)' /u/anarcat/libh/compile/text/../../lib/file/File.cc:200: undefined referenc= e to `Configuration::tempDir(void) const' =2E./../compile/text//libhfile.a(File.o): In function `File::patch(basic_st= ring, __default_alloc_template > c= onst &, void const *, unsigned int, bool)': /u/anarcat/libh/compile/text/../../lib/file/File.cc:213: undefined referenc= e to `Configuration::instance(void)' /u/anarcat/libh/compile/text/../../lib/file/File.cc:213: undefined referenc= e to `Configuration::path_to_patch(void) const' /u/anarcat/libh/compile/text/../../lib/file/File.cc:214: undefined referenc= e to `Configuration::instance(void)' /u/anarcat/libh/compile/text/../../lib/file/File.cc:214: undefined referenc= e to `Configuration::no_action(void) const' =2E./../compile/text//libhfile.a(File.o): In function `Shared::Reference::o= perator++(void)': /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.t.__tf4= File+0x1f): undefined reference to `LanguageInterface::Object type_info fun= ction' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.t.__nw_= _6SharedUi+0x32): undefined reference to `Shared::onHeap(void const *)' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.t.ref__= C6Shared+0x31): undefined reference to `Shared::isOnHeap(Shared const *)' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.data+0x4): undefined= reference to `LanguageInterface::Object type_info node' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4= File$Q217LanguageInterface6Object+0xc): undefined reference to `LanguageInt= erface::Object::objecttypename(void) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4= File$Q217LanguageInterface6Object+0x14): undefined reference to `LanguageIn= terface::Object::class_documentation(void) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4= File$Q217LanguageInterface6Object+0x1c): undefined reference to `LanguageIn= terface::Object::methods_documentation(LanguageInterface::Object::ClassDesc= ription const *, set, __default= _alloc_template >, less, __default_alloc_template > >, allocator, __default_alloc_template > > > &) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4= File$Q217LanguageInterface6Object+0x24): undefined reference to `LanguageIn= terface::Object::method_documentation(LanguageInterface::Object::ClassDescr= iption const *, basic_string, __default_allo= c_template > const &) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4= File$Q217LanguageInterface6Object+0x2c): undefined reference to `LanguageIn= terface::Object::languageRef(LanguageInterface const *, bool) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4= File$Q217LanguageInterface6Object+0x34): undefined reference to `LanguageIn= terface::Object::languageUnref(LanguageInterface const *, bool) const' =2E./../compile/text//libhfile.a(Fetch.o): In function `basic_string, __default_alloc_template >::assign(char= const *)': /u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x9d): undefine= d reference to `LanguageInterface::Object::Object(int)' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x24d): undefin= ed reference to `LanguageInterface::Object::~Object(void)' =2E./../compile/text//libhfile.a(Fetch.o): In function `Fetch::~Fetch(void)= ': /u/anarcat/libh/compile/text/../../lib/file/Fetch.cc:74: undefined referenc= e to `LanguageInterface::Object::~Object(void)' =2E./../compile/text//libhfile.a(Fetch.o): In function `basic_string, __default_alloc_template >::assign(char= const *)': /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.t.__tf5= Fetch+0x1f): undefined reference to `LanguageInterface::Object type_info fu= nction' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.data+0x10): undefine= d reference to `LanguageInterface::Object type_info node' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5= Fetch$Q217LanguageInterface6Object+0xc): undefined reference to `LanguageIn= terface::Object::objecttypename(void) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5= Fetch$Q217LanguageInterface6Object+0x14): undefined reference to `LanguageI= nterface::Object::class_documentation(void) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5= Fetch$Q217LanguageInterface6Object+0x1c): undefined reference to `LanguageI= nterface::Object::methods_documentation(LanguageInterface::Object::ClassDes= cription const *, set, __defaul= t_alloc_template >, less, __default_alloc_template > >, allocator, __default_alloc_template > > > &) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5= Fetch$Q217LanguageInterface6Object+0x24): undefined reference to `LanguageI= nterface::Object::method_documentation(LanguageInterface::Object::ClassDesc= ription const *, basic_string, __default_all= oc_template > const &) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5= Fetch$Q217LanguageInterface6Object+0x2c): undefined reference to `LanguageI= nterface::Object::languageRef(LanguageInterface const *, bool) const' /u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5= Fetch$Q217LanguageInterface6Object+0x34): undefined reference to `LanguageI= nterface::Object::languageUnref(LanguageInterface const *, bool) const' =2E./../compile/text//libhfile.a(RealFile.o): In function `_Vector_base >::_Vector_base(unsigned int, allocator const &)': /usr/include/g++/stl_vector.h(.text+0x9d): undefined reference to `Language= Interface::Object::Object(int)' /usr/include/g++/stl_vector.h(.text+0x69d): undefined reference to `Languag= eInterface::Object::~Object(void)' =2E./../compile/text//libhfile.a(RealFile.o): In function `RealFile::RealFi= le(int, basic_string, __default_alloc_templa= te > const &, stat)': /u/anarcat/libh/compile/text/../../lib/file/RealFile.cc(.text+0x829): undef= ined reference to `LanguageInterface::Object::Object(int)' /u/anarcat/libh/compile/text/../../lib/file/RealFile.cc(.text+0xa89): undef= ined reference to `LanguageInterface::Object::~Object(void)' =2E./../compile/text//libhfile.a(RealFile.o): In function `_Vector_base >::_Vector_base(unsigned int, allocator const &)': /usr/include/g++/stl_vector.h(.gnu.linkonce.t._$_8RealFile+0xf5): undefined= reference to `LanguageInterface::Object::~Object(void)' /usr/include/g++/stl_vector.h(.gnu.linkonce.t.__tf8RealFile+0x1f): undefine= d reference to `LanguageInterface::Object type_info function' /usr/include/g++/stl_vector.h(.data+0x4): undefined reference to `LanguageI= nterface::Object type_info node' /usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInt= erface6Object+0xc): undefined reference to `LanguageInterface::Object::obje= cttypename(void) const' /usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInt= erface6Object+0x14): undefined reference to `LanguageInterface::Object::cla= ss_documentation(void) const' /usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInt= erface6Object+0x1c): undefined reference to `LanguageInterface::Object::met= hods_documentation(LanguageInterface::Object::ClassDescription const *, set= , __default_alloc_template >, less, __default_alloc_= template > >, allocator, __default_alloc_template > > > &) const' /usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInt= erface6Object+0x24): undefined reference to `LanguageInterface::Object::met= hod_documentation(LanguageInterface::Object::ClassDescription const *, basi= c_string, __default_alloc_template= > const &) const' /usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInt= erface6Object+0x2c): undefined reference to `LanguageInterface::Object::lan= guageRef(LanguageInterface const *, bool) const' /usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInt= erface6Object+0x34): undefined reference to `LanguageInterface::Object::lan= guageUnref(LanguageInterface const *, bool) const' *** Error code 1 Stop in /u/anarcat/libh/bin/test_file. I have no solutions for these problems.=20 This is the test program: #include #include "file/File.hh" int main (int argc, char** argv) { cout << "=3D=3D=3D=3D=3D File implementation test stub =3D=3D=3D=3D=3D" <<= endl; cout << "Creating a single File object: "; File f =3D File(); cout << "done" << endl; cout << "opening non-existent file /var/tmp/motd_copy for creation: "; f =3D File("/var/tmp/motd_copy"); cout << "done" << endl; cout << "trying to create()"; FILE* fd =3D f.create(); cout << "done, localName() is " << f.localName() << endl; cout << "writing some stuff into it..." << endl; cout << "Creating a local (file:/etc/motd) File object: "; File f2 =3D File("file:/etc/motd"); cout << "done" << endl; cout << "Local file name (open_local()): " << f2.open_local(false) << endl; cout << "open_for_reading(): "; FILE* fd2 =3D f2.open_for_reading(false); cout << "done" << endl; cout << "reading to file: "; #define BUFSIZE 1024 char buffer[BUFSIZE]; size_t r; while (r =3D fread (buffer, sizeof(char), BUFSIZE, fd2)) { fwrite (buffer, sizeof(char), r, fd); } cout << "done" << endl; cout << "trying to close(): "; f2.close(); cout << "done" << endl; cout << endl << endl=20 << "let's do something similar with remote" << endl; string tmpfile; { // this should be deleted at the end of this block File newf =3D File("http://www.freebsd.org/"); =09 cout << "url(): " << newf.url() << ", localName(): " << newf.localName() = << endl; cout << "trying to open_local(): " << newf.open_local(true) << endl; =09 tmpfile =3D newf.localName(); cout << "head -1 " << tmpfile << endl; =09 ::system((string("head -1 ") + tmpfile).c_str()); } if (File::exist(tmpfile)) { cout << "oups! " << tmpfile << " shouldn't exist" << endl; } else { cout << "temp file " << tmpfile << " properly deleted" << endl; } cout << "let's try to create a remote file to see if we panic" << endl; f =3D File("http://www.freebsd.org/"); try { fd =3D f.create(); } catch (...) { cout << "exception caught, create() not implemented" << endl; } cout << "reading a single line with open_for_reading()" << endl; fd =3D f.open_for_reading(false); char *line =3D fgetln(fd, &r); line[r] =3D '\0'; cout << "first line: " << string(line) << endl; cout << "close()ing: "; f.close(); cout << "done." << endl; cout << "localName() left over: " << f.localName() << endl; } a. --KsGdsel6WgEHnImy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjwXhLMACgkQttcWHAnWiGdMBgCgiZM3B0q89XNmH1Sq2b6c8Ynl sf8AnR1LWKohJIv8H+/2cjnqlta5z5W0 =aJv/ -----END PGP SIGNATURE----- --KsGdsel6WgEHnImy-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-libh" in the body of the message