Re: [twsocket] EnterCriticalSection(SslCritSect) called afterFinalization calls DeleteCriticalSection(SslCritSect)

2013-05-11 Thread Arno Garrels
John Reid wrote:
> I should have included that the app was written as a form app but we
> recently modified it to not display the form removing the
> Application.Run call in the DPR and executing a method instead:
> 
>  Application.CreateForm(TForm1, Form1);
>  Form1.RunApplication; //Application.Run;
[..]
> Thinking about it, this is likely the cause.

Indeed, most likely.

> What does
> Application.Run do, 

It is main thread's message loop.

> specifically cleaning up, that could be missing?

When main thread's message loop quits the application
terminates.  

> (Maybe this is a question for another forum).

I think so.

-- 
Arno 

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] EnterCriticalSection(SslCritSect) called after Finalization calls DeleteCriticalSection(SslCritSect)

2013-05-11 Thread John Reid
Thanks for the quick reply. That is what would be my next step. I don't
like it because this component set seems to be working fine and it is
likely something I've done that broke it.


On Sat, May 11, 2013 at 8:05 AM, Olivier Sannier  wrote:

> Hello,
>
> I've seen this happen with other component sets because the components as
> well.
> The situation triggering this is yet unclear to me, but it is a
> combination of putting the component on a form and letting the application
> delete it.
> It appears, but I'm not quite sure, that finalization of the main form is
> done AFTER all units are finalized while it used to be the other way round.
> To circumvent this, I set the global variable to nil and test for it in
> the appropriate location.
> So basically, to be on the safe side, ICS should set SslCritSect to 0 when
> finalizing and test for this value in UnloadSSL.
>
> On 11/05/2013 15:42, John Reid wrote:
>
>> We are using the ICS in an application that emails various entities (not
>> spam). Recently, we ran into an issue where the application would not shut
>> down properly. On some systems it simply persists and on others it reports
>> that an error occurred and it needs to close. This is after it has
>> completed all of its functions. I traced into it and found the
>> Finalization
>> section of OverbyteICSWSocket was executing before the
>> TComponent.DestroyComponent. The Finalization section calls
>> DeleteCriticalSection(**SslCritSect). TComponent.DestroyComponent calls
>> the
>> destructor of all its components. Those destructors ultimately call
>> UnloadSsl and this method uses EnterCriticalSection(**SslCritSect) and
>> LeaveCriticalSection(**SslCritSect), which causes an access violation and
>> prevents the app from closing.
>> This problem has only been seen recently; prior versions of this app with
>> this version of the ICS, the exact same components with the exact same
>> properties, and only slight modification to the code do not hang like
>> this.
>> First, is executing the Finalization before calling the component's
>> destructor the *normal* order? Is there some way to control this order?
>> Second, has anyone else seen this issue? Is there any way to *fix* this
>> short of removing the use of the SslCritSect in UnloadSsl?
>> Thanks in advance for any help.
>>
>>
>
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto 
> http://lists.elists.org/cgi-**bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>



-- 

*John Reid*

*Software Development Manager*
6415 South 3000 East
Suite 150
Salt Lake City, UT  84121
Phone: 801.305.3995
Fax: 801.521.6222

*www.piracle.com*
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] EnterCriticalSection(SslCritSect) called afterFinalization calls DeleteCriticalSection(SslCritSect)

2013-05-11 Thread John Reid
Thanks for the quick reply. There are no explicit threads in the
application.
I should have included that the app was written as a form app but we
recently modified it to not display the form removing the Application.Run
call in the DPR and executing a method instead:

  Application.CreateForm(TForm1, Form1);
  Form1.RunApplication; //Application.Run;

The Form1.RunApplication method was factored from the Form1.FormShow method
(without the UI specific code).

Thinking about it, this is likely the cause. What does Application.Run do,
specifically cleaning up, that could be missing? (Maybe this is a question
for another forum).


On Sat, May 11, 2013 at 7:55 AM, Arno Garrels  wrote:

> John Reid wrote:
> > The Finalization
> > section calls DeleteCriticalSection(SslCritSect).
> > TComponent.DestroyComponent calls the destructor of all its
> > components. Those destructors ultimately call UnloadSsl and this
> > method uses EnterCriticalSection(SslCritSect) and
> > LeaveCriticalSection(SslCritSect), which causes an access violation
> > and prevents the app from closing.
>
> Do you use multiple threads with ICS?
> If so, make sure all threads are closed before the application
> exits.
>
> --
> Arno
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>



-- 

*John Reid*

*Software Development Manager*
6415 South 3000 East
Suite 150
Salt Lake City, UT  84121
Phone: 801.305.3995
Fax: 801.521.6222

*www.piracle.com*
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] EnterCriticalSection(SslCritSect) called after Finalization calls DeleteCriticalSection(SslCritSect)

2013-05-11 Thread Olivier Sannier

Hello,

I've seen this happen with other component sets because the components 
as well.
The situation triggering this is yet unclear to me, but it is a 
combination of putting the component on a form and letting the 
application delete it.
It appears, but I'm not quite sure, that finalization of the main form 
is done AFTER all units are finalized while it used to be the other way 
round.
To circumvent this, I set the global variable to nil and test for it in 
the appropriate location.
So basically, to be on the safe side, ICS should set SslCritSect to 0 
when finalizing and test for this value in UnloadSSL.


On 11/05/2013 15:42, John Reid wrote:

We are using the ICS in an application that emails various entities (not
spam). Recently, we ran into an issue where the application would not shut
down properly. On some systems it simply persists and on others it reports
that an error occurred and it needs to close. This is after it has
completed all of its functions. I traced into it and found the Finalization
section of OverbyteICSWSocket was executing before the
TComponent.DestroyComponent. The Finalization section calls
DeleteCriticalSection(SslCritSect). TComponent.DestroyComponent calls the
destructor of all its components. Those destructors ultimately call
UnloadSsl and this method uses EnterCriticalSection(SslCritSect) and
LeaveCriticalSection(SslCritSect), which causes an access violation and
prevents the app from closing.
This problem has only been seen recently; prior versions of this app with
this version of the ICS, the exact same components with the exact same
properties, and only slight modification to the code do not hang like this.
First, is executing the Finalization before calling the component's
destructor the *normal* order? Is there some way to control this order?
Second, has anyone else seen this issue? Is there any way to *fix* this
short of removing the use of the SslCritSect in UnloadSsl?
Thanks in advance for any help.




--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] EnterCriticalSection(SslCritSect) called afterFinalization calls DeleteCriticalSection(SslCritSect)

2013-05-11 Thread Arno Garrels
John Reid wrote:
> The Finalization
> section calls DeleteCriticalSection(SslCritSect).
> TComponent.DestroyComponent calls the destructor of all its
> components. Those destructors ultimately call UnloadSsl and this
> method uses EnterCriticalSection(SslCritSect) and
> LeaveCriticalSection(SslCritSect), which causes an access violation
> and prevents the app from closing. 

Do you use multiple threads with ICS?
If so, make sure all threads are closed before the application
exits.

-- 
Arno 
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] EnterCriticalSection(SslCritSect) called after Finalization calls DeleteCriticalSection(SslCritSect)

2013-05-11 Thread John Reid
We are using the ICS in an application that emails various entities (not
spam). Recently, we ran into an issue where the application would not shut
down properly. On some systems it simply persists and on others it reports
that an error occurred and it needs to close. This is after it has
completed all of its functions. I traced into it and found the Finalization
section of OverbyteICSWSocket was executing before the
TComponent.DestroyComponent. The Finalization section calls
DeleteCriticalSection(SslCritSect). TComponent.DestroyComponent calls the
destructor of all its components. Those destructors ultimately call
UnloadSsl and this method uses EnterCriticalSection(SslCritSect) and
LeaveCriticalSection(SslCritSect), which causes an access violation and
prevents the app from closing.
This problem has only been seen recently; prior versions of this app with
this version of the ICS, the exact same components with the exact same
properties, and only slight modification to the code do not hang like this.
First, is executing the Finalization before calling the component's
destructor the *normal* order? Is there some way to control this order?
Second, has anyone else seen this issue? Is there any way to *fix* this
short of removing the use of the SslCritSect in UnloadSsl?
Thanks in advance for any help.

-- 

*John Reid*

*Software Development Manager*
6415 South 3000 East
Suite 150
Salt Lake City, UT  84121
Phone: 801.305.3995
Fax: 801.521.6222

*www.piracle.com*
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be