StackOverflowException

Posts   
 
    
Posts: 254
Joined: 16-Nov-2006
# Posted on: 22-Apr-2008 21:52:12   

SQL Server 2005 Latest 2.5 version 2.5.08.0328 of runtime

Guys

I've data bound a DataGridView to an EntityCollection and have defined a few different event handlers for the grid. Everything works fine except when I click on one of the columns in the grid ( Description ) to sort it, it changes the order from descending then ascending then causes a stack overflow exception.

This is part of the stack trace which shows one complete stack cycle duplicated once.

Cheers

Matt

System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnSelectionChanged(System.EventArgs e) + 0x87 bytes  
    System.Windows.Forms.dll!System.Windows.Forms.DataGridView.ClearSelection(int columnIndexException, int rowIndexException, bool selectExceptionElement) + 0x336 bytes   
    System.Windows.Forms.dll!System.Windows.Forms.DataGridView.SetAndSelectCurrentCellAddress(int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick, bool clearSelection, bool forceCurrentCellSelection) + 0x5f bytes 
    System.Windows.Forms.dll!System.Windows.Forms.DataGridView.MakeFirstDisplayedCellCurrentCell(bool includeNewRow) + 0x8d bytes   
    System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnRowCollectionChanged_PostNotification(bool recreateNewRow, bool allowSettingCurrentCell, System.ComponentModel.CollectionChangeAction cca = Add, System.Windows.Forms.DataGridViewRow dataGridViewRow = {System.Windows.Forms.DataGridViewRow}, int rowIndex = 0) + 0xfc bytes 
    System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged_ PostNotification(System.ComponentModel.CollectionChangeAction cca, int rowIndex, int rowCount, System.Windows.Forms.DataGridViewRow dataGridViewRow, bool changeIsDeletion, bool changeIsInsertion, bool recreateNewRow, System.Drawing.Point newCurrentCell) + 0xb8 bytes 
    System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged System.ComponentModel.CollectionChangeEventArgs e, int rowIndex, int rowCount) + 0x101 bytes    
    System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRowCollection.AddInternal System.Windows.Forms.DataGridViewRow dataGridViewRow) + 0x2c7 bytes 
    System.Windows.Forms.dll!System.Windows.Forms.DataGridView.RefreshRows(bool scrollIntoView = true) + 0x1a7 bytes    
    System.Windows.Forms.dll!System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged( System.ComponentModel.ListChangedEventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x575 bytes    
    System.Windows.Forms.dll!System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e = {System.ComponentModel.ListChangedEventArgs}) + 0x27 bytes  
    System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnListChanged (System.ComponentModel.ListChangedEventArgs e) + 0x17 bytes 
    System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) + 0x512 bytes   
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase< CodeReviewer.EntityClasses.DefectEntity>.OnListChanged(int index = 0, System.ComponentModel.ListChangedType typeOfChange = Reset) Line 750 + 0x29 bytes   C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase< CodeReviewer.EntityClasses.DefectEntity>._relatedCollectionListChanged(object sender = {CodeReviewer.CollectionClasses.DefectCollection}, System.ComponentModel.ListChangedEventArgs e = {System.ComponentModel.ListChangedEventArgs}) Line 1080 + 0xe bytes  C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore< CodeReviewer.EntityClasses.DefectEntity>.OnListChanged(int index = 0, System.ComponentModel.ListChangedType typeOfChange = ItemChanged) Line 859 + 0x2d bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore< CodeReviewer.EntityClasses.DefectEntity>.OnEntityInListOnEntityContentsChanged(object sender = {CodeReviewer.EntityClasses.DefectEntity}, System.EventArgs e = {System.EventArgs}) Line 944 + 0x2d bytes  C#
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.FlagMeAsChanged() Line 1071 + 0x23 bytes   C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.SyncFKFields( SD.LLBLGen.Pro.ORMSupportClasses.EntitySyncInfo<SD.LLBLGen.Pro.ORMSupportClasses.IEntity> syncInfo = {SD.LLBLGen.Pro.ORMSupportClasses.EntitySyncInfo<SD.LLBLGen.Pro.ORMSupportClasses.IEntity>}) Line 3151 + 0x7 bytes  C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityBase. SetEntitySyncInformation(string fieldName = "DefectSeverity", SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity = {CodeReviewer.EntityClasses.DefectSeverityEntity}, SD.LLBLGen.Pro.ORMSupportClasses.IEntityRelation relation = {SD.LLBLGen.Pro.ORMSupportClasses.EntityRelation}) Line 3297 + 0xd bytes    C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityBase. PerformSetupSyncRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity = {CodeReviewer.EntityClasses.DefectSeverityEntity}, System.ComponentModel.PropertyChangedEventHandler propertiesChangedHandler = {Method = Cannot evaluate expression because the code of the current method is optimized.}, string fieldName = "DefectSeverity", SD.LLBLGen.Pro.ORMSupportClasses.IEntityRelation relation = {SD.LLBLGen.Pro.ORMSupportClasses.EntityRelation}, bool connectToSaveEvent = true, ref bool alreadyFetchedFlag = true, string[] forfNames = {string[0]}) Line 3374 + 0x11 bytes   C#
    CodeReviewer.dll!CodeReviewer.EntityClasses.DefectEntityBase.SetupSyncDefectSeverity( SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity = {CodeReviewer.EntityClasses.DefectSeverityEntity}) Line 1456 + 0x6d bytes    C#
    CodeReviewer.dll!CodeReviewer.EntityClasses.DefectEntityBase.SetRelatedEntity( SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity = {CodeReviewer.EntityClasses.DefectSeverityEntity}, string fieldName = "DefectSeverity") Line 387 + 0x9 bytes    C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase< CodeReviewer.EntityClasses.DefectEntity>.PerformSetRelatedEntity(CodeReviewer.EntityClasses.DefectEntity entity = {CodeReviewer.EntityClasses.DefectEntity}) Line 1456 + 0x13 bytes C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore< CodeReviewer.EntityClasses.DefectEntity>.PerformAdd(CodeReviewer.EntityClasses.DefectEntity item = {CodeReviewer.EntityClasses.DefectEntity}) Line 1280 + 0xd bytes   C#
    SD.LLBLGen.Pro.ORMSupportClasses.dll!SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore< CodeReviewer.EntityClasses.DefectEntity>.Add(CodeReviewer.EntityClasses.DefectEntity item = {CodeReviewer.EntityClasses.DefectEntity}) Line 319 + 0x9 bytes   C#
    CodeReviewer.dll!CodeReviewer.EntityClasses.DefectSeverityEntityBase.SetRelatedEntity (SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity = {CodeReviewer.EntityClasses.DefectEntity}, string fieldName = "Defect") Line 283 + 0x32 bytes   C#
    CodeReviewer.dll!CodeReviewer.EntityClasses.DefectEntityBase.DefectSeverity.set( CodeReviewer.EntityClasses.DefectSeverityEntity value = {CodeReviewer.EntityClasses.DefectSeverityEntity}) Line 2008 + 0x10 bytes  C#
    CodeReviewerTaskManager.exe!CodeReviewerTaskManager.ReviewFileForm.UpdateDefectFromControls( CodeReviewer.EntityClasses.DefectEntity defect = {CodeReviewer.EntityClasses.DefectEntity}) Line 489 + 0x2d bytes  C#
    CodeReviewerTaskManager.exe!CodeReviewerTaskManager.ReviewFileForm.defectGridControl_DefectSelected(object sender = {CRWinFormControls.DefectGrid.DefectGridControl}, CRWinFormControls.DefectGrid.DefectEventArgs e = {CRWinFormControls.DefectGrid.DefectEventArgs}) Line 1453 + 0x11 bytes   C#
    CRWinFormControls.dll!CRWinFormControls.DefectGrid.DefectGridControl.OnDefectSelected( CodeReviewer.EntityClasses.DefectEntity defect = {CodeReviewer.EntityClasses.DefectEntity}) Line 435 + 0x29 bytes    C#

-- SNIP .... -- Otis

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 23-Apr-2008 11:25:44   

Would you please attach a simple repro solution (better be based on northwind)?

Posts: 254
Joined: 16-Nov-2006
# Posted on: 23-Apr-2008 11:41:09   

No that's not possible unfortunately. It's a complex app with many dependencies.

I can put additional trace logging at certain points in the core runtime code if you want if this would help you determine the state at specific places.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 23-Apr-2008 12:35:06   

No that's not possible unfortunately. It's a complex app with many dependencies.

We don't need your complex application. But we don't have enough information to debug your issue, so maybe you can just create a simple form based on northwind where you can reproduce this error.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 23-Apr-2008 12:39:29   

Stack overflows are infinite recursion loops. So please use the debug build of the llblgen pro runtime lib (it's shipped with the runtime libs in a separate folder) and when you sort you immediately break the debugger. this should give a proper indication where things loop

I've cut off your long stacktrace as it ruined the layout of the page completely plus it's of no use to traverse 10 pages of stacktrace if the stack was run over by an infinite loop. Please next time make sure the post doesn't ruin the layout of the page.

Sorting of a view can also be done without a grid. Can you repro it with sorting the entity view in code?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 254
Joined: 16-Nov-2006
# Posted on: 23-Apr-2008 15:42:45   

Hi Frans,

Thanks for the feedback. The output I sent was actually a single stack trace, but with each frame duplicated twice to show the exact point or rather cycle of stack frames called which caused the stack overflow. I thought this would be helpful.

I actually captured the stack trace using a debug build of the llbgen runtime, however I wasn't aware of a separate debug project, I will look into that and capture another call stack. In what way is the debug project different to the standard runtime library?

I'll also try sorting the collection using the business object directly.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 23-Apr-2008 15:59:47   

I actually captured the stack trace using a debug build of the llbgen runtime, however I wasn't aware of a separate debug project,

A debug build is a debug build, so most probably these are identical, if not actually the same simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 23-Apr-2008 16:01:00   

The debug build is the same, it just comes with a pdb and is a debug build so you can load the .pdb module in the modules screen in vs.net (debugger windows) and step into the code of the ormsupportclasses dll by pointing vs.net to the folder of the sourcecode once you step into a method.

However, as it seems this is caused by event cycles (entities keep on signaling that they're changed), it's very hard to track down (read: impossible) without a reprocase. So if you can't repro it in a repro case, there's little we can do about it at the moment.

If not already the case: be sure to use the latest templates and runtime lib.

Frans Bouma | Lead developer LLBLGen Pro