Re: [ROOT] fcn for TF1

From: Arthur E. Snyder (snyder@slac.stanford.edu)
Date: Wed Sep 29 2004 - 22:05:09 MEST


Empirically (I just tried it), I find that I can use compiled functions to
define TF1 objects.  It appears that the comment specifying only
intrepreted functions is wrong or out-of-date.

-Art

A.E. Snyder, Group EC                        \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder@slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:650-926-2657                          Collaboration



On Wed, 29 Sep 2004, Arthur E. Snyder wrote:

> The TF1 constructor from a function(fcn) says (in the comments) that fcn
> is an intrepreted function. I would prefer to compile my function; will
> TF1 accept a compiled function? If not how do I make a compiled function?
>
> -Art
>
> A.E. Snyder, Group EC                        \!c*p?/
> SLAC Mail Stop #95                          ((.   .))
> Box 4349                                        |
> Stanford, Ca, USA, 94309                      '\|/`
> e-mail:snyder@slac.stanford.edu                 o
> phone:650-926-2701                              _
> http://www.slac.stanford.edu/~snyder          BaBar
> FAX:650-926-2657                          Collaboration
>
>
>
> On Mon, 5 Aug 2002, Brett Viren wrote:
>
> > Hi,
> >
> > I sure hope someone can help as I am at my wits end here.
> >
> > I am finding that exceptions which should be caught are instead
> > triggering an abort() when they are called from code which is
> > dynamically loaded into ROOT, either explicitly with gSystem->Load()
> > (or via building a special root.exe which is otherwise the same but
> > uses "-l" to link the library in).  Details and example are below.
> >
> > I have tested it with a fairly recent CVS build but also the binary
> > tar file: root_v3.03.07.Linux.RH7.2.gcc2953.tar.gz.
> >
> > The problem is occuring on Debian system which uses GCC version:
> >
> > bviren@minos:bviren> gcc -v
> > Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
> > gcc version 2.95.4 20011002 (Debian prerelease)
> >
> > I *think* this is just GCC 2.95.3 + some bug fixes by the Debian
> > maintainers.  Other collaborators on other systems don't see it.
> > Also, I don't reproduce it under 3.1.
> >
> > As a test I have a simple struct with one method that will throw an
> > exception:
> >
> > ---------------------------
> > //tlib.cxx
> > #include "tlib.h"
> > void tlib::doit() {
> >     throw "something";
> > }
> > // end tlib.cxx
> > ---------------------------
> > // tlib.h
> > #ifndef TLIB_H
> > #define TLIB_H
> > struct tlib {
> >     void doit();
> > };
> > #endif  // TLIB_H
> > ---------------------------
> > // LinkDef.h
> > #ifdef __CINT__
> > #pragma link off all globals;
> > #pragma link off all classes;
> > #pragma link off all functions;
> > #pragma link C++ struct tlib;
> > #endif
> > ---------------------------
> > // main.cc for testing w/out ROOT
> > #include <iostream>
> > #include "tlib.h"
> > int main() {
> >     try {
> >         tlib t;
> >         t.doit();
> >     }
> >     catch (const char* msg) {
> >         cerr << "Exception!: " << msg << endl << flush;
> >     }
> > }
> > ---------------------------
> > To build I do:
> >
> > ---------------------------
> > g++-2.95 -march=i686 -Wall -g -I. -I$ROOTSYS/include -fPIC -c tlib.cxx -otlib.o
> > rootcint -f tlibCint.cc -c -I. -I$ROOTSYS/include  tlib.h LinkDef.h
> > g++-2.95 -march=i686 -Wall -g -I. -I$ROOTSYS/include -fPIC -c tlibCint.cc -o tlibCint.o
> > g++-2.95 -shared -o libtlib.so tlib.o tlibCint.o
> > gcc-2.95 -shared -o libtlib-noroot.so tlib.o
> > g++-2.95 -march=i686 -Wall -g -I. -L. -o tlib-noroot main.cc -ltlib-noroot -rdynamic
> > ---------------------------
> >
> >
> > And, finally to test it I do:
> >
> >
> > ---------------------------
> > bviren@minos:jnk> ./tlib-noroot
> > Exception!: something
> > bviren@minos:jnk> root.exe
> >   *******************************************
> >   *                                         *
> >   *        W E L C O M E  to  R O O T       *
> >   *                                         *
> >   *   Version   3.03/07      18 July 2002   *
> >   *                                         *
> >   *  You are welcome to visit our Web site  *
> >   *          http://root.cern.ch            *
> >   *                                         *
> >   *******************************************
> >
> > FreeType Engine v1.x used to render TrueType fonts.
> > Compiled for linux with thread support.
> >
> > CINT/ROOT C/C++ Interpreter version 5.15.50, July 7 2002
> > Type ? for help. Commands must be C++ statements.
> > Enclose multiple statements between { }.
> > PAWish style
> > root [0] gSystem->Load("libtlib"); tlib t; t.doit()
> > Aborted
> > ---------------------------
> >
> >
> > Doing this again while running in GDB 5.2 gives a stack trace which
> > looks like:
> >
> >
> > ---------------------------
> > 0x40cb3741 in kill () from /lib/libc.so.6
> > (gdb) where
> > #0  0x40cb3741 in kill () from /lib/libc.so.6
> > #1  0x40c5de5e in pthread_kill () from /lib/libpthread.so.0
> > #2  0x40c5e339 in raise () from /lib/libpthread.so.0
> > #3  0x40cb4b81 in abort () from /lib/libc.so.6
> > #4  0x403643cb in __default_terminate () at ../../gcc/gcc/libgcc2.c:-1
> > #5  0x403643ec in __terminate () from /home/bviren/root/lib/libCore.so
> > #6  0x40364d24 in throw_helper (eh=0x404c34c4, pc=0x40575fe1,
> >     my_udata=0xbffe6f9c, offset_p=0xbffe6f98)
> >    from /home/bviren/root/lib/libCore.so
> > #7  0x40364edc in __throw () from /home/bviren/root/lib/libCore.so
> > #8  0x40f068fd in tlib::doit (this=0x87636a8) at tlib.cxx:4
> > #9  0x40f06b59 in G__tlib_doit_0_0 (result7=0xbfff39f0, funcname=0x0,
> >     libp=0xbfff058c, hash=0) at tlibCint.cc:93
> > #10 0x40575fe2 in G__call_cppfunc () from /home/bviren/root/lib/libCint.so
> > #11 0x4056563b in G__interpret_func () from /home/bviren/root/lib/libCint.so
> > #12 0x4054c95d in G__getfunction () from /home/bviren/root/lib/libCint.so
> > #13 0x405d6b56 in G__getstructmem () from /home/bviren/root/lib/libCint.so
> > #14 0x405cfea0 in G__getvariable () from /home/bviren/root/lib/libCint.so
> > #15 0x40544cbf in G__getitem () from /home/bviren/root/lib/libCint.so
> > #16 0x40543593 in G__getexpr () from /home/bviren/root/lib/libCint.so
> > #17 0x4058c951 in G__exec_function () from /home/bviren/root/lib/libCint.so
> > #18 0x405938eb in G__exec_statement () from /home/bviren/root/lib/libCint.so
> > #19 0x4052ae92 in G__exec_tempfile () from /home/bviren/root/lib/libCint.so
> > #20 0x4059baa7 in G__process_cmd () from /home/bviren/root/lib/libCint.so
> > #21 0x4015da3e in TCint::ProcessLine () from /home/bviren/root/lib/libCore.so
> > #22 0x400f4aa1 in TApplication::ProcessLine ()
> >    from /home/bviren/root/lib/libCore.so
> > #23 0x40c1d5bb in TRint::HandleTermInput ()
> >    from /home/bviren/root/lib/libRint.so
> > #24 0x40c1c71d in TTermInputHandler::Notify ()
> >    from /home/bviren/root/lib/libRint.so
> > #25 0x40c35d54 in TTermInputHandler::ReadNotify ()
> >    from /home/bviren/root/lib/libRint.so
> > #26 0x40196c0a in TUnixSystem::CheckDescriptors ()
> >    from /home/bviren/root/lib/libCore.so
> > #27 0x4019633b in TUnixSystem::DispatchOneEvent ()
> >    from /home/bviren/root/lib/libCore.so
> > #28 0x40139399 in TSystem::InnerLoop () from /home/bviren/root/lib/libCore.so
> > #29 0x40139309 in TSystem::Run () from /home/bviren/root/lib/libCore.so
> > #30 0x400f54c6 in TApplication::Run () from /home/bviren/root/lib/libCore.so
> > #31 0x40c1d070 in TRint::Run () from /home/bviren/root/lib/libRint.so
> > #32 0x080487b7 in main ()
> > #33 0x40ca314f in __libc_start_main () from /lib/libc.so.6
> > ---------------------------
> >
> >
> > Please, Obi-wan (or any-wan), you are my only hope!
> >
> > -Brett.
> >
>
>



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET