[Gambas-user] Bug with JIT and external functions

Emil Lenngren emil.lenngren at ...626...
Tue Jun 19 21:57:41 CEST 2012


If you want a quick workaround, you can have non-fast method that creates a
callback, and immediately returns it, like:

Private Function GenerateCallback() As Pointer
  Return CallbackFunction
End

Fast Private Function CallbackFunction()
...
End

Extern extfunc(cb As Pointer) In "somelib"

Fast Private Function Main()
  Dim p As Pointer = GenerateCallback()
  extfunc(p)
End

/Emil

2012/6/19 Jussi Lahtinen <jussi.lahtinen at ...626...>

> No problem, I'm glad to help making Gambas more robust, when ever I have
> time to do so!
> And testing things seems to be easy contribution for me...
>
> My project has about 120 000 lines of code. And I try JIT with every module
> and class of it.
> So I think I will find more bugs... But in some point I must wait support
> for callbacks to finish that.
>
> Jussi
>
>
>
> On 19 June 2012 21:58, Emil Lenngren <emil.lenngren at ...626...> wrote:
>
> > Hi. Kiitos for another bug report :)
> >
> > Hmm.. I forgot that classes can override extern methods as well. That's
> > where the real problem is.
> >
> > /Emil
> >
> > 2012/6/19 Jussi Lahtinen <jussi.lahtinen at ...626...>
> >
> > > More bugs...
> > >
> > > Make shared library (just dummy example [or just use binary that is
> > > included with project source]);
> > >
> > > #include <math.h>
> > >
> > > int yEta(int x1, int y1, int x2, int y2)
> > > {return (int) hypot(x1-x2,y1-y2);}
> > >
> > >
> > > Then run the attached project.
> > > With JIT, number of arguments is counted wrong.
> > >
> > >
> > > Jussi
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On 19 June 2012 21:02, Jussi Lahtinen <jussi.lahtinen at ...626...>
> wrote:
> > >
> > > > Yes, it works now!
> > > >
> > > > Jussi
> > > >
> > > >
> > > >
> > > >
> > > > On 18 June 2012 22:34, Emil Lenngren <emil.lenngren at ...626...>
> wrote:
> > > >
> > > >> Does it work in revision #4847?
> > > >>
> > > >> /Emil
> > > >>
> > > >> 2012/6/18 Jussi Lahtinen <jussi.lahtinen at ...626...>
> > > >>
> > > >> > Starting program: /usr/local/bin/gbx3
> > > >> > [Thread debugging using libthread_db enabled]
> > > >> > Using host libthread_db library
> > > >> "/lib/x86_64-linux-gnu/libthread_db.so.1".
> > > >> > gbx3: ExecutionEngine.cpp:165: void
> > > >> > llvm::ExecutionEngine::addGlobalMapping(const llvm::GlobalValue*,
> > > >> void*):
> > > >> > Assertion `(CurVal == 0 || Addr == 0) && "GlobalMapping already
> > > >> > established!"' failed.
> > > >> >
> > > >> > Program received signal SIGABRT, Aborted.
> > > >> > 0x00007ffff7130445 in __GI_raise (sig=<optimized out>)
> > > >> >    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> > > >> > 64    ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or
> > > >> directory.
> > > >> > (gdb) bt
> > > >> > #0  0x00007ffff7130445 in __GI_raise (sig=<optimized out>)
> > > >> >    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> > > >> > #1  0x00007ffff7133bab in __GI_abort () at abort.c:91
> > > >> > #2  0x00007ffff712910e in __assert_fail_base (fmt=<optimized out>,
> > > >> >    assertion=0x7fffed43c3b8 "(CurVal == 0 || Addr == 0) &&
> > > >> \"GlobalMapping
> > > >> > already established!\"", file=0x7fffed43c55b
> "ExecutionEngine.cpp",
> > > >> >    line=<optimized out>, function=<optimized out>) at assert.c:94
> > > >> > #3  0x00007ffff71291b2 in __GI___assert_fail (
> > > >> >    assertion=0x7fffed43c3b8 "(CurVal == 0 || Addr == 0) &&
> > > >> \"GlobalMapping
> > > >> > already established!\"", file=0x7fffed43c55b
> "ExecutionEngine.cpp",
> > > >> > line=165,
> > > >> >    function=0x7fffed43d7a0 "void
> > > >> > llvm::ExecutionEngine::addGlobalMapping(const llvm::GlobalValue*,
> > > >> void*)")
> > > >> > at assert.c:103
> > > >> > #4  0x00007fffeca84aae in
> > > >> > llvm::ExecutionEngine::addGlobalMapping(llvm::GlobalValue const*,
> > > >> void*) ()
> > > >> > from /usr/lib/libLLVM-3.2svn.so
> > > >> > #5  0x00007fffedc85ec7 in register_global_symbol
> (address=0x40ebf6,
> > > >> >    value=0x8b2500, name=...) at jit_codegen.cpp:242
> > > >> > #6  register_global_symbol (name=..., value=0x8b2500,
> > > address=0x40ebf6)
> > > >> >    at jit_codegen.cpp:240
> > > >> > #7  0x00007fffedc8600e in get_global_function_real (
> > > >> >    name=0x7fffedcb9e57 "CLASS_free", func=0x40ebf6, ret=<optimized
> > > out>,
> > > >> >    args=<optimized out>, vararg=<optimized out>) at
> > > jit_codegen.cpp:276
> > > >> > #8  0x00007fffedc8a9dc in operator() (this=<synthetic pointer>)
> > > >> >    at jit_codegen.cpp:991
> > > >> > ---Type <return> to continue, or q <return> to quit---
> > > >> > #9  gen_if<unref_object_no_nullcheck(llvm::Value*)::<lambda()> >
> > > >> (func=...,
> > > >> >    cond=0x8999d0, if_name=<optimized out>, cont_name=<optimized
> > out>)
> > > >> >    at jit_codegen.cpp:562
> > > >> > #10 unref_object_no_nullcheck (ptr=0x898ca8) at
> jit_codegen.cpp:993
> > > >> > #11 0x00007fffedc9a44c in codegen_get_value (this=0x8abba0)
> > > >> >    at jit_codegen.cpp:1566
> > > >> > #12 PushPureObjectVariableExpression::codegen_get_value
> > > (this=0x8abba0)
> > > >> >    at jit_codegen.cpp:1545
> > > >> > #13 0x00007fffedca3f0d in SubrExpression::codegen_get_value
> > > >> (this=0x86a450)
> > > >> >    at jit_codegen.cpp:5898
> > > >> > #14 0x00007fffedc8c21d in DropExpression::codegen (this=0x86a4a0)
> > > >> >    at jit_codegen.cpp:1257
> > > >> > #15 0x00007fffedca6fa7 in codegen_statements () at
> > jit_codegen.cpp:855
> > > >> > #16 JIT_codegen () at jit_codegen.cpp:6490
> > > >> > #17 0x00007fffedcadc64 in JIT_compile_and_execute () at
> > > >> jit_compile.cpp:119
> > > >> > #18 0x000000000040a2fb in EXEC_jit_function_loop () at
> > gbx_exec.c:871
> > > >> > #19 0x000000000040ab22 in EXEC_function_real () at gbx_exec.c:862
> > > >> > #20 0x000000000041e86d in raise_event (observer=<optimized out>,
> > > >> >    object=<optimized out>, func_id=<optimized out>,
> > nparam=<optimized
> > > >> out>)
> > > >> >    at gbx_api.c:711
> > > >> > #21 0x000000000041efa6 in GB_Raise (object=0x8b95c8, event_id=16,
> > > >> nparam=0)
> > > >> >    at gbx_api.c:842
> > > >> > #22 0x00007ffff5fce3d3 in gb_raise_button_Click (sender=<optimized
> > > out>)
> > > >> >
> > > >> > Jussi
> > > >> >
> > > >> >
> > > >> >
> > > >> > On 18 June 2012 22:08, Emil Lenngren <emil.lenngren at ...626...>
> > wrote:
> > > >> >
> > > >> > > Hi. Can you please provide more information? A gdb backtrace or
> > > >> > something,
> > > >> > > because I get no errors at all. Everything seems to work for me
> > ...
> > > >> > >
> > > >> > > /Emil
> > > >> > >
> > > >> > > 2012/6/18 Jussi Lahtinen <jussi.lahtinen at ...626...>
> > > >> > >
> > > >> > > > OK, I found it. See attachment.
> > > >> > > >
> > > >> > > > Jussi
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > > > On 17 June 2012 23:36, Jussi Lahtinen <
> jussi.lahtinen at ...626...
> > >
> > > >> > wrote:
> > > >> > > >
> > > >> > > > > OK, that is fixed, and I cannot see any problems with
> compare
> > > >> method
> > > >> > > > > anymore.
> > > >> > > > >
> > > >> > > > > But with my big project, I got this with signal 6;
> > > >> > > > > gbx3: ExecutionEngine.cpp:165: void
> > > >> > > > > llvm::ExecutionEngine::addGlobalMapping(const
> > > llvm::GlobalValue*,
> > > >> > > void*):
> > > >> > > > > Assertion `(CurVal == 0 || Addr == 0) && "GlobalMapping
> > already
> > > >> > > > > established!"' failed.
> > > >> > > > >
> > > >> > > > > I'm out of time, but as soon as I have time I try to isolate
> > > code
> > > >> > > causing
> > > >> > > > > the problem.
> > > >> > > > >
> > > >> > > > > Jussi
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > On 17 June 2012 20:24, Emil Lenngren <
> emil.lenngren at ...626...
> > >
> > > >> > wrote:
> > > >> > > > >
> > > >> > > > >> It should be fixed in revision #4843!
> > > >> > > > >>
> > > >> > > > >> /Emil
> > > >> > > > >>
> > > >> > > > >> 2012/6/17 Jussi Lahtinen <jussi.lahtinen at ...626...>
> > > >> > > > >>
> > > >> > > > >> > Yes, it really works now. And I found  a lot of errors by
> > me.
> > > >> > > > >> >
> > > >> > > > >> > But for some reason JIT raises compare method when it
> > > >> shouldn't,
> > > >> > > > >> > and when I tried to isolate the problem I got crash
> (signal
> > > >> 11).
> > > >> > > > >> > This seems not to be related to compare method, so just
> > > ignore
> > > >> > name
> > > >> > > of
> > > >> > > > >> the
> > > >> > > > >> > attached project.
> > > >> > > > >> > I will look it more closely when this is fixed.
> > > >> > > > >> >
> > > >> > > > >> > Jussi
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> > On 17 June 2012 19:01, Emil Lenngren <
> > > emil.lenngren at ...626...>
> > > >> > > wrote:
> > > >> > > > >> >
> > > >> > > > >> > > Yes, it works now :)
> > > >> > > > >> > >
> > > >> > > > >> > > 2012/6/17 Benoît Minisini <
> gambas at ...1...>
> > > >> > > > >> > >
> > > >> > > > >> > > > Le 17/06/2012 02:54, Jussi Lahtinen a écrit :
> > > >> > > > >> > > > > Yeah, terminal gives other position...
> > > >> > > > >> > > > > With my actual project, I got error message; wanted
> > > >> string,
> > > >> > > got
> > > >> > > > >> > > > > blaablaaClass instead.
> > > >> > > > >> > > > > And that error message comes from function (from
> > other
> > > >> > module
> > > >> > > > >> without
> > > >> > > > >> > > > Fast)
> > > >> > > > >> > > > > which takes two objects are parameters.
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > So either terminal isn't showing the real stack, or
> > > >> there is
> > > >> > > > >> > something
> > > >> > > > >> > > > else
> > > >> > > > >> > > > > wrong...
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > But my time is up, I'll see it tomorrow (with
> latest
> > > >> > > revision).
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > Jussi
> > > >> > > > >> > > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > The incorrect line number problem, as reported by the
> > > >> debugger
> > > >> > > > (and
> > > >> > > > >> not
> > > >> > > > >> > > > when you run the program normally!), should be fixed
> in
> > > >> > revision
> > > >> > > > >> #4841.
> > > >> > > > >> > > >
> > > >> > > > >> > > > Regards,
> > > >> > > > >> > > >
> > > >> > > > >> > > > --
> > > >> > > > >> > > > Benoît Minisini
> > > >> > > > >> > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > >
> > > >> > > > >> > >
> > > >> > > > >> >
> > > >> > > > >>
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> > > > >> > > > Live Security Virtual Conference
> > > >> > > > >> > > > Exclusive live event will cover all the ways today's
> > > >> security
> > > >> > > and
> > > >> > > > >> > > > threat landscape has changed and how IT managers can
> > > >> respond.
> > > >> > > > >> > Discussions
> > > >> > > > >> > > > will include endpoint security, mobile security and
> the
> > > >> latest
> > > >> > > in
> > > >> > > > >> > malware
> > > >> > > > >> > > > threats.
> > > >> > > > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> > > > >> > > > _______________________________________________
> > > >> > > > >> > > > Gambas-user mailing list
> > > >> > > > >> > > > Gambas-user at lists.sourceforge.net
> > > >> > > > >> > > >
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >> > > > >> > > >
> > > >> > > > >> > >
> > > >> > > > >> > >
> > > >> > > > >> >
> > > >> > > > >>
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> > > > >> > > Live Security Virtual Conference
> > > >> > > > >> > > Exclusive live event will cover all the ways today's
> > > security
> > > >> > and
> > > >> > > > >> > > threat landscape has changed and how IT managers can
> > > respond.
> > > >> > > > >> Discussions
> > > >> > > > >> > > will include endpoint security, mobile security and the
> > > >> latest
> > > >> > in
> > > >> > > > >> malware
> > > >> > > > >> > > threats.
> > > >> > > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> > > > >> > > _______________________________________________
> > > >> > > > >> > > Gambas-user mailing list
> > > >> > > > >> > > Gambas-user at lists.sourceforge.net
> > > >> > > > >> > >
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >> > > > >> > >
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >>
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> > > > >> > Live Security Virtual Conference
> > > >> > > > >> > Exclusive live event will cover all the ways today's
> > security
> > > >> and
> > > >> > > > >> > threat landscape has changed and how IT managers can
> > respond.
> > > >> > > > >> Discussions
> > > >> > > > >> > will include endpoint security, mobile security and the
> > > latest
> > > >> in
> > > >> > > > >> malware
> > > >> > > > >> > threats.
> > > >> > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> > > > >> > _______________________________________________
> > > >> > > > >> > Gambas-user mailing list
> > > >> > > > >> > Gambas-user at lists.sourceforge.net
> > > >> > > > >> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >>
> > > >> > > > >>
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> > > > >> Live Security Virtual Conference
> > > >> > > > >> Exclusive live event will cover all the ways today's
> security
> > > and
> > > >> > > > >> threat landscape has changed and how IT managers can
> respond.
> > > >> > > > Discussions
> > > >> > > > >> will include endpoint security, mobile security and the
> > latest
> > > in
> > > >> > > > malware
> > > >> > > > >> threats.
> > > >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> > > > >> _______________________________________________
> > > >> > > > >> Gambas-user mailing list
> > > >> > > > >> Gambas-user at lists.sourceforge.net
> > > >> > > > >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >> > > > >>
> > > >> > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> > > > Live Security Virtual Conference
> > > >> > > > Exclusive live event will cover all the ways today's security
> > and
> > > >> > > > threat landscape has changed and how IT managers can respond.
> > > >> > Discussions
> > > >> > > > will include endpoint security, mobile security and the latest
> > in
> > > >> > malware
> > > >> > > > threats.
> > > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> > > > _______________________________________________
> > > >> > > > Gambas-user mailing list
> > > >> > > > Gambas-user at lists.sourceforge.net
> > > >> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >> > > >
> > > >> > > >
> > > >> > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> > > Live Security Virtual Conference
> > > >> > > Exclusive live event will cover all the ways today's security
> and
> > > >> > > threat landscape has changed and how IT managers can respond.
> > > >> Discussions
> > > >> > > will include endpoint security, mobile security and the latest
> in
> > > >> malware
> > > >> > > threats.
> > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> > > _______________________________________________
> > > >> > > Gambas-user mailing list
> > > >> > > Gambas-user at lists.sourceforge.net
> > > >> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >> > >
> > > >> >
> > > >> >
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> > Live Security Virtual Conference
> > > >> > Exclusive live event will cover all the ways today's security and
> > > >> > threat landscape has changed and how IT managers can respond.
> > > >> Discussions
> > > >> > will include endpoint security, mobile security and the latest in
> > > >> malware
> > > >> > threats.
> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> > _______________________________________________
> > > >> > Gambas-user mailing list
> > > >> > Gambas-user at lists.sourceforge.net
> > > >> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >> >
> > > >>
> > > >>
> > >
> >
> ------------------------------------------------------------------------------
> > > >> Live Security Virtual Conference
> > > >> Exclusive live event will cover all the ways today's security and
> > > >> threat landscape has changed and how IT managers can respond.
> > > Discussions
> > > >> will include endpoint security, mobile security and the latest in
> > > malware
> > > >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > >> _______________________________________________
> > > >> Gambas-user mailing list
> > > >> Gambas-user at lists.sourceforge.net
> > > >> https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >>
> > > >
> > > >
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------------
> > > Live Security Virtual Conference
> > > Exclusive live event will cover all the ways today's security and
> > > threat landscape has changed and how IT managers can respond.
> Discussions
> > > will include endpoint security, mobile security and the latest in
> malware
> > > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > >
> >
> >
> ------------------------------------------------------------------------------
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and
> > threat landscape has changed and how IT managers can respond. Discussions
> > will include endpoint security, mobile security and the latest in malware
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



More information about the User mailing list