Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Comments

fix: Maximum call stack size exceeded when open a bot#3025

Merged
cwhitten merged 8 commits intomicrosoft:masterfrom
lei9444:cache
May 13, 2020
Merged

fix: Maximum call stack size exceeded when open a bot#3025
cwhitten merged 8 commits intomicrosoft:masterfrom
lei9444:cache

Conversation

@lei9444
Copy link
Contributor

@lei9444 lei9444 commented May 13, 2020

Description

I have add a debug information with defName, invoked times and recursion depth in the getRef function

image

this three types

Microsoft.BeginDialog
Microsoft.QnAMakerDialog
Microsoft.AdaptiveDialog

are looping infinitely

The first time we open the bot, the definitionCache is empty. After doing dereference. The cache has stored the definition.

Then open a new bot again, The Microsoft.BeginDialog is stored in cache already. If we use the value and do dereference continue. There will be a infinite loop. The Microsoft.BeginDialog has a type Microsoft.IDialog, and IDialog has a Microsoft.BeginDialog type.

The schema about Microsoft.IDialog

"Microsoft.IDialog": {
			"title": "Microsoft Dialogs",
			"description": "Components which derive from Dialog",
			"$role": "interface",
			"oneOf": [
				{
					"type": "string"
				},
				{
					"$ref": "#/definitions/Microsoft.QnAMakerDialog"
				},
				{
					"$ref": "#/definitions/Microsoft.AdaptiveDialog"
				},
				{
					"$ref": "#/definitions/Microsoft.BeginDialog"
				},
				{
					"$ref": "#/definitions/Microsoft.BreakLoop"
				},

and part of Microsoft.BeginDialog are

					"oneOf": [
						{
							"$kind": "Microsoft.IDialog",
							"pattern": "^(?!(=)).*",
							"title": "Dialog",
							"$ref": "#/definitions/Microsoft.IDialog"
						},
						{
							"$ref": "#/definitions/equalsExpression",
							"examples": [
								"=settings.dialogId"
							]
						}
					],
					"title": "Dialog name",
					"description": "Name of the dialog to call."
				},

Task Item

refs #3023

Screenshots

@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling 1c6a9c9 on lei9444:cache into 08b8579 on microsoft:master.

@coveralls
Copy link

coveralls commented May 13, 2020

Coverage Status

Coverage remained the same at 0.0% when pulling 47d48b6 on lei9444:cache into ab5cc0c on microsoft:master.

boydc2014
boydc2014 previously approved these changes May 13, 2020
@boydc2014 boydc2014 added the Approved to merge approved, waiting to be merged label May 13, 2020
Copy link
Contributor

@a-b-r-o-w-n a-b-r-o-w-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to look into this a bit further this morning and add some unit tests. This change seems fine to me, but I'd like to understand why.

@boydc2014
Copy link
Contributor

I'm going to look into this a bit further this morning and add some unit tests. This change seems fine to me, but I'd like to understand why.

The issue is the dereference code will hit a circle once the defCache has value for certain key (which only happens the second time, we try to dereference on on exiting cache), this fix is just to clear the cache, so everytime it's a new cache and won't hit cirle.

@boydc2014
Copy link
Contributor

I'm going to look into this a bit further this morning and add some unit tests. This change seems fine to me, but I'd like to understand why.

Seems like leilei added a few logs in above, it's pretty much the IDialog causing the circle.

* if def is found in cache, do not attempt to dereference
* make a per-instance cache
* check for a circular ref when initially resolving
@cwhitten cwhitten merged commit c0ed9af into microsoft:master May 13, 2020
@lei9444 lei9444 deleted the cache branch May 21, 2020 07:04
lei9444 added a commit to lei9444/BotFramework-Composer-1 that referenced this pull request Jun 15, 2021
* fix: Maximum call stack size exceeded when open a bot

* use clear

* extract schema utils and add tests

* if def is found in cache, do not attempt to dereference
* make a per-instance cache
* check for a circular ref when initially resolving

* only process the schema once per project

Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Approved to merge approved, waiting to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants