XmlDiffLib icon indicating copy to clipboard operation
XmlDiffLib copied to clipboard

System.StackOverflowException

Open maldworth opened this issue 8 years ago • 13 comments

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

I'm getting this failure when I try to diff this file. You can reproduce with the sample file below. Just use it as the To and From, and you will see it fail.

See the sample XML here: https://gist.github.com/maldworth/ef6cd93be25d3617379b899977a5ed5b

maldworth avatar Sep 10 '16 15:09 maldworth

Thanks for bringing this to my attention. The problem here is that the algorithm for differencing xml uses recursion and is reaching the limit of the allowable recursion depth for .Net. I will need to rewrite the algorithm to avoid recursion, which will take me some time. In fact, I'll likely rewrite the code using the Zhang Sahsha algorithm as it will be far more accurate than it is now.

BrutalSimplicity avatar Sep 11 '16 19:09 BrutalSimplicity

Beginning work on this issue here: https://github.com/BrutalSimplicity/XmlDiffLib/tree/zhang-shasha

BrutalSimplicity avatar Sep 13 '16 03:09 BrutalSimplicity

I am also getting stack overflow exception, waiting for the fix :(

laveravi avatar Oct 05 '16 21:10 laveravi

Sorry about that, are you getting it on every Xml, or is this a particular set of samples that is returning it.

Also, if you could post the Xml that would be helpful. You can perhaps post it as a gist, and put the link here.

I'll see if I can provide a short-term hack for it, until I rewrite the algorithm.

BrutalSimplicity avatar Oct 05 '16 21:10 BrutalSimplicity

Not for every Xml. Only for lengthy input xml. I will post the xml in a while. Thank you.

laveravi avatar Oct 05 '16 21:10 laveravi

Cool, thanks for the info. Yea, it's a fault of the algorithm I hadn't considered that when the Xml structure is deep enough the recursion limit gets hit.

BrutalSimplicity avatar Oct 05 '16 21:10 BrutalSimplicity

any update on the fix :(?

laveravi avatar Feb 15 '17 16:02 laveravi

Sorry man, this is still on my horizon, but you know... Life. Will try to do a bit more work this weekend.

BrutalSimplicity avatar Mar 10 '17 18:03 BrutalSimplicity

I investigation this issue, it is associated with the same name elements without attributes, if there are several of them in the same parent. example:

<Root>
	<First>
		<Head>Head1</Head>
		<Item>Value1</Item>
		<Item>Value2</Item>
		<Item>Value3</Item>
	</First>
	<Second>
		<Head>Head2</Head>
		<Item>Value1</Item>
		<Item>Value2</Item>
		<Item>Value3</Item>
	</Second>
</Root>

this XML throw exception (stackoverflow)

MatchElement () can not correctly compare elements, because it does not check their contents. It turns out that all elements are equal to each other.

grwizard avatar Mar 15 '17 13:03 grwizard

Hi, I'm also getting this error when the XML File is especially large., like around 100 rows. Any update on the fix? Perhaps I can help?

TheSithPadawan avatar Aug 10 '18 23:08 TheSithPadawan

I am also getting this issue, is there any fix for this?

TarunBabbar avatar May 29 '19 11:05 TarunBabbar

Same here, large files cause this issue.

evrimicoz avatar Sep 03 '19 20:09 evrimicoz

Yeah, I also have that issue with large files.. any idea if progress was made or if there are any alternatives?

marcdepelteau avatar Nov 16 '20 14:11 marcdepelteau