infinitе loop in freeIntRepProc()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

infinitе loop in freeIntRepProc()

Александр Митрохин
Hi.

I am sorry for my english.
I get infinite loop in freeIntRepProc(), if condition "obj == Tcl_GetObjResult(interp)" is true.

I want to write proc "typedef" and to define new types in tcl code. For example:

#!/usr/local/bin/tclsh

load ./typedef.so typedef

# typedef <type name> <constructor args> <constructor body> <destructor body>
typedef xxx {a b} {
    set x [list $a $b]
    puts "ctor: $x"
    return $x
} {
    puts "dtor: $this"
}

proc main {} {
    xxx 1 2
}

main

This approach shall cause a destructor call in case of automatic destruction of variable.

This code looped forewer if destroied object and interp result object are same.
http://tcl.uk.to/typedef.c

--
Александр Митрохин

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|

Re: infinitе loop in freeIntRepProc()

Christian Gollwitzer
Am 24.03.17 um 08:17 schrieb Александр Митрохин:
> I am sorry for my english.
> I get infinite loop in freeIntRepProc(), if condition "obj ==
> Tcl_GetObjResult(interp)" is true.
>
> I want to write proc "typedef" and to define new types in tcl code.

Maybe you are interested in the "tclvalue" extension which I prepared as
an experiment for the last EuroTcl conference. The code is here:

     https://github.com/auriocus/tclvalue

and here is the talk:

     https://www.youtube.com/watch?v=7mCDd-h89gQ

One thing I noticed during the preparation of this extension, Tcl is not
prepared to be invoked during the function working on the types,
especially the UpdateStringRep. It caused some random crashes in the
interpreter due to recursive invocation. Finally, I used another
Tcl_Interp for the execution of the type functions, but it felt so
hackish that in the end I think it is too dangerous to use that thing. YMMV

     Christian

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|

Re: infinitе loop in freeIntRepProc()

Dipl. Ing. Sergey G. Brester
In reply to this post by Александр Митрохин

Now understood (I think).

You should just reset obj->typePtr inside freeIntRepProc BEFORE you deletes it.
Or as already suggested a week pointer in-between.

Regards,
sebres.

Am 24.03.2017 08:17, schrieb Александр Митрохин:

Hi.

I am sorry for my english.
I get infinite loop in freeIntRepProc(), if condition "obj == Tcl_GetObjResult(interp)" is true.

I want to write proc "typedef" and to define new types in tcl code. For example:

#!/usr/local/bin/tclsh

load ./typedef.so typedef

# typedef <type name> <constructor args> <constructor body> <destructor body>
typedef xxx {a b} {
    set x [list $a $b]
    puts "ctor: $x"
    return $x
} {
    puts "dtor: $this"
}

proc main {} {
    xxx 1 2
}

main

This approach shall cause a destructor call in case of automatic destruction of variable.

This code looped forewer if destroied object and interp result object are same.
http://tcl.uk.to/typedef.c

--
Александр Митрохин

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Tcl-Core mailing list
Tcl-Core@...
https://lists.sourceforge.net/lists/listinfo/tcl-core

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|

Re: infinitе loop in freeIntRepProc()

Christian Gollwitzer
In reply to this post by Christian Gollwitzer
...forgot to link the slides:

Am 24.03.17 um 09:14 schrieb Christian Gollwitzer:
>
> and here is the talk:


http://www.eurotcl.tcl3d.org/presentations/EuroTcl2016-Gollwitzer-EIAS.pdf


        Christian


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core