Re: context pointer always NULL for "c-tor" when created w/ Reflex::ClassBuilder::AddFunctionMember ?

From: Sebastien Binet <binet_at_cern.ch>
Date: Tue, 17 May 2011 13:33:16 +0200


On Tue, 17 May 2011 12:22:16 +0200, Sebastien Binet <binet_at_cern.ch> wrote:
> On Tue, 17 May 2011 11:04:10 +0200, Axel Naumann <Axel.Naumann_at_cern.ch> wrote:
> > Hi Sebastien,
> >
> > I don't know how you bind it to Go. How does the constructor get
> > invoked?
> that's probably done by TTree/TBranch... I am not calling it directly.
>
> > I.e. is Reflex::FunctionMember::Invoke() really called? Can you
> > send the backtrace?
> ah! got it.
> it is probably b/c of:
> http://root.cern.ch/lxr/source/cint/reflex/src/Object.cxx#89
> 80 //-------------------------------------------------------------------------------
> 81 // Invoke a data member of this object. Sign can be used for finding overloaded funs.
> 82 // Put return value(if not void) into ret.
> 83 Member m = TypeOf().FunctionMemberByName(fm, sign);
> 84
> 85 if (!m) {
> 86 throw RuntimeError("No such MemberAt " + fm);
> 87 }
> 88
> 89 m.Invoke(*this, ret, args);
> 90 }

arf... scratch that. I have of course been confusing all of these Invokes...

here is the backtrace:
(gdb) bt
#0 ctor_Event (retaddr=0x0, mem=0xa55500, args=0x86a5d0, ctx=0x0)

    at ../src/externals/go-io-benchmarks/cmds/croot_event.h:45

#1  0x00007ffff4153438 in ROOT::Cintex::Constructor_stub_with_context(ROOT::Cintex::StubContext_t*, G__value*, char const*, G__param*, int) () from /usr/lib/root/libCintex.so.5.28
#2  0x00007ffff65d6d17 in Cint::G__ClassInfo::New() () from /usr/lib/root/libCint.so.5.28
#3  0x00007ffff712611a in TClass::New(TClass::ENewType) const () from /usr/lib/root/libCore.so.5.28
#4  0x00007ffff7126f9b in TClass::BuildRealData(void*, bool) () from /usr/lib/root/libCore.so.5.28
#5  0x00007ffff5e2b3ea in TStreamerInfo::Build() () from /usr/lib/root/libRIO.so.5.28
#6  0x00007ffff71222c3 in TClass::GetStreamerInfo(int) const () from /usr/lib/root/libCore.so.5.28
#7  0x00007ffff5e2c6df in TStreamerInfo::BuildOld() () from /usr/lib/root/libRIO.so.5.28
#8  0x00007ffff71221ac in TClass::GetStreamerInfo(int) const () from /usr/lib/root/libCore.so.5.28
#9  0x00007ffff620c7b6 in TBranchElement::InitInfo() () from /usr/lib/root/libTree.so.5.28
#10 0x00007ffff620b10c in TBranchElement::SetAddress(void*) () from /usr/lib/root/libTree.so.5.28
#11 0x00007ffff623aed4 in TTree::SetBranchAddressImp(TBranch*, void*, TBranch**) () from /usr/lib/root/libTree.so.5.28
#12 0x0000000000402392 in tree0 (f=<value optimized out>) at ../src/externals/go-io-benchmarks/cmds/croot-read-new-struct.c:23
#13 0x0000000000401857 in main (argc=1, argv=0x7fffffffe558) at ../src/externals/go-io-benchmarks/cmds/croot-read-new-struct.c:71

-s

>
> Object::Invoke not passing m.Stubcontext() to m.Invoke...
>
> -s
>
>
> >
> > Cheers, Axel.
> >
> >
> > Sebastien Binet wrote on 05/17/2011 10:46 AM:
> > >
> > > hi there,
> > >
> > > (still playing with Go)
> > > I am seeing something rather strange:
> > >
> > > say I have these structs:
> > >
> > > /** edm **/
> > > typedef struct {
> > > double E;
> > > double T;
> > > } Det;
> > >
> > > typedef struct {
> > > Det A;
> > > Det B;
> > > } Event;
> > >
> > > size_t g_sz_det = sizeof(Det);
> > > size_t g_sz_evt = sizeof(Event);
> > >
> > >
> > > and the corresponding c-tor stub functions:
> > > /* stub functions for Event */
> > > void ctor_Event(void *retaddr, void *mem, void* args, void* ctx)
> > > {
> > > fprintf(stderr, "::ctor-fct[Event] [%p] [%p] [%p] [%p]\n", retaddr, mem, args, ctx);
> > > void* dummy = 0;
> > > if (retaddr) *(void**)retaddr = (Event*)realloc(mem, sizeof(Event));
> > > else dummy = (Event*)realloc(mem, sizeof(Event));
> > > if (dummy) {}
> > > }
> > >
> > > /* etc... */
> > >
> > > the ctor_Event stub function is attached to the Event Reflex::Type like
> > > so:
> > > Reflex::ClassBuilder cb = ...;
> > > Reflex::Type ty_ctor = Reflex::FunctionTypeBuilder(ty_void);
> > > void *ctx = &g_sz_evt;
> > > cb.AddFunctionMember(ty_ctor, "Event", &ctor_Event, ctx, NULL,
> > > Reflex::PUBLIC|Reflex::CONSTRUCTOR);
> > >
> > >
> > > so far so good, and when iterating over the function members of the
> > > "Event" type I do see:
> > > :: Evt-size: 32 32
> > > :: Evt-mbrs: 2
> > > :: Evt-type: 117
> > > :: Evt-name: Event
> > > :: Evt-id: 0x11c28d0
> > > :: Evt-fct-mbrs: 3
> > > :: fct-mbr[0][Event] - ctx [0x6033b8] stub-fct[0x401960]
> > > :: fct-mbr[1][IsA] - ctx [0x11c3910] stub-fct[0x7f9892ed2290]
> > > :: fct-mbr[2][ShowMembers] - ctx [0x11c3910] stub-fct[0x7f9892ed1d00]
> > >
> > > ie: the correct address for both the context pointer and the stub
> > > function (calling resp. Member::Stubcontext() and Member::Stubfunction())
> > >
> > > but when the ctor_Event function is invoked:
> > > ::ctor-fct[Event] [(nil)] [0x13b3500] [0x11c85d0] [(nil)]
> > >
> > > the ctx pointer is always NULL, eventhough FunctionMember::Invoke does
> > > pass the fStubCtx to fStubFP:
> > >
> > > // parameters need more checking FIXME
> > > fStubFP(retaddr, mem, paramList, fStubCtx);
> > >
> > >
> > > (I'd like to use that context pointer to pass a few extra informations
> > > needed for the proper initialization of the Go runtime when
> > > instantiating the struct instance...)
> > >
> > > am I doing something wrong ?
> > >
> > > -s
> > >
>
> --
> #########################################
> # Dr. Sebastien Binet
> # Laboratoire de l'Accelerateur Lineaire
> # Universite Paris-Sud XI
> # Batiment 200
> # 91898 Orsay
> #########################################
Non-text part: application/pgp-signature

-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################

  • application/pgp-signature attachment: stored
Received on Tue May 17 2011 - 13:33:21 CEST

This archive was generated by hypermail 2.2.0 : Tue May 17 2011 - 17:50:01 CEST