Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Unknown Exception after Application->Terminate()



Permlink Replies: 6 - Last Post: Jul 28, 2017 11:28 PM Last Post By: John Pearson Threads: [ Previous | Next ]
John Pearson

Posts: 42
Registered: 8/23/05
Unknown Exception after Application->Terminate()
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 17, 2017 6:25 AM
On closing my prog I get an exception in a message box.
" is not a valid floating point value

Breaking on HandleException() in TWinControl.MainWndProc(..) and stepping
thru' the Vcl doesn't leave me any wiser. Typically variables are optimised
out (the Compiler optimisation option is 'disable all optimisation')

I trapped this

System::Exception* :0012E964: :01FFE630
FMessage {u"" is not a valid floating point value"}
FHelpContext 0
FInnerException NULL
FStackInfo NULL
FAcquireInnerException false
GetExceptionStackInfoProc :006F0EC4
GetStackInfoStringProc :006F0EC8
CleanUpStackInfoProc :006F0ECC

I'm stuck.

1. How do I trace this exception to my code
2. Why should I get such an exception on Application->Terminate() ;

Best John
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Unknown Exception after Application->Terminate()
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 24, 2017 10:01 AM   in response to: John Pearson in response to: John Pearson
John Pearson wrote:

On closing my prog I get an exception in a message box.
" is not a valid floating point value

Breaking on HandleException() in TWinControl.MainWndProc(..) and
stepping thru' the Vcl doesn't leave me any wiser. Typically
variables are optimised out (the Compiler optimisation option is
'disable all optimisation')

Without seeing a stack trace from the IDE debugger (you ARE running the
app inside the debugger, right?) leading up to the exception, there is
no way anyone here can diagnose this for you. You will have to track
it down yourself. When the debugger sees the exception, it should jump
right to the code that raised the exception, whether it is in the
RTL/VCL or your own code.

1. How do I trace this exception to my code

What makes you think it is in your code to begin with?

2. Why should I get such an exception on Application->Terminate() ;

Application->Terminate() itself doesn't raise ay exceptions. It simply
posts a WM_QUIT message to the main message queue. The app exits after
Application->Run() exits when it receives that message.

--
Remy Lebeau (TeamB)
John Pearson

Posts: 42
Registered: 8/23/05
Re: Unknown Exception after Application->Terminate()
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 26, 2017 8:15 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy wrote
"When the debugger sees the exception, it should jump right to the
code that raised the exception, whether it is in the RTL/VCL or your own
code."

The exception occurs in Vcl.Controls::TWinControl.MainWndProc( . ) where
execution jumps to Application.HandleException( . )
The stack at HandleException() is:-

->:005FCE77 Vcl::Controls::TWinControl::MainWndProc(Self=:040E2C80,
Message=????)
:0047131E System::Classes::StdWndProc(Window=????, Message=5, WParam=0,
LParam=65078175)
:75a7fd72 ; C:\Windows\system32\USER32.dll
:75a7fe4a ; C:\Windows\system32\USER32.dll
:75a79d6a USER32.ReleaseDC + 0x7d
:75a79f8d USER32.WCSToMBEx + 0xcc
:76f05dae ntdll.KiUserCallbackDispatcher + 0x2e
:75a803ab ; C:\Windows\system32\USER32.dll
:75a80408 USER32.DefWindowProcW + 0x54
:75a7fd72 ; C:\Windows\system32\USER32.dll
:75a7fe4a ; C:\Windows\system32\USER32.dll
:75a809d3 USER32.CallWindowProcW + 0x75
:75a80979 USER32.CallWindowProcW + 0x1b
:005FD921 Vcl::Controls::TWinControl::DefaultHandler(Self=????,
Message=????)

On exiting Vcl.Forms::TApplication>HandleException execution passes into
System.Classes::StdWinProc( .),
the exception messagebox appears, and the stack shows
:005FD8B4 Vcl::Controls::TWinControl::DefaultHandler(Self=:04262C80,
Message=:0012F930)

If I subclass WndProc to catch the exception so I can trace it thru
TWinControl.MainWndProc( . )
[called many times) when it occurs then the exception is in
FreeMemoryContexts; viz

procedure TWinControl.MainWndProc(var Message: TMessage);
begin
try
try
WindowProc(Message);
finally
FreeDeviceContexts;
FreeMemoryContexts; //exception here
end;
except
Application.HandleException(Self);
end;
end;

and Remy wrote
"What makes you think it is in your code to begin with?"
I'm assuming the exception is caused by my code.

How do I debug further ?

Thanx John
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Unknown Exception after Application->Terminate()
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 26, 2017 9:59 AM   in response to: John Pearson in response to: John Pearson
John Pearson wrote:

:0047131E System::Classes::StdWndProc(Window=????, Message=5,
WParam=0, LParam=65078175)

Message=5 is WM_SIZE, where WParam=0 is SIZE_RESTORED, and
LParam=65078175 is a rectangle of 927x993 pixels (does that sound about
right for the size of your TForm's client area?). That is an odd
message to get during app shutdown.

If I subclass WndProc to catch the exception so I can trace it thru
TWinControl.MainWndProc( . )
[called many times) when it occurs then the exception is in
FreeMemoryContexts;

The only way I can see FreeMemoryContexts() crashing is if you have an
invalid/corrupted TBitmap canvas in memory. Do you happen to use any
TBitmap objects in worker threads without locking their canvases?

--
Remy Lebeau (TeamB)
John Pearson

Posts: 42
Registered: 8/23/05
Re: Unknown Exception after Application->Terminate()
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 27, 2017 12:42 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Hi Remy

Thanx for the prompt reply.

You wrote "LParam=65078175 is a rectangle of 927x993 pixels (does that
sound about right for the size of your TForm's client area?). "

Yes. The TForm client area is 927x974 .

and "Do you happen to use any TBitmap objects in worker threads without
locking their canvases?"

Yes. Several TBitmap objects but none are threaded and their Canvases not
locked.

Best John.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Unknown Exception after Application->Terminate()
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 27, 2017 8:57 AM   in response to: John Pearson in response to: John Pearson
John Pearson wrote:

"Do you happen to use any TBitmap objects in worker threads
without locking their canvases?"

Yes. Several TBitmap objects but none are threaded and their
Canvases not locked.

Any TBitmap object that is used outside of the main UI thread must
have its Canvas locked, otherwise the main UI thread will destroy and
invalidate the canvas while the thread is still using it. The sole
purpose of FreeMemoryContexts() is to release unlocked TBitmap canvases.

--
Remy Lebeau (TeamB)
John Pearson

Posts: 42
Registered: 8/23/05
Re: Unknown Exception after Application->Terminate()
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 28, 2017 11:28 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy

Thanx for the insight.
When time permits I'll drill into this problem.& post again if necessary
Meanwhile I can dismiss the exception warning in the local WndProc. ;-)

John


"Remy Lebeau (TeamB)" <no dot spam at no dot spam dot com> wrote in message
news:927760 at forums dot embarcadero dot com...

John Pearson wrote:

"Do you happen to use any TBitmap objects in worker threads
without locking their canvases?"

Yes. Several TBitmap objects but none are threaded and their
Canvases not locked.

Any TBitmap object that is used outside of the main UI thread must
have its Canvas locked, otherwise the main UI thread will destroy and
invalidate the canvas while the thread is still using it. The sole
purpose of FreeMemoryContexts() is to release unlocked TBitmap canvases.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02