Re: [twsocket] How to get the call stack programmatically?

2007-04-30 Thread Dave Baxter
MadExcept does similar things.

http://www.madshi.net/madExceptDescription.htm

Very useful, to users of Delphi 4-7 that is, not other versions, or C
etc.

Dave B.

This mail has been scanned by Palmer Cook Computer Services Limited.  
www.palmercook.co.uk
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-30 Thread Markus Humm
Hello,

MadExcept does work also with Delphi 2005 and 2006 (and I suppose 2007).

Greetings

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-29 Thread Fastream Technologies
Hello,

So this is my latest code:

void inline __fastcall lockCriticalSection(TCriticalSection *criticalSection)
{
for(int i = 0; i  5000; ++i)
{
if(criticalSection-TryEnter())
return;

::Sleep(1);
}

throw Exception(BUG FOUND, CHECK CALL STACK!);

//criticalSection-Acquire();
};

Is it OK?

Regards,

SZ

On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
  For example, perhaps we can implement a single global mutex for the
  lock... function.

 No good idea. That would change a lot.

  This would slow down the execution for sure but
  would it create the exception?

 You have to raise the exception if the wait returns WAIT_TIMEOUT.

  Can you provide some source code
  snippet for this please?

 Please search the internet there should be tons of snippets
 around, or ask your question in newsgroup:
 borland.public.delphi.nativeapi.win32.

 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html

 
  Best Regards,
 
  SZ
 
  On 4/28/07, Fastream Technologies [EMAIL PROTECTED] wrote:
  Arno,
 
  I have THOUSANDS of critical sections passed to this function as
  parameter! Isn't there a simpler way to implement??
 
  Regards,
 
  SZ
 
  On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
  Fastream Technologies wrote:
  This sounds reasonable. Can you give an example? Since all my cs
  are of TCriticalSection type, can I do it in this function:
 
  I thought of using mutexes. That's not very difficult to change.
  Have an array of mutex handles, then pass the index to your
  function. Search for CreateMutex etc. in the SDK. When the wait
  returned WAIT_TIMEOUT and you raise an exception MadExcept will
  report the callstacks of each thread.
  I don't have any idea how one can raise an exception in a thread
  or get to thread's callstack when it hangs around in
  CriticalSection-Acquire.
 
  --
  Arno Garrels [TeamICS]
  http://www.overbyte.be/eng/overbyte/teamics.html
 
 
  void __fastcall lockCriticalSection(TCriticalSection *CS)
  {
 // currently it is:
 CS-Acquire();
 
 // what should it be?
  }
 
  Best Regards,
 
  SZ
 
  On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
  Fastream Technologies wrote:
  Hello,
 
  I have a very difficult bug: the program includes lots of
  critical sections and it suddenly stops responding!
 
  Sounds like deadlock.
 
  I have a wrapper global
  function called lockCriticalSection(TCriticalSection *cs) which
  calls acquire. I want to log inside this but need to record the
  call stack so that I can see which call is the lastest. Any idea?
 
  AFAIK Jedi gives you the callstack only upon an exception.
  My idea is to use a different synchronization method with a
  timeout parameter, when the wait timed out you can raise an
  exception.
 
  Would that help?
 
  --
  Arno Garrels [TeamICS]
  http://www.overbyte.be/eng/overbyte/teamics.html
 
 
  Best Regards,
 
  SZ
  --
  To unsubscribe or change your settings for TWSocket mailing list
  please goto http://www.elists.org/mailman/listinfo/twsocket
  Visit our website at http://www.overbyte.be
 
 
 
  --
  CSA, Fastream Technologies
  Software IQ: Innovation  Quality
  www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-
  2830 Join IQWF Server Yahoo group at
  http://groups.yahoo.com/group/IQWFServer Join IQ Reverse Proxy
  Yahoo group at http://groups.yahoo.com/group/IQReverseProxy
  --
  To unsubscribe or change your settings for TWSocket mailing list
  please goto http://www.elists.org/mailman/listinfo/twsocket
  Visit our website at http://www.overbyte.be
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-29 Thread Fastream Technologies
Yes, but the problem is there is exception thrown! I thought I wrote
this before...

On 4/28/07, Markus Humm [EMAIL PROTECTED] wrote:
 Hello,

 did you already try MadExcept? Afaik it comes with source or at least
 can be bought with it and will decipher the callstack. It's free to use
 for non commercial projects AFAIK.

 Greetings

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

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-29 Thread Arno Garrels
Fastream Technologies wrote:
 Hello,
 
 So this is my latest code:
 
 void inline __fastcall lockCriticalSection(TCriticalSection
 *criticalSection) {
 for(int i = 0; i  5000; ++i)
 {
 if(criticalSection-TryEnter())
 return;

Calling Sleep() in such short intervals is critical.
With each call to Sleep() you force a context switch, this will
slow down entire application and may lead to strange results.

Try something like the class below (untested), copy the code
to a new file, name it MySyncObjs.pas and replace SyncObjs by
MySyncObjs in your uses clause (works only if you do not use
other objects from that unit as well). I use MadExept 2.7.

--
unit MySyncObjs;

interface

uses
  Windows, Sysutils, MadExcept;

type
  ECriticalSection = class(Exception);
  TCriticalSection = class(TObject)
  protected
FMutex : THandle;
  public
constructor Create;
destructor Destroy; override;
procedure Acquire;
procedure Release;
procedure Enter;
procedure Leave;
  end;

implementation

{ TCriticalSection }

constructor TCriticalSection.Create;
begin
FMutex := CreateMutex(nil, FALSE, nil);
if FMutex = 0 then
  ECriticalSection.Create(SysErrorMessage(GetLastError));
end;

destructor TCriticalSection.Destroy;
begin
  if FMutex  0 then
  CloseHandle(FMutex);
  inherited;
end;

procedure TCriticalSection.Acquire;
begin
Enter
end;

procedure TCriticalSection.Enter;
var
  WaitResult: Cardinal;
begin  
  try
WaitResult := WaitForSingleObject(FMutex, 5000);
case WaitResult of
  WAIT_TIMEOUT :  raise ECriticalSection.Create('Critical Section timed 
out');
  WAIT_ABANDONED: raise ECriticalSection.Create('Critical Section 
abandoned');
  WAIT_FAILED: raise ECriticalSection.Create(SysErrorMessage(GetLastError));
end;
  except
MadExcept.HandleException;
  end;
end;

procedure TCriticalSection.Leave;
begin
Release
end;

procedure TCriticalSection.Release;
begin
if not ReleaseMutex(FMutex) then
ECriticalSection.Create(SysErrorMessage(GetLastError));
end;

end.


--

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-29 Thread Arno Garrels
Arno Garrels wrote:
 
 Try something like the class below (untested), copy the code

Small fix add raise in front of ECriticalSection.Create in
TCriticalSection.Create as well as in TCriticalSection.Release.
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-29 Thread Fastream Technologies
Dear Arno,

Thank you SO MUCH! I will tell you what the customer reports.

Regards,

SZ

On 4/29/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Arno Garrels wrote:
 
  Try something like the class below (untested), copy the code

 Small fix add raise in front of ECriticalSection.Create in
 TCriticalSection.Create as well as in TCriticalSection.Release.
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be



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


Re: [twsocket] How to get the call stack programmatically?

2007-04-29 Thread Markus Humm
Hello,

what I meant by mentioning MadExcept: it contains the source code to 
determine the call stack. This you could extract from madExcept and call 
it whenever you like. No need to raise some exception first!

The full version of the FastMM memory manager contains similar code.

Greetings

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-29 Thread Fastream Technologies
Hello Markus,

Unfortunately I was not able to detect when a deadlock occurs so as to
launch the function you mention. Let's see if Arno's code will do the
trick...

Best Regards,

SZ

On 4/29/07, Markus Humm [EMAIL PROTECTED] wrote:
 Hello,

 what I meant by mentioning MadExcept: it contains the source code to
 determine the call stack. This you could extract from madExcept and call
 it whenever you like. No need to raise some exception first!

 The full version of the FastMM memory manager contains similar code.

 Greetings

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

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


[twsocket] How to get the call stack programmatically?

2007-04-28 Thread Fastream Technologies
Hello,

I have a very difficult bug: the program includes lots of critical
sections and it suddenly stops responding! I have a wrapper global
function called lockCriticalSection(TCriticalSection *cs) which calls
acquire. I want to log inside this but need to record the call stack
so that I can see which call is the lastest. Any idea?

Best Regards,

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Francois PIETTE
I think JCL or JVCL has a function for call stack.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


- Original Message - 
From: Fastream Technologies [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Saturday, April 28, 2007 9:11 AM
Subject: [twsocket] How to get the call stack programmatically?


 Hello,
 
 I have a very difficult bug: the program includes lots of critical
 sections and it suddenly stops responding! I have a wrapper global
 function called lockCriticalSection(TCriticalSection *cs) which calls
 acquire. I want to log inside this but need to record the call stack
 so that I can see which call is the lastest. Any idea?
 
 Best Regards,
 
 SZ
 -- 
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Arno Garrels
Fastream Technologies wrote:
 Hello,
 
 I have a very difficult bug: the program includes lots of critical
 sections and it suddenly stops responding!

Sounds like deadlock.

 I have a wrapper global
 function called lockCriticalSection(TCriticalSection *cs) which calls
 acquire. I want to log inside this but need to record the call stack
 so that I can see which call is the lastest. Any idea?

AFAIK Jedi gives you the callstack only upon an exception.
My idea is to use a different synchronization method with a timeout
parameter, when the wait timed out you can raise an exception.

Would that help?

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Fastream Technologies
This sounds reasonable. Can you give an example? Since all my cs are
of TCriticalSection type, can I do it in this function:

void __fastcall lockCriticalSection(TCriticalSection *CS)
{
   // currently it is:
   CS-Acquire();

   // what should it be?
}

Best Regards,

SZ

On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
  Hello,
 
  I have a very difficult bug: the program includes lots of critical
  sections and it suddenly stops responding!

 Sounds like deadlock.

  I have a wrapper global
  function called lockCriticalSection(TCriticalSection *cs) which calls
  acquire. I want to log inside this but need to record the call stack
  so that I can see which call is the lastest. Any idea?

 AFAIK Jedi gives you the callstack only upon an exception.
 My idea is to use a different synchronization method with a timeout
 parameter, when the wait timed out you can raise an exception.

 Would that help?

 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html

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



-- 
CSA, Fastream Technologies
Software IQ: Innovation  Quality
www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-2830
Join IQWF Server Yahoo group at http://groups.yahoo.com/group/IQWFServer
Join IQ Reverse Proxy Yahoo group at
http://groups.yahoo.com/group/IQReverseProxy
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Arno Garrels
Fastream Technologies wrote:
 This sounds reasonable. Can you give an example? Since all my cs are
 of TCriticalSection type, can I do it in this function:

I thought of using mutexes. That's not very difficult to change.
Have an array of mutex handles, then pass the index to your
function. Search for CreateMutex etc. in the SDK. When the wait
returned WAIT_TIMEOUT and you raise an exception MadExcept will
report the callstacks of each thread.   
I don't have any idea how one can raise an exception in a thread
or get to thread's callstack when it hangs around in 
CriticalSection-Acquire.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html 

 
 void __fastcall lockCriticalSection(TCriticalSection *CS)
 {
// currently it is:
CS-Acquire();
 
// what should it be?
 }
 
 Best Regards,
 
 SZ
 
 On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
 Hello,
 
 I have a very difficult bug: the program includes lots of critical
 sections and it suddenly stops responding!
 
 Sounds like deadlock.
 
 I have a wrapper global
 function called lockCriticalSection(TCriticalSection *cs) which
 calls acquire. I want to log inside this but need to record the
 call stack so that I can see which call is the lastest. Any idea?
 
 AFAIK Jedi gives you the callstack only upon an exception.
 My idea is to use a different synchronization method with a timeout
 parameter, when the wait timed out you can raise an exception.
 
 Would that help?
 
 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 Best Regards,
 
 SZ
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
 
 
 
 --
 CSA, Fastream Technologies
 Software IQ: Innovation  Quality
 www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-2830
 Join IQWF Server Yahoo group at
 http://groups.yahoo.com/group/IQWFServer Join IQ Reverse Proxy Yahoo
 group at http://groups.yahoo.com/group/IQReverseProxy
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Fastream Technologies
Arno,

I have THOUSANDS of critical sections passed to this function as
parameter! Isn't there a simpler way to implement??

Regards,

SZ

On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
  This sounds reasonable. Can you give an example? Since all my cs are
  of TCriticalSection type, can I do it in this function:

 I thought of using mutexes. That's not very difficult to change.
 Have an array of mutex handles, then pass the index to your
 function. Search for CreateMutex etc. in the SDK. When the wait
 returned WAIT_TIMEOUT and you raise an exception MadExcept will
 report the callstacks of each thread.
 I don't have any idea how one can raise an exception in a thread
 or get to thread's callstack when it hangs around in
 CriticalSection-Acquire.

 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html

 
  void __fastcall lockCriticalSection(TCriticalSection *CS)
  {
 // currently it is:
 CS-Acquire();
 
 // what should it be?
  }
 
  Best Regards,
 
  SZ
 
  On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
  Fastream Technologies wrote:
  Hello,
 
  I have a very difficult bug: the program includes lots of critical
  sections and it suddenly stops responding!
 
  Sounds like deadlock.
 
  I have a wrapper global
  function called lockCriticalSection(TCriticalSection *cs) which
  calls acquire. I want to log inside this but need to record the
  call stack so that I can see which call is the lastest. Any idea?
 
  AFAIK Jedi gives you the callstack only upon an exception.
  My idea is to use a different synchronization method with a timeout
  parameter, when the wait timed out you can raise an exception.
 
  Would that help?
 
  --
  Arno Garrels [TeamICS]
  http://www.overbyte.be/eng/overbyte/teamics.html
 
 
  Best Regards,
 
  SZ
  --
  To unsubscribe or change your settings for TWSocket mailing list
  please goto http://www.elists.org/mailman/listinfo/twsocket
  Visit our website at http://www.overbyte.be
 
 
 
  --
  CSA, Fastream Technologies
  Software IQ: Innovation  Quality
  www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-2830
  Join IQWF Server Yahoo group at
  http://groups.yahoo.com/group/IQWFServer Join IQ Reverse Proxy Yahoo
  group at http://groups.yahoo.com/group/IQReverseProxy
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Fastream Technologies
For example, perhaps we can implement a single global mutex for the
lock... function. This would slow down the execution for sure but
would it create the exception? Can you provide some source code
snippet for this please?

Best Regards,

SZ

On 4/28/07, Fastream Technologies [EMAIL PROTECTED] wrote:
 Arno,

 I have THOUSANDS of critical sections passed to this function as
 parameter! Isn't there a simpler way to implement??

 Regards,

 SZ

 On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
  Fastream Technologies wrote:
   This sounds reasonable. Can you give an example? Since all my cs are
   of TCriticalSection type, can I do it in this function:
 
  I thought of using mutexes. That's not very difficult to change.
  Have an array of mutex handles, then pass the index to your
  function. Search for CreateMutex etc. in the SDK. When the wait
  returned WAIT_TIMEOUT and you raise an exception MadExcept will
  report the callstacks of each thread.
  I don't have any idea how one can raise an exception in a thread
  or get to thread's callstack when it hangs around in
  CriticalSection-Acquire.
 
  --
  Arno Garrels [TeamICS]
  http://www.overbyte.be/eng/overbyte/teamics.html
 
  
   void __fastcall lockCriticalSection(TCriticalSection *CS)
   {
  // currently it is:
  CS-Acquire();
  
  // what should it be?
   }
  
   Best Regards,
  
   SZ
  
   On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
   Fastream Technologies wrote:
   Hello,
  
   I have a very difficult bug: the program includes lots of critical
   sections and it suddenly stops responding!
  
   Sounds like deadlock.
  
   I have a wrapper global
   function called lockCriticalSection(TCriticalSection *cs) which
   calls acquire. I want to log inside this but need to record the
   call stack so that I can see which call is the lastest. Any idea?
  
   AFAIK Jedi gives you the callstack only upon an exception.
   My idea is to use a different synchronization method with a timeout
   parameter, when the wait timed out you can raise an exception.
  
   Would that help?
  
   --
   Arno Garrels [TeamICS]
   http://www.overbyte.be/eng/overbyte/teamics.html
  
  
   Best Regards,
  
   SZ
   --
   To unsubscribe or change your settings for TWSocket mailing list
   please goto http://www.elists.org/mailman/listinfo/twsocket
   Visit our website at http://www.overbyte.be
  
  
  
   --
   CSA, Fastream Technologies
   Software IQ: Innovation  Quality
   www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-2830
   Join IQWF Server Yahoo group at
   http://groups.yahoo.com/group/IQWFServer Join IQ Reverse Proxy Yahoo
   group at http://groups.yahoo.com/group/IQReverseProxy
  --
  To unsubscribe or change your settings for TWSocket mailing list
  please goto http://www.elists.org/mailman/listinfo/twsocket
  Visit our website at http://www.overbyte.be
 

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


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Arno Garrels
Fastream Technologies wrote:
 Arno,
 
 I have THOUSANDS of critical sections passed to this function as
 parameter! 

Why do you need THOUSANDS of critical sections??
That sounds slower than running single threaded.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

 Isn't there a simpler way to implement??
 
 Regards,
 
 SZ
 
 On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
 This sounds reasonable. Can you give an example? Since all my cs are
 of TCriticalSection type, can I do it in this function:
 
 I thought of using mutexes. That's not very difficult to change.
 Have an array of mutex handles, then pass the index to your
 function. Search for CreateMutex etc. in the SDK. When the wait
 returned WAIT_TIMEOUT and you raise an exception MadExcept will
 report the callstacks of each thread.
 I don't have any idea how one can raise an exception in a thread
 or get to thread's callstack when it hangs around in
 CriticalSection-Acquire.
 
 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 void __fastcall lockCriticalSection(TCriticalSection *CS)
 {
// currently it is:
CS-Acquire();
 
// what should it be?
 }
 
 Best Regards,
 
 SZ
 
 On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
 Hello,
 
 I have a very difficult bug: the program includes lots of critical
 sections and it suddenly stops responding!
 
 Sounds like deadlock.
 
 I have a wrapper global
 function called lockCriticalSection(TCriticalSection *cs) which
 calls acquire. I want to log inside this but need to record the
 call stack so that I can see which call is the lastest. Any idea?
 
 AFAIK Jedi gives you the callstack only upon an exception.
 My idea is to use a different synchronization method with a timeout
 parameter, when the wait timed out you can raise an exception.
 
 Would that help?
 
 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 Best Regards,
 
 SZ
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
 
 
 
 --
 CSA, Fastream Technologies
 Software IQ: Innovation  Quality
 www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-
 2830 Join IQWF Server Yahoo group at
 http://groups.yahoo.com/group/IQWFServer Join IQ Reverse Proxy Yahoo
 group at http://groups.yahoo.com/group/IQReverseProxy
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Arno Garrels
Fastream Technologies wrote:
 For example, perhaps we can implement a single global mutex for the
 lock... function. 

No good idea. That would change a lot.

 This would slow down the execution for sure but
 would it create the exception?

You have to raise the exception if the wait returns WAIT_TIMEOUT.

 Can you provide some source code
 snippet for this please?

Please search the internet there should be tons of snippets
around, or ask your question in newsgroup:
borland.public.delphi.nativeapi.win32.  

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

 
 Best Regards,
 
 SZ
 
 On 4/28/07, Fastream Technologies [EMAIL PROTECTED] wrote:
 Arno,
 
 I have THOUSANDS of critical sections passed to this function as
 parameter! Isn't there a simpler way to implement??
 
 Regards,
 
 SZ
 
 On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
 This sounds reasonable. Can you give an example? Since all my cs
 are of TCriticalSection type, can I do it in this function:
 
 I thought of using mutexes. That's not very difficult to change.
 Have an array of mutex handles, then pass the index to your
 function. Search for CreateMutex etc. in the SDK. When the wait
 returned WAIT_TIMEOUT and you raise an exception MadExcept will
 report the callstacks of each thread.
 I don't have any idea how one can raise an exception in a thread
 or get to thread's callstack when it hangs around in
 CriticalSection-Acquire.
 
 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 void __fastcall lockCriticalSection(TCriticalSection *CS)
 {
// currently it is:
CS-Acquire();
 
// what should it be?
 }
 
 Best Regards,
 
 SZ
 
 On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
 Hello,
 
 I have a very difficult bug: the program includes lots of
 critical sections and it suddenly stops responding!
 
 Sounds like deadlock.
 
 I have a wrapper global
 function called lockCriticalSection(TCriticalSection *cs) which
 calls acquire. I want to log inside this but need to record the
 call stack so that I can see which call is the lastest. Any idea?
 
 AFAIK Jedi gives you the callstack only upon an exception.
 My idea is to use a different synchronization method with a
 timeout parameter, when the wait timed out you can raise an
 exception. 
 
 Would that help?
 
 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html
 
 
 Best Regards,
 
 SZ
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
 
 
 
 --
 CSA, Fastream Technologies
 Software IQ: Innovation  Quality
 www.fastream.com | Email: [EMAIL PROTECTED] | Tel: +90-312-223-
 2830 Join IQWF Server Yahoo group at
 http://groups.yahoo.com/group/IQWFServer Join IQ Reverse Proxy
 Yahoo group at http://groups.yahoo.com/group/IQReverseProxy
 --
 To unsubscribe or change your settings for TWSocket mailing list
 please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Fastream Technologies
Hello Arno,

Per your advice, I coded the following but in the first time there
needs to be a wait for other thread, it times out! I wonder why?

void inline __fastcall lockCriticalSection(TCriticalSection *criticalSection)
{
HANDLE hMutex;

// Create a mutex with no initial owner.

hMutex = CreateMutex(
NULL,   // no security attributes
true,  // initially owned
String((int)(void*)criticalSection).c_str());  // name 
of mutex

DWORD dwWaitResult;

// Request ownership of mutex.

if(hMutex)
{
dwWaitResult = WaitForSingleObject(
hMutex,   // handle to mutex
5000L);   // five-second time-out interval

switch(dwWaitResult)
{
// Cannot get mutex ownership due to time-out.
case WAIT_TIMEOUT:
throw Exception(BUG FOUND, CHECK CALL 
STACK!);

// Got ownership of the abandoned mutex object.
case WAIT_ABANDONED:
break;
}
}

criticalSection-Acquire();
};

void inline __fastcall releaseCriticalSection(TCriticalSection *criticalSection)
{
criticalSection-Release();

HANDLE hMutex;

// Create a mutex with no initial owner.

hMutex = OpenMutex(
  MUTEX_ALL_ACCESS,
  false,
  String((int)(void*)criticalSection).c_str()
);  // name of mutex

if(hMutex)
{
DWORD dwWaitResult;

// Request ownership of mutex.

dwWaitResult = WaitForSingleObject(
hMutex,   // handle to mutex
5000L);   // five-second time-out interval

switch(dwWaitResult)
{
// The thread got mutex ownership.
case WAIT_OBJECT_0:
// Release ownership of the mutex 
object.
if(!ReleaseMutex(hMutex))
{
// Deal with error.
}

break;

// Cannot get mutex ownership due to time-out.
case WAIT_TIMEOUT:
break;

// Got ownership of the abandoned mutex object.
case WAIT_ABANDONED:
break;
}
}
};

PLEASE HELP! The technique I used is called named mutex. What I am
trying to do is to complete the job in these two functions.

Best Regards,

SZ


On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
 Fastream Technologies wrote:
  For example, perhaps we can implement a single global mutex for the
  lock... function.

 No good idea. That would change a lot.

  This would slow down the execution for sure but
  would it create the exception?

 You have to raise the exception if the wait returns WAIT_TIMEOUT.

  Can you provide some source code
  snippet for this please?

 Please search the internet there should be tons of snippets
 around, or ask your question in newsgroup:
 borland.public.delphi.nativeapi.win32.

 --
 Arno Garrels [TeamICS]
 http://www.overbyte.be/eng/overbyte/teamics.html

 
  Best Regards,
 
  SZ
 
  On 4/28/07, Fastream Technologies [EMAIL PROTECTED] wrote:
  Arno,
 
  I have THOUSANDS of critical sections passed to this function as
  parameter! Isn't there a simpler way to implement??
 
  Regards,
 
  SZ
 
  On 4/28/07, Arno Garrels [EMAIL PROTECTED] wrote:
  Fastream Technologies wrote:
  This sounds reasonable. Can you give an example? Since all my cs
  are of TCriticalSection type, can I do it in this function:
 
  I thought of using mutexes. That's not very difficult to change.
  Have an array of mutex handles, then pass the index to your
  function. Search for CreateMutex etc. in the SDK. When the wait
  returned WAIT_TIMEOUT and you raise an exception MadExcept will
  report the callstacks of each thread.
  I don't have any idea how one can raise an exception in a thread
  or get to thread's callstack when it hangs around in
  CriticalSection-Acquire.
 
  --
  Arno Garrels [TeamICS]
  http://www.overbyte.be/eng/overbyte/teamics.html
 
 
  void __fastcall 

Re: [twsocket] How to get the call stack programmatically?

2007-04-28 Thread Markus Humm
Hello,

did you already try MadExcept? Afaik it comes with source or at least 
can be bought with it and will decipher the callstack. It's free to use 
for non commercial projects AFAIK.

Greetings

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