[bug] Delay issue

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

[bug] Delay issue

MrGwen
Issue status update for
http://smalltalk.gnu.org/node/631
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/631

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    VM
 Category:     bug reports
 Priority:     normal
 Assigned to:  MrGwen
 Reported by:  MrGwen
 Updated by:   MrGwen
 Status:       active

In master I've the following problem with Delay.
st> d := Delay forSeconds: 2.
st> d wait
(wait two seconds)
st> d wait
(doesn't wait anymore)
st> d reset; wait
 (wait again two seconds)

If I change Delay class>>#unscheduleDelay: it works

Delay class >> unscheduleDelay: aDelay [
 "Private - Unschedule this Delay.  Run in the timer process, which
  is the only one that manipulates Queue."

 
 | activeDelay |
 activeDelay := self activeDelay.
 activeDelay isNil ifTrue: [^self].
 aDelay reset.
 activeDelay == aDelay ifTrue: [^Queue removeLast].
 Queue identityRemove: aDelay ifAbsent: [].
]



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

Paolo Bonzini-3
Issue status update for
http://smalltalk.gnu.org/project/issue/631
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/631

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    VM
 Category:     bug reports
 Priority:     normal
 Assigned to:  MrGwen
 Reported by:  MrGwen
 Updated by:   bonzinip
-Status:       active
+Status:       fixed

The patch looks sane, but do you have any idea why it doesn't show on
3.2?



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

MrGwen
In reply to this post by MrGwen
Issue status update for
http://smalltalk.gnu.org/project/issue/631
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/631

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    VM
 Category:     bug reports
 Priority:     normal
 Assigned to:  MrGwen
 Reported by:  MrGwen
 Updated by:   MrGwen
 Status:       fixed

I've tried with gst 3.2.4 and there is the same bug



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

Ladislav Marek
Hi,

after this change, code:

5 timesRepeat: [
    [(Delay forSeconds: 2) value: [] onTimeoutDo: [Error signal]] fork].
Processor activeProcess suspend.

ends with:

Object: nil error: did not understand #goodness:
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #goodness: (SysExcept.st:1442)
optimized [] in BlockClosure class>>exceptionHandlerSearchBlock
(BlkClosure.st:16)
[] in MessageNotUnderstood(Exception)>>instantiateNextHandlerFrom:
(ExcHandling.st:339)
MethodContext(ContextPart)>>scanBacktraceForAttribute:do: (ContextPart.st:449)
MessageNotUnderstood(Exception)>>instantiateNextHandlerFrom:
(ExcHandling.st:335)
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:253)
UndefinedObject(Object)>>doesNotUnderstand: #generality (SysExcept.st:1442)
SmallInteger(Number)>>retryDifferenceCoercing: (Number.st:357)
SmallInteger(Number)>>retryRelationalOp:coercing: (Number.st:295)
SmallInteger>>>= (SmallInt.st:223)
optimized [] in Delay class>>startDelayLoop (Delay.st:166)
SortedCollection>>percolateDown (SortCollect.st:490)
SortedCollection>>sortHeap (SortCollect.st:435)
SortedCollection>>beConsistent (SortCollect.st:246)
SortedCollection>>at: (SortCollect.st:147)
SortedCollection(SequenceableCollection)>>identityIndexOf:startingAt:ifAbsent:
(SeqCollect.st:415)
SortedCollection(OrderedCollection)>>identityRemove:ifAbsent: (OrderColl.st:334)
Delay class>>unscheduleDelay: (bug7.st:13)
Delay class>>handleDelayRequestor (Delay.st:99)
optimized [] in Delay class>>runDelayProcess (Delay.st:124)
[] in BlockClosure>>ifCurtailed: (BlkClosure.st:286)
BlockClosure>>ensure: (BlkClosure.st:268)
BlockClosure>>ifCurtailed: (BlkClosure.st:273)
Delay class>>runDelayProcess (Delay.st:120)
optimized [] in Delay class>>startDelayLoop (Delay.st:168)
[] in Process>>onBlock:at:suspend: (Process.st:411)
BlockClosure>>on:do: (BlkClosure.st:193)
[] in Process>>onBlock:at:suspend: (Process.st:412)
BlockClosure>>ensure: (BlkClosure.st:268)
[] in Process>>onBlock:at:suspend: (Process.st:390)
[] in BlockClosure>>asContext: (BlkClosure.st:179)
BlockContext class>>fromClosure:parent: (BlkContext.st:68)

On Sun, Jan 22, 2012 at 15:15, Gwenael Casaccio <[hidden email]> wrote:

> Issue status update for http://smalltalk.gnu.org/project/issue/631
>
> Post a follow up: http://smalltalk.gnu.org/project/comments/add/631
>
> Project:      GNU Smalltalk
> Version:      <none>
> Component:    VM
> Category:     bug reports
> Priority:     normal
> Assigned to:  MrGwen
> Reported by:  MrGwen
> Updated by:   MrGwen
> Status:       fixed
>
> I've tried with gst 3.2.4 and there is the same bug
>
>
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

Paolo Bonzini-2
On 01/28/2012 07:56 PM, Ladislav Marek wrote:
> Hi,
>
> after this change, code:
>
> 5 timesRepeat: [
>      [(Delay forSeconds: 2) value: [] onTimeoutDo: [Error signal]] fork].
> Processor activeProcess suspend.

I fixed this and will push soon:

diff --git a/kernel/Delay.st b/kernel/Delay.st
index a77da53..40298cc 100644
--- a/kernel/Delay.st
+++ b/kernel/Delay.st
@@ -143,9 +143,10 @@ created.'>
          | activeDelay |
  activeDelay := self activeDelay.
  activeDelay isNil ifTrue: [^self].
+ activeDelay == aDelay
+    ifTrue: [Queue removeLast]
+    ifFalse: [Queue identityRemove: aDelay ifAbsent: []].
  aDelay reset.
- activeDelay == aDelay ifTrue: [^Queue removeLast].
- Queue identityRemove: aDelay ifAbsent: [].
      ]

      Delay class >> startDelayLoop [

However I cannot reproduce the problem.

Paolo



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

MrGwen
On 31/01/2012 10:19, Paolo Bonzini wrote:

> On 01/28/2012 07:56 PM, Ladislav Marek wrote:
>> Hi,
>>
>> after this change, code:
>>
>> 5 timesRepeat: [
>>      [(Delay forSeconds: 2) value: [] onTimeoutDo: [Error signal]]
>> fork].
>> Processor activeProcess suspend.
>
> I fixed this and will push soon:
>
> diff --git a/kernel/Delay.st b/kernel/Delay.st
> index a77da53..40298cc 100644
> --- a/kernel/Delay.st
> +++ b/kernel/Delay.st
> @@ -143,9 +143,10 @@ created.'>
>          | activeDelay |
>      activeDelay := self activeDelay.
>      activeDelay isNil ifTrue: [^self].
> +    activeDelay == aDelay
> +        ifTrue: [Queue removeLast]
> +        ifFalse: [Queue identityRemove: aDelay ifAbsent: []].
>      aDelay reset.
> -    activeDelay == aDelay ifTrue: [^Queue removeLast].
> -    Queue identityRemove: aDelay ifAbsent: [].
>      ]
>
>      Delay class >> startDelayLoop [
>
> However I cannot reproduce the problem.
>
> Paolo
>
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-smalltalk

I've tried the change you propose before but I had this problem:

Eval [
     | d1 d2 p1 p2 |
     sem := Semaphore new.
     d1 := Delay forSeconds: 1.
     p1 := [ d1 value: [ sem signal ] onTimeoutDo: [ ] ] fork.
     sem wait.

     'value:onTimeoutDo:' displayNl.
     d1 := Delay forMilliseconds: 100.
     d1 value: [ [ true ] whileTrue ] onTimeoutDo: [ ].
]

The vm abort when it checks the process list state (if it's finished).
Maybe can you enlight me about that bug  ?

#0  0x00007ffff77963a5 in __GI_raise (sig=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff7799b0b in __GI_abort () at abort.c:92
#2  0x00007ffff7b642ec in _gst_check_process_state () at interp.c:2086
#3  0x00007ffff7b70de6 in _gst_nvmsg_send (receiver=0x7f7061d2f3e0,
sendSelector=0x7f7061d3d340, args=<optimized out>, sendArgs=1) at
interp.c:2349
#4  0x00007ffff7b47a1b in _gst_va_msg_sendf (resultPtr=0x0,
fmt=0x7ffff7b8614e "%v %o changed: %S", ap=0x7fffffffd7a8) at callin.c:305
#5  0x00007ffff7b48557 in _gst_msg_sendf (resultPtr=<optimized out>,
fmt=<optimized out>) at callin.c:380
#6  0x00007ffff7b1fb07 in invoke_hook_smalltalk (hook=<optimized out>)
at comp.c:485
#7  _gst_invoke_hook (hook=<optimized out>) at comp.c:496
#8  0x00007ffff7b231de in _gst_execute_statements
(receiverOOP=0x7f7061d2e000, method=<optimized out>,
undeclared=<optimized out>, quiet=true) at comp.c:673
#9  0x00007ffff7b1439d in execute_doit (p=0x7fffffffddd0,
temps=0x61bc50, stmts=0x61c0a0, receiverOOP=0x7f7061d2e000,
undeclared=true, quiet=false) at gst-parse.c:604
#10 0x00007ffff7b1554e in parse_eval_definition (p=0x7fffffffddd0) at
gst-parse.c:762
#11 0x00007ffff7b16bbe in parse_scoped_definition (first_stmt=0x61bbd0,
p=0x7fffffffddd0) at gst-parse.c:675
#12 parse_doit (p=0x7fffffffddd0, fail_at_eof=<optimized out>) at
gst-parse.c:636
#13 0x00007ffff7b17281 in parse_chunks (p=0x7fffffffddd0) at gst-parse.c:486
#14 0x00007ffff7b17762 in _gst_parse_chunks (currentNamespace=<optimized
out>) at gst-parse.c:461
#15 0x00007ffff7b192b2 in _gst_parse_stream (currentNamespace=0x0) at
lex.c:1208
#16 0x00007ffff7b4429e in _gst_process_file (fileName=<optimized out>,
dir=<optimized out>) at input.c:844
#17 0x0000000000401167 in main (argc=<optimized out>, argv=<optimized
out>) at main.c:401



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

Paolo Bonzini-2
On 01/31/2012 09:32 PM, Gwenaël Casaccio wrote:

>
> Eval [
>      | d1 d2 p1 p2 |
>      sem := Semaphore new.
>      d1 := Delay forSeconds: 1.
>      p1 := [ d1 value: [ sem signal ] onTimeoutDo: [ ] ] fork.
>      sem wait.
>
>      'value:onTimeoutDo:' displayNl.
>      d1 := Delay forMilliseconds: 100.
>      d1 value: [ [ true ] whileTrue ] onTimeoutDo: [ ].
> ]

Let's fix this too, then. :)

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

MrGwen
On 01/02/2012 08:26, Paolo Bonzini wrote:

> On 01/31/2012 09:32 PM, Gwenaël Casaccio wrote:
>>
>> Eval [
>>      | d1 d2 p1 p2 |
>>      sem := Semaphore new.
>>      d1 := Delay forSeconds: 1.
>>      p1 := [ d1 value: [ sem signal ] onTimeoutDo: [ ] ] fork.
>>      sem wait.
>>
>>      'value:onTimeoutDo:' displayNl.
>>      d1 := Delay forMilliseconds: 100.
>>      d1 value: [ [ true ] whileTrue ] onTimeoutDo: [ ].
>> ]
>
> Let's fix this too, then. :)
>
> Paolo
Hi Paolo,  the bug comes when the process is removed from the middle of
the list.

So here is the patch

diff --git a/libgst/interp.c b/libgst/interp.c
index fe154be..515f84a 100644
--- a/libgst/interp.c
+++ b/libgst/interp.c
@@ -305,6 +305,9 @@ static OOP highest_priority_process (void);
     LinkedList) and answer it.  */
  static OOP remove_first_link (OOP semaphoreOOP);

+/* Remove a process of the given list */
+static void remove_from_link (OOP processOOP);
+
  /* Add PROCESSOOP as the head of the given list (a Semaphore is a
     subclass of LinkedList) and answer it.  */
  static void add_first_link (OOP semaphoreOOP,
@@ -1398,8 +1401,7 @@ get_scheduled_process (void)
  }

  void
-add_first_link (OOP semaphoreOOP,
- OOP processOOP)
+remove_from_link (OOP processOOP)
  {
    gst_semaphore sem;
    gst_process process, lastProcess;
@@ -1410,28 +1412,40 @@ add_first_link (OOP semaphoreOOP,
      {
        sem = (gst_semaphore) OOP_TO_OBJ (process->myList);
        if (sem->firstLink == processOOP)
- {
-  sem->firstLink = process->nextLink;
-  if (sem->lastLink == processOOP)
-    {
-      /* It was the only process in the list */
-      sem->lastLink = _gst_nil_oop;
-    }
- }
-      else if (sem->lastLink == processOOP)
- {
-  /* Find the new last link */
-  lastProcessOOP = sem->firstLink;
-  lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
-  while (lastProcess->nextLink != processOOP)
-    {
-      lastProcessOOP = lastProcess->nextLink;
-      lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
-    }
-  sem->lastLink = lastProcessOOP;
-  lastProcess->nextLink = _gst_nil_oop;
- }
+        {
+          sem->firstLink = process->nextLink;
+          if (sem->lastLink == processOOP)
+            {
+              /* It was the only process in the list */
+              sem->lastLink = _gst_nil_oop;
+            }
+        }
+      else
+        {
+          /* Find the new middle link */
+          lastProcessOOP = sem->firstLink;
+          lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
+          while (lastProcess->nextLink != processOOP)
+            {
+              lastProcessOOP = lastProcess->nextLink;
+              lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
+            }
+          if (sem->lastLink == processOOP)
+            sem->lastLink = lastProcessOOP;
+          lastProcess->nextLink = process->nextLink;
+        }
      }
+}
+
+void
+add_first_link (OOP semaphoreOOP,
+ OOP processOOP)
+{
+  gst_semaphore sem;
+  gst_process process;
+
+  process = (gst_process) OOP_TO_OBJ (processOOP);
+  remove_from_link (processOOP);

    sem = (gst_semaphore) OOP_TO_OBJ (semaphoreOOP);
    process->myList = semaphoreOOP;
@@ -1509,36 +1523,10 @@ add_last_link (OOP semaphoreOOP,
        OOP processOOP)
  {
    gst_semaphore sem;
-  gst_process process, lastProcess;
-  OOP lastProcessOOP;
+  gst_process process;

    process = (gst_process) OOP_TO_OBJ (processOOP);
-  if (!IS_NIL (process->myList))
-    {
-      sem = (gst_semaphore) OOP_TO_OBJ (process->myList);
-      if (sem->firstLink == processOOP)
- {
-  sem->firstLink = process->nextLink;
-  if (sem->lastLink == processOOP)
-    {
-      /* It was the only process in the list */
-      sem->lastLink = _gst_nil_oop;
-    }
- }
-      else if (sem->lastLink == processOOP)
- {
-  /* Find the new last link */
-  lastProcessOOP = sem->firstLink;
-  lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
-  while (lastProcess->nextLink != processOOP)
-    {
-      lastProcessOOP = lastProcess->nextLink;
-      lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
-    }
-  sem->lastLink = lastProcessOOP;
-  lastProcess->nextLink = _gst_nil_oop;
- }
-    }
+  remove_from_link (processOOP);

    sem = (gst_semaphore) OOP_TO_OBJ (semaphoreOOP);
    process->myList = semaphoreOOP;
@@ -1548,6 +1536,9 @@ add_last_link (OOP semaphoreOOP,
      sem->firstLink = sem->lastLink = processOOP;
    else
      {
+      OOP lastProcessOOP;
+      gst_process lastProcess;
+
        lastProcessOOP = sem->lastLink;
        lastProcess = (gst_process) OOP_TO_OBJ (lastProcessOOP);
        lastProcess->nextLink = processOOP;
@@ -2082,8 +2073,10 @@ _gst_check_process_state (void)
     abort ();

   /* Check (rather brutally) for loops in the process lists.  */
-  if (++n>  _gst_mem.ot_size)
+  if (++n>  _gst_mem.ot_size) {
+    fprintf (stderr, "%d\n\n", priority);
     abort ();
+    }
  }
      }
  }




_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Delay issue

Paolo Bonzini-2
On 02/02/2012 09:46 AM, Gwenaël Casaccio wrote:
>>
> Hi Paolo,  the bug comes when the process is removed from the middle of
> the list.

Thanks Gwen!

There is already remove_process_from_list, I am committing a similar
patch that uses it.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk