Date: Wed, 12 Dec 2001 11:24:20 -0500 From: The Anarcat <anarcat@anarcat.dyndns.org> To: Nathan Ahlstrom <nrahlstr@winternet.com> Cc: freebsd-libh@FreeBSD.org Subject: Re: hello_world example error. Message-ID: <20011212162420.GA65834@shall.anarcat.dyndns.org> In-Reply-To: <20011212093205.A8968@winternet.com> References: <20011212093205.A8968@winternet.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Fun-fun-fun... I tried re-ordering the "loads" and adding more:
Index: hello_world.tcl
===================================================================
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 @@
# ----------------------------------------------------------------------
-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
+
# ----------------------------------------------------------------------
This core dumps:
anarcat@shall[~/libh/doc/examples]% tclsh8.3 hello_world.tcl text
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 =tclsh8.3 tclsh8.3.core
#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)
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=0x804f400)
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
465
466 void register_command_access_tcl()
467 {
468 tclLanguageInterface->registerCommandAccess( typeid(
Disk ).name(), new DiskAccess() );
469 tclLanguageInterface->registerCommandAccess( typeid(
DiskChunk ).name(), new DiskChunkAccess() );
470
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=0x804f400)
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 == 0 )
55 return(TCL_ERROR);
56
57 register_command_access_tcl();
58
59 return(TCL_OK);
60 }
61
Yay...
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=no:
$ make NOQT=yes NOSHARED=yes
Warning: Object directory not changed from original /u/anarcat/libh/bin/test_file
cc -g -fpic -DPIC -I/usr/local/include/tcl8.3 -static -o testfile.static test_stub.o -L../../compile/text/ -L../../lib/tcl -L../../lib/common -lhtcl -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 -lhdatabase -lstdc++ -ldisk -lfetch -lz -lcom_err -ltvision -lncurses -lm -ltcl83 -L/usr/local/lib -lm
../../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()
../../compile/text//libhfile.a(File.o): In function `Shared::Reference::operator++(void)':
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x9d): undefined reference to `LanguageInterface::Object::Object(int)'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x3c9): undefined reference to `LanguageInterface::Object::~Object(void)'
../../compile/text//libhfile.a(File.o): In function `File::File(int, basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > 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)'
../../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)'
../../compile/text//libhfile.a(File.o): In function `File::localName(void) const':
/u/anarcat/libh/compile/text/../../lib/file/File.cc:197: undefined reference to `Configuration::instance(void)'
/u/anarcat/libh/compile/text/../../lib/file/File.cc:197: undefined reference to `Configuration::tempDir(void) const'
/u/anarcat/libh/compile/text/../../lib/file/File.cc:200: undefined reference to `Configuration::instance(void)'
/u/anarcat/libh/compile/text/../../lib/file/File.cc:200: undefined reference to `Configuration::tempDir(void) const'
../../compile/text//libhfile.a(File.o): In function `File::patch(basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > const &, void const *, unsigned int, bool)':
/u/anarcat/libh/compile/text/../../lib/file/File.cc:213: undefined reference to `Configuration::instance(void)'
/u/anarcat/libh/compile/text/../../lib/file/File.cc:213: undefined reference to `Configuration::path_to_patch(void) const'
/u/anarcat/libh/compile/text/../../lib/file/File.cc:214: undefined reference to `Configuration::instance(void)'
/u/anarcat/libh/compile/text/../../lib/file/File.cc:214: undefined reference to `Configuration::no_action(void) const'
../../compile/text//libhfile.a(File.o): In function `Shared::Reference::operator++(void)':
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.t.__tf4File+0x1f): undefined reference to `LanguageInterface::Object type_info function'
/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$4File$Q217LanguageInterface6Object+0xc): undefined reference to `LanguageInterface::Object::objecttypename(void) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4File$Q217LanguageInterface6Object+0x14): undefined reference to `LanguageInterface::Object::class_documentation(void) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4File$Q217LanguageInterface6Object+0x1c): undefined reference to `LanguageInterface::Object::methods_documentation(LanguageInterface::Object::ClassDescription const *, set<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> >, less<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > >, allocator<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > > > &) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4File$Q217LanguageInterface6Object+0x24): undefined reference to `LanguageInterface::Object::method_documentation(LanguageInterface::Object::ClassDescription const *, basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > const &) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4File$Q217LanguageInterface6Object+0x2c): undefined reference to `LanguageInterface::Object::languageRef(LanguageInterface const *, bool) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$4File$Q217LanguageInterface6Object+0x34): undefined reference to `LanguageInterface::Object::languageUnref(LanguageInterface const *, bool) const'
../../compile/text//libhfile.a(Fetch.o): In function `basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> >::assign(char const *)':
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x9d): undefined reference to `LanguageInterface::Object::Object(int)'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.text+0x24d): undefined reference to `LanguageInterface::Object::~Object(void)'
../../compile/text//libhfile.a(Fetch.o): In function `Fetch::~Fetch(void)':
/u/anarcat/libh/compile/text/../../lib/file/Fetch.cc:74: undefined reference to `LanguageInterface::Object::~Object(void)'
../../compile/text//libhfile.a(Fetch.o): In function `basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> >::assign(char const *)':
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.t.__tf5Fetch+0x1f): undefined reference to `LanguageInterface::Object type_info function'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.data+0x10): undefined reference to `LanguageInterface::Object type_info node'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5Fetch$Q217LanguageInterface6Object+0xc): undefined reference to `LanguageInterface::Object::objecttypename(void) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5Fetch$Q217LanguageInterface6Object+0x14): undefined reference to `LanguageInterface::Object::class_documentation(void) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5Fetch$Q217LanguageInterface6Object+0x1c): undefined reference to `LanguageInterface::Object::methods_documentation(LanguageInterface::Object::ClassDescription const *, set<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> >, less<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > >, allocator<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > > > &) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5Fetch$Q217LanguageInterface6Object+0x24): undefined reference to `LanguageInterface::Object::method_documentation(LanguageInterface::Object::ClassDescription const *, basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > const &) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5Fetch$Q217LanguageInterface6Object+0x2c): undefined reference to `LanguageInterface::Object::languageRef(LanguageInterface const *, bool) const'
/u/anarcat/libh/compile/text/../../include/Pointer.hh(.gnu.linkonce.d._vt$5Fetch$Q217LanguageInterface6Object+0x34): undefined reference to `LanguageInterface::Object::languageUnref(LanguageInterface const *, bool) const'
../../compile/text//libhfile.a(RealFile.o): In function `_Vector_base<long, allocator<long> >::_Vector_base(unsigned int, allocator<long> const &)':
/usr/include/g++/stl_vector.h(.text+0x9d): undefined reference to `LanguageInterface::Object::Object(int)'
/usr/include/g++/stl_vector.h(.text+0x69d): undefined reference to `LanguageInterface::Object::~Object(void)'
../../compile/text//libhfile.a(RealFile.o): In function `RealFile::RealFile(int, basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > const &, stat)':
/u/anarcat/libh/compile/text/../../lib/file/RealFile.cc(.text+0x829): undefined reference to `LanguageInterface::Object::Object(int)'
/u/anarcat/libh/compile/text/../../lib/file/RealFile.cc(.text+0xa89): undefined reference to `LanguageInterface::Object::~Object(void)'
../../compile/text//libhfile.a(RealFile.o): In function `_Vector_base<long, allocator<long> >::_Vector_base(unsigned int, allocator<long> 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): undefined reference to `LanguageInterface::Object type_info function'
/usr/include/g++/stl_vector.h(.data+0x4): undefined reference to `LanguageInterface::Object type_info node'
/usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInterface6Object+0xc): undefined reference to `LanguageInterface::Object::objecttypename(void) const'
/usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInterface6Object+0x14): undefined reference to `LanguageInterface::Object::class_documentation(void) const'
/usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInterface6Object+0x1c): undefined reference to `LanguageInterface::Object::methods_documentation(LanguageInterface::Object::ClassDescription const *, set<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> >, less<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > >, allocator<basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > > > &) const'
/usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInterface6Object+0x24): undefined reference to `LanguageInterface::Object::method_documentation(LanguageInterface::Object::ClassDescription const *, basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > const &) const'
/usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInterface6Object+0x2c): undefined reference to `LanguageInterface::Object::languageRef(LanguageInterface const *, bool) const'
/usr/include/g++/stl_vector.h(.gnu.linkonce.d._vt$8RealFile$Q217LanguageInterface6Object+0x34): undefined reference to `LanguageInterface::Object::languageUnref(LanguageInterface const *, bool) const'
*** Error code 1
Stop in /u/anarcat/libh/bin/test_file.
I have no solutions for these problems.
This is the test program:
#include <iostream>
#include "file/File.hh"
int main (int argc, char** argv) {
cout << "===== File implementation test stub =====" << endl;
cout << "Creating a single File object: ";
File f = File();
cout << "done" << endl;
cout << "opening non-existent file /var/tmp/motd_copy for creation: ";
f = File("/var/tmp/motd_copy");
cout << "done" << endl;
cout << "trying to create()";
FILE* fd = 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 = File("file:/etc/motd");
cout << "done" << endl;
cout << "Local file name (open_local()): " << f2.open_local(false) << endl;
cout << "open_for_reading(): ";
FILE* fd2 = f2.open_for_reading(false);
cout << "done" << endl;
cout << "reading to file: ";
#define BUFSIZE 1024
char buffer[BUFSIZE];
size_t r;
while (r = 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
<< "let's do something similar with remote" << endl;
string tmpfile;
{
// this should be deleted at the end of this block
File newf = File("http://www.freebsd.org/");
cout << "url(): " << newf.url() << ", localName(): " << newf.localName() << endl;
cout << "trying to open_local(): " << newf.open_local(true) << endl;
tmpfile = newf.localName();
cout << "head -1 " << tmpfile << endl;
::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 = File("http://www.freebsd.org/");
try {
fd = f.create();
} catch (...) {
cout << "exception caught, create() not implemented" << endl;
}
cout << "reading a single line with open_for_reading()" << endl;
fd = f.open_for_reading(false);
char *line = fgetln(fd, &r);
line[r] = '\0';
cout << "first line: " << string(line) << endl;
cout << "close()ing: ";
f.close();
cout << "done." << endl;
cout << "localName() left over: " << f.localName() << endl;
}
a.
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjwXhLMACgkQttcWHAnWiGdMBgCgiZM3B0q89XNmH1Sq2b6c8Ynl
sf8AnR1LWKohJIv8H+/2cjnqlta5z5W0
=aJv/
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011212162420.GA65834>
