Re: [Chicken-users] newbie: questions about set-finalizer!

2009-02-18 Thread felix winkelmann
On Fri, Feb 13, 2009 at 2:31 PM, felix winkelmann bunny...@gmail.com wrote:

 In interpreted code, the finalizers do not trigger at all, even when
 you exit csi via (exit).



Hi!

I have reverted the original change that caused this for the time being.


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2009-02-13 Thread felix winkelmann
On Thu, Jan 29, 2009 at 9:01 PM, Jim Ursetto zbignie...@gmail.com wrote:
 On Thu, Jan 29, 2009 at 5:56 AM, felix winkelmann bunny...@gmail.com wrote:
 On Thu, Jan 29, 2009 at 9:41 AM, Jim Ursetto zbignie...@gmail.com wrote:
 I am seeing finalizers fail to execute on recent SVN and I think
 it is the result of this change.  I backed out the patch and it works
 okay again.

 Is the behaviour identical for compiled code?

 No, it works correctly for compiled code.  They trigger immediately
 after (gc #t).

 In interpreted code, the finalizers do not trigger at all, even when
 you exit csi via (exit).


Hm... I think this is related to the fact, that interpreter environments
are managed differently (the closure representation in the interpreter
is a simple linked list of environments, so it is possible that more indirect
references to finalizers are left. But this should work. Have to investigate.


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2009-01-29 Thread Jim Ursetto
On Mon, Dec 22, 2008 at 3:03 AM, felix winkelmann bunny...@gmail.com wrote:
 Please try this [finalizer patch].

Hi.  I am seeing finalizers fail to execute on recent SVN and I think
it is the result of this change.  I backed out the patch and it works
okay again.

On Version 3.4.10 - SVN rev. 13079 - macosx-unix-gnu-x86
and Version 4.0.0x5 - SVN rev. 13079  - macosx-unix-gnu-x86

#;1 (let ((abc (vector 5))) (set-finalizer! abc (lambda (x) (print
final))) (void))
#;2 (gc #t)
142744

On Version 3.3.10 - SVN rev. 11733 - macosx-unix-gnu-x86,
and on 4.0.0x5 rev. 13079 with reversed runtime.c patch:

#;1 (let ((abc (vector 5))) (set-finalizer! abc (lambda (x) (print
final))) (void))
#;2 (gc #t)
final; right
139240


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2009-01-29 Thread felix winkelmann
On Thu, Jan 29, 2009 at 9:41 AM, Jim Ursetto zbignie...@gmail.com wrote:
 On Mon, Dec 22, 2008 at 3:03 AM, felix winkelmann bunny...@gmail.com wrote:
 Please try this [finalizer patch].

 Hi.  I am seeing finalizers fail to execute on recent SVN and I think
 it is the result of this change.  I backed out the patch and it works
 okay again.

 On Version 3.4.10 - SVN rev. 13079 - macosx-unix-gnu-x86
 and Version 4.0.0x5 - SVN rev. 13079  - macosx-unix-gnu-x86

 #;1 (let ((abc (vector 5))) (set-finalizer! abc (lambda (x) (print
 final))) (void))
 #;2 (gc #t)
 142744

 On Version 3.3.10 - SVN rev. 11733 - macosx-unix-gnu-x86,
 and on 4.0.0x5 rev. 13079 with reversed runtime.c patch:

 #;1 (let ((abc (vector 5))) (set-finalizer! abc (lambda (x) (print
 final))) (void))
 #;2 (gc #t)
 final; right
 139240


Hi, Jim!

Is the behaviour identical for compiled code?


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2009-01-29 Thread Jim Ursetto
On Thu, Jan 29, 2009 at 5:56 AM, felix winkelmann bunny...@gmail.com wrote:
 On Thu, Jan 29, 2009 at 9:41 AM, Jim Ursetto zbignie...@gmail.com wrote:
 I am seeing finalizers fail to execute on recent SVN and I think
 it is the result of this change.  I backed out the patch and it works
 okay again.

 Is the behaviour identical for compiled code?

No, it works correctly for compiled code.  They trigger immediately
after (gc #t).

In interpreted code, the finalizers do not trigger at all, even when
you exit csi via (exit).


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2008-12-22 Thread felix winkelmann
On Sat, Dec 20, 2008 at 4:04 PM, Alejandro Forero Cuervo
a...@freaks-unidos.net wrote:

 Please try attached patch. I have added it to trunk and the chicken-3
 branch, and did some tests, but testing finalization is always somewhat
 difficult.

 I tried the patch (on 3.4.0) and it did not work.

 Running in csi the original code in my report,

  (define x (list 1 2 3))
  (begin (set-finalizer! x (lambda (o) (format #t Delete: ~A~% o))) #t)
  (define y (list 4 5 6))
  (begin (set-finalizer! y (let ((p x)) (lambda (o) (format #t Delete: ~A: 
 ~A~% o p #t)
  (gc #t)
  (set! x #f)
  (gc #t)

 , still produces the Delete (1 2 3) message, which it shouldn't.


You're right. My bad. I'll try once more.


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2008-12-22 Thread felix winkelmann
Please try this one.


cheers
felix
Index: runtime.c
===
--- runtime.c	(revision 12851)
+++ runtime.c	(working copy)
@@ -2706,6 +2706,10 @@
 for(gcrp = gc_root_list; gcrp != NULL; gcrp = gcrp-next)
   mark(gcrp-value);
 
+/* mark finalizer procedures: */
+for(flist = finalizer_list; flist != NULL; flist = flist-next) 
+  mark(flist-finalizer);
+
 mark_system_globals();
   }
   else {
@@ -2770,7 +2774,6 @@
 
 	for(flist = finalizer_list; flist != NULL; flist = flist-next) {
 	  mark(flist-item);
-	  mark(flist-finalizer);
 	  ++fcount;
 	}
 
@@ -2780,9 +2783,6 @@
   else {
 	j = fcount = 0;
 
-	for(flist = finalizer_list; flist != NULL; flist = flist-next) 
-	  mark(flist-finalizer);
-
 	for(flist = finalizer_list; flist != NULL; flist = flist-next) {
 	  if(j  C_max_pending_finalizers) {
 	if(!is_fptr(C_block_header(flist-item))) 
@@ -2797,7 +2797,7 @@
   finalizers_checked = 1;
 
   if(pending_finalizer_count  0  gc_report_flag)
-	C_printf(C_text([GC] finalizers pending for rescan: %d (%d live)\n), 
+	C_printf(C_text([GC] finalizers pending: %d (%d live)\n), 
 		 pending_finalizer_count, live_finalizer_count);
 
   goto rescan;
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2008-12-21 Thread felix winkelmann
On Sat, Dec 20, 2008 at 4:04 PM, Alejandro Forero Cuervo
a...@freaks-unidos.net wrote:

 Please try attached patch. I have added it to trunk and the chicken-3
 branch, and did some tests, but testing finalization is always somewhat
 difficult.

 I tried the patch (on 3.4.0) and it did not work.

 Running in csi the original code in my report,

  (define x (list 1 2 3))
  (begin (set-finalizer! x (lambda (o) (format #t Delete: ~A~% o))) #t)
  (define y (list 4 5 6))
  (begin (set-finalizer! y (let ((p x)) (lambda (o) (format #t Delete: ~A: 
 ~A~% o p #t)
  (gc #t)
  (set! x #f)
  (gc #t)

 , still produces the Delete (1 2 3) message, which it shouldn't.


I'm pretty sure it works. Is it possible that you mixed up two different
installations?


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2008-12-20 Thread Alejandro Forero Cuervo

 Please try attached patch. I have added it to trunk and the chicken-3
 branch, and did some tests, but testing finalization is always somewhat
 difficult.

I tried the patch (on 3.4.0) and it did not work.

Running in csi the original code in my report,

  (define x (list 1 2 3))
  (begin (set-finalizer! x (lambda (o) (format #t Delete: ~A~% o))) #t)
  (define y (list 4 5 6))
  (begin (set-finalizer! y (let ((p x)) (lambda (o) (format #t Delete: ~A: 
~A~% o p #t)
  (gc #t)
  (set! x #f)
  (gc #t)

, still produces the Delete (1 2 3) message, which it shouldn't.

Alejo.
http://azul.freaks-unidos.net/


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2008-12-17 Thread felix winkelmann
On Tue, Dec 16, 2008 at 7:36 PM, felix winkelmann bunny...@gmail.com wrote:
 On Mon, Dec 15, 2008 at 11:57 PM, Alejandro Forero Cuervo
 a...@freaks-unidos.net wrote:

 I have a question about finalizers.

 If you run the following in csi:

  (define x (list 1 2 3))
  (begin (set-finalizer! x (lambda (o) (format #t Delete: ~A~% o))) #t)
  (define y (list 4 5 6))
  (begin (set-finalizer! y (let ((p x)) (lambda (o) (format #t Delete: ~A: 
 ~A~% o p #t)
  (gc #t)
  (set! x #f)
  (gc #t)

 Why do you get Delete: (1 2 3), the output of the finalizer for x,
 even though the finalizer for y depends on the value of x?

 Am I misunderstanding the way finalizer procedures get executed?


 A bug. The finalizer itself is not considered in the calculation whether
 something is still referenced or not (I think). I have to investigate.


Hi!

Please try attached patch. I have added it to trunk and the chicken-3
branch, and did some tests, but testing finalization is always somewhat
difficult.


cheers,
felix
Index: runtime.c
===
--- runtime.c	(revision 12830)
+++ runtime.c	(working copy)
@@ -2701,7 +2701,8 @@
 /* Mark collectibles: */
 for(msp = collectibles; msp  collectibles_top; ++msp)
   if(*msp != NULL) mark(*msp);
-
+
+/* mark GC roots: */
 for(gcrp = gc_root_list; gcrp != NULL; gcrp = gcrp-next)
   mark(gcrp-value);
 
@@ -2779,6 +2780,9 @@
   else {
 	j = fcount = 0;
 
+	for(flist = finalizer_list; flist != NULL; flist = flist-next) 
+	  mark(flist-finalizer);
+
 	for(flist = finalizer_list; flist != NULL; flist = flist-next) {
 	  if(j  C_max_pending_finalizers) {
 	if(!is_fptr(C_block_header(flist-item))) 
@@ -2786,7 +2790,6 @@
 	  }
 
 	  mark(flist-item);
-	  mark(flist-finalizer);
 	}
   }
 
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] newbie: questions about set-finalizer!

2008-12-16 Thread felix winkelmann
On Mon, Dec 15, 2008 at 11:57 PM, Alejandro Forero Cuervo
a...@freaks-unidos.net wrote:

 I have a question about finalizers.

 If you run the following in csi:

  (define x (list 1 2 3))
  (begin (set-finalizer! x (lambda (o) (format #t Delete: ~A~% o))) #t)
  (define y (list 4 5 6))
  (begin (set-finalizer! y (let ((p x)) (lambda (o) (format #t Delete: ~A: 
 ~A~% o p #t)
  (gc #t)
  (set! x #f)
  (gc #t)

 Why do you get Delete: (1 2 3), the output of the finalizer for x,
 even though the finalizer for y depends on the value of x?

 Am I misunderstanding the way finalizer procedures get executed?


A bug. The finalizer itself is not considered in the calculation whether
something is still referenced or not (I think). I have to investigate.


cheers,
felix


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users