12186 image quit problem

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

Re: 12186 image quit problem

Pavel Krivanek-3


On Fri, Oct 8, 2010 at 7:40 PM, Igor Stasenko <[hidden email]> wrote:
2010/10/8 Pavel Krivanek <[hidden email]>:
>
>
> On Fri, Oct 8, 2010 at 7:15 PM, Pavel Krivanek <[hidden email]>
> wrote:
>>
>>
>> On Fri, Oct 8, 2010 at 5:06 PM, Igor Stasenko <[hidden email]> wrote:
>>>
>>> 2010/10/8 Pavel Krivanek <[hidden email]>:
>>> > Hi Marcus,
>>> > is that really all what happened between 12172 and 12186?
>>> >
>>> > update12186
>>> > Issue 3071: fixing timestamp tests
>>> > Issue 3068: Non portable SmalltalkImage>>platformName
>>> > deprecationWarning
>>> > Issue 3063: removing explain
>>> > Issue 3039: There should not be any configuration on Core
>>> > It doesn't explain the problems with VM versions and in 12186 I cannot
>>> > build
>>> > the PharoKernel (it hangs without error in unload phase)
>>> > -- Pavel
>>> >
>>> please , tell me if it keep hanging after you doing:
>>>
>>> WeakArray restartFinalizationProcess.
>>>
>>> it seems like a deadlock with WeakArray's FinalizationLock or
>>> FinalizationSemaphore.
>>
>> it hangs for me...
>> -- Pavel
>
> with the MCMethodDefinition>>shutdown hack it work well

so, at least we know what causing it.

Now i wonder, what may cause that
  WeakArray classPool at: #FinalizationLock
get locked by some other process and not released anymore?


if I replace critical:ifError: by critical:ifLocked: in WeakArray >> removeWeakDependent:, it shows that it is really locked. I can reproduce it everytime. Any idea how can I determine who locked it?

-- Pavel


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Pavel Krivanek-3

On Sun, Oct 10, 2010 at 10:09 AM, Pavel Krivanek <[hidden email]> wrote:


On Fri, Oct 8, 2010 at 7:40 PM, Igor Stasenko <[hidden email]> wrote:
2010/10/8 Pavel Krivanek <[hidden email]>:
>
>
> On Fri, Oct 8, 2010 at 7:15 PM, Pavel Krivanek <[hidden email]>
> wrote:
>>
>>
>> On Fri, Oct 8, 2010 at 5:06 PM, Igor Stasenko <[hidden email]> wrote:
>>>
>>> 2010/10/8 Pavel Krivanek <[hidden email]>:
>>> > Hi Marcus,
>>> > is that really all what happened between 12172 and 12186?
>>> >
>>> > update12186
>>> > Issue 3071: fixing timestamp tests
>>> > Issue 3068: Non portable SmalltalkImage>>platformName
>>> > deprecationWarning
>>> > Issue 3063: removing explain
>>> > Issue 3039: There should not be any configuration on Core
>>> > It doesn't explain the problems with VM versions and in 12186 I cannot
>>> > build
>>> > the PharoKernel (it hangs without error in unload phase)
>>> > -- Pavel
>>> >
>>> please , tell me if it keep hanging after you doing:
>>>
>>> WeakArray restartFinalizationProcess.
>>>
>>> it seems like a deadlock with WeakArray's FinalizationLock or
>>> FinalizationSemaphore.
>>
>> it hangs for me...
>> -- Pavel
>
> with the MCMethodDefinition>>shutdown hack it work well

so, at least we know what causing it.

Now i wonder, what may cause that
  WeakArray classPool at: #FinalizationLock
get locked by some other process and not released anymore?


if I replace critical:ifError: by critical:ifLocked: in WeakArray >> removeWeakDependent:, it shows that it is really locked. I can reproduce it everytime. Any idea how can I determine who locked it?

-- Pavel

It collides with HostSystemMenusProxy class >> unregister 

this is the call stack:

[caught := true.
self wait.
blockValue := mutuallyExcludedBlock value] in Semaphore>>critical:

BlockClosure>>ensure:

Semaphore>>critical:

Semaphore>>critical:ifError:

WeakRegistry>>protected:

WeakRegistry>>remove:ifAbsent:

HostSystemMenusProxy class>>unregister:

HostSystemMenusProxy>>unregister

HostSystemMenusProxy>>destroyEveryThing

[self destroyEveryThing] in HostSystemMenusProxy>>finalize

BlockClosure>>on:do:

BlockClosure>>ifError:

HostSystemMenusProxy>>finalize

WeakFinalizerItem>>finalizeValues

[:finItem | finItem finalizeValues] in [valueDictionary
expiredValuesDo: [:finItem | finItem finalizeValues]] in WeakRegistry>>finalizeValues

WeakIdentityKeyDictionary(WeakKeyDictionary)>>expiredValuesDo:

[valueDictionary
expiredValuesDo: [:finItem | finItem finalizeValues]] in WeakRegistry>>finalizeValues

[mutuallyExcludedBlock value] in [blockValue := [mutuallyExcludedBlock value]
ifError: [:msg :rcvr | 
hasError := true.
errMsg := msg.
errRcvr := rcvr]] in Semaphore>>critical:ifError:

BlockClosure>>on:do:

BlockClosure>>ifError:

[blockValue := [mutuallyExcludedBlock value]
ifError: [:msg :rcvr | 
hasError := true.
errMsg := msg.
errRcvr := rcvr]] in Semaphore>>critical:ifError:

[caught := true.
self wait.
blockValue := mutuallyExcludedBlock value] in Semaphore>>critical:

BlockClosure>>ensure:

Semaphore>>critical:

Semaphore>>critical:ifError:

WeakRegistry>>protected:

WeakRegistry>>finalizeValues

[:weakDependent | weakDependent
ifNotNil: [weakDependent finalizeValues]] in [WeakFinalizationList checkTestPair.
FinalizationDependents
do: [:weakDependent | weakDependent
ifNotNil: [weakDependent finalizeValues]]] in WeakArray class>>finalizationProcess

WeakArray(SequenceableCollection)>>do:

[WeakFinalizationList checkTestPair.
FinalizationDependents
do: [:weakDependent | weakDependent
ifNotNil: [weakDependent finalizeValues]]] in WeakArray class>>finalizationProcess

[mutuallyExcludedBlock value] in [blockValue := [mutuallyExcludedBlock value]
ifError: [:msg :rcvr | 
hasError := true.
errMsg := msg.
errRcvr := rcvr]] in Semaphore>>critical:ifError:

BlockClosure>>on:do:

BlockClosure>>ifError:

[blockValue := [mutuallyExcludedBlock value]
ifError: [:msg :rcvr | 
hasError := true.
errMsg := msg.
errRcvr := rcvr]] in Semaphore>>critical:ifError:

[caught := true.
self wait.
blockValue := mutuallyExcludedBlock value] in Semaphore>>critical:

BlockClosure>>ensure:

Semaphore>>critical:

Semaphore>>critical:ifError:

WeakArray class>>finalizationProcess

[self finalizationProcess] in WeakArray class>>restartFinalizationProcess

[self value.
Processor terminateActive] in BlockClosure>>newProcess


-- Pavel


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Igor Stasenko
OKay, now i see what the problem:

<weak registry protected>
   <finalize items>
       <HostSystemMenusProxy>>finalize>
            ....
            <HostSystemMenusProxy class>>unregister>
              <weak registry protected>


In my WeakRegistry, a #finalize message sent while registry semaphore locked,
so, in case if object in #finalize trying to manipulate with registry
then it going to deadlock.

Then following piece:

WeakRegistry>>finalizeValues

self protected: [
        valueDictionary expiredValuesDo: [:finItem |
                finItem finalizeValues ].
  ].

should be rewritten as:

| expired |
expired := OrderedCollection new.
self protected: [
        valueDictionary expiredValuesDo: [:finItem | expired add: finItem ]
  ].
expired do: #finalizeValues.


But either way, HostSystemMenusProxy should not attempt remove itself
from registry during #finalize (and causing a deadlock),
since its pointless.


--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Schwab,Wilhelm K
Sig,

Have you thought about using a Mutex?  Maybe I'm missing something in life, but long ago I decided the #forMutualExclusion is *beyond* private.  Semaphores are wonderful for #wait/#signal.  But for #critical:, I use Mutex which won't deadlock a thread with itself.

Bill


________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Igor Stasenko [[hidden email]]
Sent: Sunday, October 10, 2010 7:56 AM
To: [hidden email]
Subject: Re: [Pharo-project] 12186 image quit problem

OKay, now i see what the problem:

<weak registry protected>
   <finalize items>
       <HostSystemMenusProxy>>finalize>
            ....
            <HostSystemMenusProxy class>>unregister>
              <weak registry protected>


In my WeakRegistry, a #finalize message sent while registry semaphore locked,
so, in case if object in #finalize trying to manipulate with registry
then it going to deadlock.

Then following piece:

WeakRegistry>>finalizeValues

self protected: [
        valueDictionary expiredValuesDo: [:finItem |
                finItem finalizeValues  ].
  ].

should be rewritten as:

| expired |
expired := OrderedCollection new.
self protected: [
        valueDictionary expiredValuesDo: [:finItem | expired add: finItem ]
  ].
expired do: #finalizeValues.


But either way, HostSystemMenusProxy should not attempt remove itself
from registry during #finalize (and causing a deadlock),
since its pointless.


--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Igor Stasenko
On 10 October 2010 17:40, Schwab,Wilhelm K <[hidden email]> wrote:
> Sig,
>
> Have you thought about using a Mutex?  Maybe I'm missing something in life, but long ago I decided the #forMutualExclusion is *beyond* private.  Semaphores are wonderful for #wait/#signal.  But for #critical:, I use Mutex which won't deadlock a thread with itself.
>

yes,  i thought about it. It wont help in this situation,
because if you start modifying dictionary inside a loop, which
scanning its elements (like #do:)
you'll have very unpleasant results.

All HostSystemMenusProxy doing during #finalize is removing itself
from weakregistry (which is complete nonsense, since weak registry
cleaning itself from dead stuff anyways).
So,
 self protected: [
        valueDictionary expiredValuesDo: [:finItem |
                finItem finalizeValues  ].
  ].

actually triggers a bug/mistake in HostSystemMenusProxy , which leads
to deadlock.
:)

> Bill
>
>
> ________________________________________
> From: [hidden email] [[hidden email]] On Behalf Of Igor Stasenko [[hidden email]]
> Sent: Sunday, October 10, 2010 7:56 AM
> To: [hidden email]
> Subject: Re: [Pharo-project] 12186 image quit problem
>
> OKay, now i see what the problem:
>
> <weak registry protected>
>   <finalize items>
>       <HostSystemMenusProxy>>finalize>
>            ....
>            <HostSystemMenusProxy class>>unregister>
>              <weak registry protected>
>
>
> In my WeakRegistry, a #finalize message sent while registry semaphore locked,
> so, in case if object in #finalize trying to manipulate with registry
> then it going to deadlock.
>
> Then following piece:
>
> WeakRegistry>>finalizeValues
>
> self protected: [
>        valueDictionary expiredValuesDo: [:finItem |
>                finItem finalizeValues  ].
>  ].
>
> should be rewritten as:
>
> | expired |
> expired := OrderedCollection new.
> self protected: [
>        valueDictionary expiredValuesDo: [:finItem | expired add: finItem ]
>  ].
> expired do: #finalizeValues.
>
>
> But either way, HostSystemMenusProxy should not attempt remove itself
> from registry during #finalize (and causing a deadlock),
> since its pointless.
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Pavel Krivanek-3
Ok, I opened an issue: http://code.google.com/p/pharo/issues/detail?id=3091

The patch works for me, Thank you Igor.

Cheers,
-- Pavel

On Sun, Oct 10, 2010 at 6:46 PM, Igor Stasenko <[hidden email]> wrote:
On 10 October 2010 17:40, Schwab,Wilhelm K <[hidden email]> wrote:
> Sig,
>
> Have you thought about using a Mutex?  Maybe I'm missing something in life, but long ago I decided the #forMutualExclusion is *beyond* private.  Semaphores are wonderful for #wait/#signal.  But for #critical:, I use Mutex which won't deadlock a thread with itself.
>

yes,  i thought about it. It wont help in this situation,
because if you start modifying dictionary inside a loop, which
scanning its elements (like #do:)
you'll have very unpleasant results.

All HostSystemMenusProxy doing during #finalize is removing itself
from weakregistry (which is complete nonsense, since weak registry
cleaning itself from dead stuff anyways).
So,
 self protected: [
       valueDictionary expiredValuesDo: [:finItem |
               finItem finalizeValues  ].
 ].

actually triggers a bug/mistake in HostSystemMenusProxy , which leads
to deadlock.
:)

> Bill
>
>
> ________________________________________
> From: [hidden email] [[hidden email]] On Behalf Of Igor Stasenko [[hidden email]]
> Sent: Sunday, October 10, 2010 7:56 AM
> To: [hidden email]
> Subject: Re: [Pharo-project] 12186 image quit problem
>
> OKay, now i see what the problem:
>
> <weak registry protected>
>   <finalize items>
>       <HostSystemMenusProxy>>finalize>
>            ....
>            <HostSystemMenusProxy class>>unregister>
>              <weak registry protected>
>
>
> In my WeakRegistry, a #finalize message sent while registry semaphore locked,
> so, in case if object in #finalize trying to manipulate with registry
> then it going to deadlock.
>
> Then following piece:
>
> WeakRegistry>>finalizeValues
>
> self protected: [
>        valueDictionary expiredValuesDo: [:finItem |
>                finItem finalizeValues  ].
>  ].
>
> should be rewritten as:
>
> | expired |
> expired := OrderedCollection new.
> self protected: [
>        valueDictionary expiredValuesDo: [:finItem | expired add: finItem ]
>  ].
> expired do: #finalizeValues.
>
>
> But either way, HostSystemMenusProxy should not attempt remove itself
> from registry during #finalize (and causing a deadlock),
> since its pointless.
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Stéphane Ducasse
In reply to this post by Igor Stasenko
I integrate
        Issue 3086: MCMethodDefinition>>shutdown hack to avoid lock down.
        http://code.google.com/p/pharo/issues/detail?id=3086

       

Igor can you have a look and let me know:
        1- if we should rollback Issue 3086: MCMethodDefinition>>shutdown hack to avoid lock down.
        2- if we should integrate
                Issue 3048: MC method cache fix
                http://code.google.com/p/pharo/issues/detail?id=3048

I will integrate
        http://code.google.com/p/pharo/issues/detail?id=3091

Stef



> Ok, I opened an issue: http://code.google.com/p/pharo/issues/detail?id=3091
>
> The patch works for me, Thank you Igor.
>
> Cheers,
> -- Pavel
>
> On Sun, Oct 10, 2010 at 6:46 PM, Igor Stasenko <[hidden email]> wrote:
> On 10 October 2010 17:40, Schwab,Wilhelm K <[hidden email]> wrote:
> > Sig,
> >
> > Have you thought about using a Mutex?  Maybe I'm missing something in life, but long ago I decided the #forMutualExclusion is *beyond* private.  Semaphores are wonderful for #wait/#signal.  But for #critical:, I use Mutex which won't deadlock a thread with itself.
> >
>
> yes,  i thought about it. It wont help in this situation,
> because if you start modifying dictionary inside a loop, which
> scanning its elements (like #do:)
> you'll have very unpleasant results.
>
> All HostSystemMenusProxy doing during #finalize is removing itself
> from weakregistry (which is complete nonsense, since weak registry
> cleaning itself from dead stuff anyways).
> So,
>  self protected: [
>        valueDictionary expiredValuesDo: [:finItem |
>                finItem finalizeValues  ].
>  ].
>
> actually triggers a bug/mistake in HostSystemMenusProxy , which leads
> to deadlock.
> :)
>
> > Bill
> >
> >
> > ________________________________________
> > From: [hidden email] [[hidden email]] On Behalf Of Igor Stasenko [[hidden email]]
> > Sent: Sunday, October 10, 2010 7:56 AM
> > To: [hidden email]
> > Subject: Re: [Pharo-project] 12186 image quit problem
> >
> > OKay, now i see what the problem:
> >
> > <weak registry protected>
> >   <finalize items>
> >       <HostSystemMenusProxy>>finalize>
> >            ....
> >            <HostSystemMenusProxy class>>unregister>
> >              <weak registry protected>
> >
> >
> > In my WeakRegistry, a #finalize message sent while registry semaphore locked,
> > so, in case if object in #finalize trying to manipulate with registry
> > then it going to deadlock.
> >
> > Then following piece:
> >
> > WeakRegistry>>finalizeValues
> >
> > self protected: [
> >        valueDictionary expiredValuesDo: [:finItem |
> >                finItem finalizeValues  ].
> >  ].
> >
> > should be rewritten as:
> >
> > | expired |
> > expired := OrderedCollection new.
> > self protected: [
> >        valueDictionary expiredValuesDo: [:finItem | expired add: finItem ]
> >  ].
> > expired do: #finalizeValues.
> >
> >
> > But either way, HostSystemMenusProxy should not attempt remove itself
> > from registry during #finalize (and causing a deadlock),
> > since its pointless.
> >
> >
> > --
> > Best regards,
> > Igor Stasenko AKA sig.
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Igor Stasenko
On 11 October 2010 12:10, Stéphane Ducasse <[hidden email]> wrote:

> I integrate
>        Issue 3086:     MCMethodDefinition>>shutdown hack to avoid lock down.
>        http://code.google.com/p/pharo/issues/detail?id=3086
>
>
>
> Igor can you have a look and let me know:
>        1- if we should rollback Issue 3086:    MCMethodDefinition>>shutdown hack to avoid lock down.
>        2- if we should integrate
>                Issue 3048:     MC method cache fix
>                http://code.google.com/p/pharo/issues/detail?id=3048
>
> I will integrate
>        http://code.google.com/p/pharo/issues/detail?id=3091
>
Wait , MCMethodDefinition is only a consequence (however, removing it
from weakdependents would be good idea as well ;)).

The real cultprit is HostSystemMenusProxy , which locks the weak
registry during finalization.
Then MCMethodDefinition>>shutdown simply locks at same point (trying
to obtain semaphore lock).
Note, that HostSystemMenusProxy locks finalization process, but not
the process which doing shutdown,
and then during image startup, a new finalization process get created.
That's why removing access to weakdependents in
MCMethodDefinition>>shutdown , kinda solved the issue.
In reality its not.
An old weak registry were sending #finalize outside a critical section:

finalizeValues
        "Some of our elements may have gone away. Look for those and activate
the associated executors."
        | finiObjects |
        finiObjects := nil.
        "First collect the objects."
        self protected:[
                valueDictionary allAssociationsDo:[:assoc|
                        assoc key isNil ifTrue:[
                                finiObjects isNil
                                        ifTrue:[finiObjects := OrderedCollection with: assoc value]
                                        ifFalse:[finiObjects add: assoc value]]
                ].
                finiObjects isNil ifFalse:[valueDictionary finalizeValues:
finiObjects asArray].
        ].
        "Then do the finalization"
        finiObjects isNil ifTrue:[^self].
        finiObjects do:[:each| each finalize].


So, there two ways to solve it:
a) perform finalization outside a critical section (see attached)
b) fix the HostSystemMenusProxy to prevent any manupulation with weak
registry during finalization.


I checked Squeak 4.2 image, and i can also say, that any attempt to
manipulate weak registry during finalization will also lock down a
finalization process (see Squeak's WeakRegistry>>finalizeValues &
WeakKeyDictionary>>finalizeValues)

So, if we going to assume, in future that it is error to modify weak
registry during finalization, then we should leave the code in
WeakRegistry as-is, and fix HostSystemMenusProxy instead.
If not, the we should make sure that #finalize should be sent outside
weak registry's critical section.

And the last note: if VM supports new finalization, it will happen
outside a critical section (See the
bottom of WeakRegistry>>finalizeValues). So any manipulations with
registry during finalization can't cause lockdown.


P.S. forwarded to Squeak-dev, to make Squeakers aware of potential
danger , when manipulating weak registry during finalization.

--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

WeakRegistry-finalizeValues.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: 12186 image quit problem

Stéphane Ducasse
In reply to this post by Stéphane Ducasse
Thanks.
So let's see what is the best choice and tell us.


On Oct 11, 2010, at 11:47 AM, Igor Stasenko wrote:

> On 11 October 2010 12:10, Stéphane Ducasse <[hidden email]> wrote:
>> I integrate
>>        Issue 3086:     MCMethodDefinition>>shutdown hack to avoid lock down.
>>        http://code.google.com/p/pharo/issues/detail?id=3086
>>
>>
>>
>> Igor can you have a look and let me know:
>>        1- if we should rollback Issue 3086:    MCMethodDefinition>>shutdown hack to avoid lock down.
>>        2- if we should integrate
>>                Issue 3048:     MC method cache fix
>>                http://code.google.com/p/pharo/issues/detail?id=3048
>>
>> I will integrate
>>        http://code.google.com/p/pharo/issues/detail?id=3091
>>
>
> Wait , MCMethodDefinition is only a consequence (however, removing it
> from weakdependents would be good idea as well ;)).

Yes I integrate it to avoid system hanging.


> The real cultprit is HostSystemMenusProxy , which locks the weak
> registry during finalization.
> Then MCMethodDefinition>>shutdown simply locks at same point (trying
> to obtain semaphore lock).
> Note, that HostSystemMenusProxy locks finalization process, but not
> the process which doing shutdown,
> and then during image startup, a new finalization process get created.
> That's why removing access to weakdependents in
> MCMethodDefinition>>shutdown , kinda solved the issue.
> In reality its not.
> An old weak registry were sending #finalize outside a critical section:
>
> finalizeValues
> "Some of our elements may have gone away. Look for those and activate
> the associated executors."
> | finiObjects |
> finiObjects := nil.
> "First collect the objects."
> self protected:[
> valueDictionary allAssociationsDo:[:assoc|
> assoc key isNil ifTrue:[
> finiObjects isNil
> ifTrue:[finiObjects := OrderedCollection with: assoc value]
> ifFalse:[finiObjects add: assoc value]]
> ].
> finiObjects isNil ifFalse:[valueDictionary finalizeValues:
> finiObjects asArray].
> ].
> "Then do the finalization"
> finiObjects isNil ifTrue:[^self].
> finiObjects do:[:each| each finalize].
>
>
> So, there two ways to solve it:
> a) perform finalization outside a critical section (see attached)
> b) fix the HostSystemMenusProxy to prevent any manupulation with weak
> registry during finalization.
>
>
> I checked Squeak 4.2 image, and i can also say, that any attempt to
> manipulate weak registry during finalization will also lock down a
> finalization process (see Squeak's WeakRegistry>>finalizeValues &
> WeakKeyDictionary>>finalizeValues)
>
> So, if we going to assume, in future that it is error to modify weak
> registry during finalization, then we should leave the code in
> WeakRegistry as-is, and fix HostSystemMenusProxy instead.
> If not, the we should make sure that #finalize should be sent outside
> weak registry's critical section.
>
> And the last note: if VM supports new finalization, it will happen
> outside a critical section (See the
> bottom of WeakRegistry>>finalizeValues). So any manipulations with
> registry during finalization can't cause lockdown.
>
>
> P.S. forwarded to Squeak-dev, to make Squeakers aware of potential
> danger , when manipulating weak registry during finalization.
>
> --
> Best regards,
> Igor Stasenko AKA sig.
> <WeakRegistry-finalizeValues.st>_______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: 12186 image quit problem

Igor Stasenko
- i added a test to cover this issue
http://code.google.com/p/pharo/issues/detail?id=3092

On 11 October 2010 14:01, Stéphane Ducasse <[hidden email]> wrote:

> Thanks.
> So let's see what is the best choice and tell us.
>
>
> On Oct 11, 2010, at 11:47 AM, Igor Stasenko wrote:
>
>> On 11 October 2010 12:10, Stéphane Ducasse <[hidden email]> wrote:
>>> I integrate
>>>        Issue 3086:     MCMethodDefinition>>shutdown hack to avoid lock down.
>>>        http://code.google.com/p/pharo/issues/detail?id=3086
>>>
>>>
>>>
>>> Igor can you have a look and let me know:
>>>        1- if we should rollback Issue 3086:    MCMethodDefinition>>shutdown hack to avoid lock down.
>>>        2- if we should integrate
>>>                Issue 3048:     MC method cache fix
>>>                http://code.google.com/p/pharo/issues/detail?id=3048
>>>
>>> I will integrate
>>>        http://code.google.com/p/pharo/issues/detail?id=3091
>>>
>>
>> Wait , MCMethodDefinition is only a consequence (however, removing it
>> from weakdependents would be good idea as well ;)).
>
> Yes I integrate it to avoid system hanging.
>
>
>> The real cultprit is HostSystemMenusProxy , which locks the weak
>> registry during finalization.
>> Then MCMethodDefinition>>shutdown simply locks at same point (trying
>> to obtain semaphore lock).
>> Note, that HostSystemMenusProxy locks finalization process, but not
>> the process which doing shutdown,
>> and then during image startup, a new finalization process get created.
>> That's why removing access to weakdependents in
>> MCMethodDefinition>>shutdown , kinda solved the issue.
>> In reality its not.
>> An old weak registry were sending #finalize outside a critical section:
>>
>> finalizeValues
>>       "Some of our elements may have gone away. Look for those and activate
>> the associated executors."
>>       | finiObjects |
>>       finiObjects := nil.
>>       "First collect the objects."
>>       self protected:[
>>               valueDictionary allAssociationsDo:[:assoc|
>>                       assoc key isNil ifTrue:[
>>                               finiObjects isNil
>>                                       ifTrue:[finiObjects := OrderedCollection with: assoc value]
>>                                       ifFalse:[finiObjects add: assoc value]]
>>               ].
>>               finiObjects isNil ifFalse:[valueDictionary finalizeValues:
>> finiObjects asArray].
>>       ].
>>       "Then do the finalization"
>>       finiObjects isNil ifTrue:[^self].
>>       finiObjects do:[:each| each finalize].
>>
>>
>> So, there two ways to solve it:
>> a) perform finalization outside a critical section (see attached)
>> b) fix the HostSystemMenusProxy to prevent any manupulation with weak
>> registry during finalization.
>>
>>
>> I checked Squeak 4.2 image, and i can also say, that any attempt to
>> manipulate weak registry during finalization will also lock down a
>> finalization process (see Squeak's WeakRegistry>>finalizeValues &
>> WeakKeyDictionary>>finalizeValues)
>>
>> So, if we going to assume, in future that it is error to modify weak
>> registry during finalization, then we should leave the code in
>> WeakRegistry as-is, and fix HostSystemMenusProxy instead.
>> If not, the we should make sure that #finalize should be sent outside
>> weak registry's critical section.
>>
>> And the last note: if VM supports new finalization, it will happen
>> outside a critical section (See the
>> bottom of WeakRegistry>>finalizeValues). So any manipulations with
>> registry during finalization can't cause lockdown.
>>
>>
>> P.S. forwarded to Squeak-dev, to make Squeakers aware of potential
>> danger , when manipulating weak registry during finalization.
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>> <WeakRegistry-finalizeValues.st>_______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
123