Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: List index out of bounds exception in TListBoxStrings.GetObject


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 8 - Last Post: Mar 16, 2018 1:26 PM Last Post By: Alan Hartmann
Alan Hartmann

Posts: 17
Registered: 2/21/08
List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2018 8:35 AM
Delphi XE7 app using LMD VCL Complete 2015 library. Sporadically we get MadExcept bug reports that have no references to application level code in the call stack, with exception “List index out of bounds”coming out of TListBoxStrings.GetObject. All or most of the customers experiencing this issue are running Remote Desktop Services on W2012 R2 servers. A portion of the exception report isshown below.

Can anyone suggest how this can be debugged? We’ve never been able to reproduce this problem in in-house testing, or while running in the IDE. It’s not practical to replace all the LMD components that might be involved.

date/time          : 2018-03-12, 06:22:11, 785ms
computer name      : xxxx
wts client name    : xxxx
user name          : xxxx
registered owner   : Windows User
operating system   : Windows 2012 R2 x64 build 9600
system language    : English
system up time     : 11 days 14 hours
program up time    : 7 hours 26 minutes
processors         : 2x Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz
physical memory    : 2583/4095 MB (free/total)
free disk space    : (C:) 23.56 GB (P:) 78.05 GB
display mode       : 1366x768, 32 bit
process id         : $dac
allocated memory   : 40.56 MB
largest free block : 1.35 GB
executable         : Dashboard4006.exe
exec. date/time    : 2018-03-07 11:55
version            : 4.0.0.6
compiled with      : Delphi XE7
madExcept version  : 4.0.12
callstack crc      : $052b8584, $3a5d7b71, $b699f6ce
exception number   : 1
exception class    : EStringListError
exception message  : List index out of bounds (2).
 
main thread ($1240):
005f46a9 Dashboard4006.exe Vcl.StdCtrls             TListBoxStrings.GetObject
0053bdba Dashboard4006.exe System.Classes           TStrings.AddStrings
0053bfd6 Dashboard4006.exe System.Classes           TStrings.Assign
0053db82 Dashboard4006.exe System.Classes           TStringList.Assign
005f4e91 Dashboard4006.exe Vcl.StdCtrls             TCustomListBox.SaveRecreateItems
005f5a05 Dashboard4006.exe Vcl.StdCtrls             TCustomListBox.DestroyWnd
005d3ab9 Dashboard4006.exe Vcl.Controls             TWinControl.DestroyHandle
005d3a89 Dashboard4006.exe Vcl.Controls             TWinControl.DestroyHandle
005d3831 Dashboard4006.exe Vcl.Controls             TWinControl.DestroyWnd
005d3a89 Dashboard4006.exe Vcl.Controls             TWinControl.DestroyHandle
005d3b16 Dashboard4006.exe Vcl.Controls             TWinControl.CMRecreateWnd
005cfdc9 Dashboard4006.exe Vcl.Controls             TControl.WndProc
005d4896 Dashboard4006.exe Vcl.Controls             TWinControl.WndProc
005cfa04 Dashboard4006.exe Vcl.Controls             TControl.Perform
005d3ada Dashboard4006.exe Vcl.Controls             TWinControl.RecreateWnd
0072e57a Dashboard4006.exe LMDCustomBevelPanel      TLMDCustomBevelPanel.DoThemeChanged
0072cb14 Dashboard4006.exe LMDCustomControl         TLMDCustomControl.WMThemeChanged
005cfdc9 Dashboard4006.exe Vcl.Controls             TControl.WndProc
0071f6bf Dashboard4006.exe LMDBaseGraphicControl    TLMDBaseGraphicControl.WMThemeChanged
005cfdc9 Dashboard4006.exe Vcl.Controls             TControl.WndProc
005d4896 Dashboard4006.exe Vcl.Controls             TWinControl.WndProc
005cfa04 Dashboard4006.exe Vcl.Controls             TControl.Perform
0072e56f Dashboard4006.exe LMDCustomBevelPanel      TLMDCustomBevelPanel.DoThemeChanged
0072cb14 Dashboard4006.exe LMDCustomControl         TLMDCustomControl.WMThemeChanged
005cfdc9 Dashboard4006.exe Vcl.Controls             TControl.WndProc
005d4896 Dashboard4006.exe Vcl.Controls             TWinControl.WndProc
005d3ed0 Dashboard4006.exe Vcl.Controls             TWinControl.MainWndProc
00555850 Dashboard4006.exe System.Classes           StdWndProc
77670664 ntdll.dll                                  KiUserCallbackDispatcher
74ebf15d USER32.dll                                 SendMessageTimeoutW
74ebeef6 USER32.dll                                 EnumChildWindows
74f03fd6 USER32.dll                                 EnumDesktopWindows
74f04000 USER32.dll                                 EnumDesktopsW
00555850 Dashboard4006.exe System.Classes           StdWndProc
74eba6db USER32.dll                                 DispatchMessageW
006cc96f Dashboard4006.exe Vcl.Forms                TApplication.ProcessMessage
006cc9b2 Dashboard4006.exe Vcl.Forms                TApplication.HandleMessage
006ccce5 Dashboard4006.exe Vcl.Forms                TApplication.Run
00b0096c Dashboard4006.exe Dashboard             81 initialization
77157c02 KERNEL32.DLL                               BaseThreadInitThunk
Matthew Jones

Posts: 337
Registered: 1/25/98
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2018 9:43 AM   in response to: Alan Hartmann in response to: Alan Hartmann
Alan Hartmann wrote:

TLMDCustomBevelPanel.DoThemeChanged

That appears to be called twice, so possibly recursively. I presume though that something has affected the content of the list box between the count and the access.

Is there a clue in the theme changing at all?
Alan Hartmann

Posts: 17
Registered: 2/21/08
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2018 11:15 AM   in response to: Matthew Jones in response to: Matthew Jones
dup post, sorry.

Edited by: Alan Hartmann on Mar 12, 2018 2:18 PM
Alan Hartmann

Posts: 17
Registered: 2/21/08
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2018 11:16 AM   in response to: Matthew Jones in response to: Matthew Jones
Matthew Jones wrote:

That appears to be called twice, so possibly recursively. I presume though that something has affected the content of the list box between the count and the access.

That's a possibility. With no app code in the call stack, I wouldn't know where to begin looking though. I can't even tell which list box is affected.

Is there a clue in the theme changing at all?

That's a good question. No customers have thus far admitted to changing their themes at the same time as the program crashed.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2018 12:34 PM   in response to: Alan Hartmann in response to: Alan Hartmann
Alan Hartmann wrote:

That's a possibility. With no app code in the call stack, I
wouldn't know where to begin looking though.

From the stack trace, it looks like an LMD control is processing a
WM_THEMECHANGED message, goes to recreate its HWND, and an error
happens during that process. Maybe the LMD control destroyed its
internal objects before the RTL had a chance to copy them? Really hard
to say without having the LMD source code to look at. You might try
manually sending a WM_THEMECHANGED message and trace the LMD source
code yourseld to see what is happening.

--
Remy Lebeau (TeamB)
Alan Hartmann

Posts: 17
Registered: 2/21/08
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 12, 2018 1:59 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
...
You might try
manually sending a WM_THEMECHANGED message and trace the LMD source
code yourseld to see what is happening.

--
Remy Lebeau (TeamB)

That's a great idea. I don't have the source code for LMD, but if I'm able to make the problem happen in a controlled environment, I might be able to get further assistance from the LMD folks. Thanks!
Alan Hartmann

Posts: 17
Registered: 2/21/08
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 16, 2018 11:02 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
. You might try
manually sending a WM_THEMECHANGED message and trace the LMD source
code yourseld to see what is happening.

--
Remy Lebeau (TeamB)

So far I've had no luck reproducing the problem. I initially tried using the Send Message program ( [Send Message|http://tools.stefankueng.com/SendMessage.html] ), then built a test procedure right into the program to periodically send a few WM_THEMECHANGED messages to the application.handle, but I never get the crash. MS documentation I've read on WM_THEMECHANGED doesn't specify what values should be passed for wParam or lParam, so I've just used 0 for both.

Could my methodology be flawed? The test environment is not identical to the environment my customers run in, and that could certainly be part of the issue, but creating a 100% identical environment is going to be very difficult .

Any other thoughts for how I might approach this?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 16, 2018 11:41 AM   in response to: Alan Hartmann in response to: Alan Hartmann
Alan Hartmann wrote:

So far I've had no luck reproducing the problem. I initially tried
using the Send Message program, then built a test procedure right into
the program to periodically send a few WM_THEMECHANGED messages to the
application.handle, but I never get the crash.

Makes sense, since you are not duplicating what your stack trace showed
earlier. I was implying that you should send WM_THEMECHANGED directly
to the ListBox window, not to the Application window. TApplication
converts WM_THEMECHANGED messages into CM_THEMECHANGED messages and
then broadcasts them to each active TForm. That is not what your stack
trace showed was happening. TLMDCustomControl and
TLMDBaseGraphicControl were handling WM_THEMECHANGED messages directly
instead.

The test environment is not identical to the environment my customers
run in, and that could certainly be part of the issue, but creating a
100% identical environment is going to be very difficult.

Does your test environment at least have themes enabled?

--
Remy Lebeau (TeamB)
Alan Hartmann

Posts: 17
Registered: 2/21/08
Re: List index out of bounds exception in TListBoxStrings.GetObject  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 16, 2018 1:26 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
I was implying that you should send WM_THEMECHANGED directly
to the ListBox window, not to the Application window. ...

Ahh, I completely missed that, sorry. There are some challenges with that approach because there are a number of instances of components based on the one LMDListBox, but I should be able to identify them and modify my test.

Remy Lebeau (TeamB) wrote:

Does your test environment at least have themes enabled?

Remy Lebeau (TeamB)

Yes, in fact I initially tried to repro the problem by using the "personalize" option in Windows.

I really appreciate your help!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02