microsoft / RTVS

R Tools for Visual Studio.
MIT License
390 stars 111 forks source link

Assertion failed: children collection is sorted and yet no position to insert can be found #1541

Closed int19h closed 8 years ago

int19h commented 8 years ago

Happened while trying to reproduce #1268, when pasting the following code into REPL:

id <- 1:5
url <- paste0( "http://faxian.smzdm.com/mall/%E4%BA%AC%E4%B8%9C/p", id)
read_html(url[1], encoding = "UTF-8") %>% html_nodes("h2.itemName") %>% html_node("a") %>% html_node("span.black") %>% html_text() %>% repair_encoding(., from = "UTF_8")

image

Children collection is sorted and yet no position to insert can be found

at Microsoft.Languages.Core.Text.TextRangeCollection`1.AddSorted(T item) in C:\git\RTVS\src\Languages\Core\Impl\Text\TextRangeCollection.cs:line 134

at Microsoft.R.Core.AST.AstNode.AppendChild(IAstNode child) in C:\git\RTVS\src\R\Core\Impl\AST\AstNode.cs:line 64

at Microsoft.R.Core.AST.AstNode.set_Parent(IAstNode value) in C:\git\RTVS\src\R\Core\Impl\AST\AstNode.cs:line 45

at Microsoft.R.Core.AST.AstNode.AppendChild(IAstNode child) in C:\git\RTVS\src\R\Core\Impl\AST\AstNode.cs:line 56

at Microsoft.R.Core.AST.Expressions.Expression.MakeNode(ParseContext context) in C:\git\RTVS\src\R\Core\Impl\AST\Expressions\ExpressionParser.cs:line 541

at Microsoft.R.Core.AST.Expressions.Expression.ProcessHigherPrecendenceOperators(ParseContext context, IOperator currentOperator) in C:\git\RTVS\src\R\Core\Impl\AST\Expressions\ExpressionParser.cs:line 499

at Microsoft.R.Core.AST.Expressions.Expression.HandleOperatorPrecede......

int19h commented 8 years ago

Full stack:

    [Managed to Native Transition]  
    System.dll!Microsoft.Win32.SafeNativeMethods.MessageBox(System.IntPtr hWnd, string text, string caption, int type)  Unknown
    System.dll!System.Diagnostics.AssertWrapper.ShowMessageBoxAssert(string stackTrace, string message, string detailMessage)   Unknown
    System.dll!System.Diagnostics.DefaultTraceListener.Fail(string message, string detailMessage)   Unknown
    System.dll!System.Diagnostics.DefaultTraceListener.Fail(string message) Unknown
    System.dll!System.Diagnostics.TraceInternal.Fail(string message)    Unknown
    System.dll!System.Diagnostics.Debug.Assert(bool condition, string message)  Unknown
>   Microsoft.Languages.Core.dll!Microsoft.Languages.Core.Text.TextRangeCollection<Microsoft.R.Core.AST.Definitions.IAstNode>.AddSorted(Microsoft.R.Core.AST.Definitions.IAstNode item) Line 134    C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.AstNode.AppendChild(Microsoft.R.Core.AST.Definitions.IAstNode child) Line 64  C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.AstNode.Parent.set(Microsoft.R.Core.AST.Definitions.IAstNode value) Line 45   C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.AstNode.AppendChild(Microsoft.R.Core.AST.Definitions.IAstNode child) Line 56  C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Expressions.Expression.MakeNode(Microsoft.R.Core.Parser.ParseContext context) Line 541    C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Expressions.Expression.ProcessHigherPrecendenceOperators(Microsoft.R.Core.Parser.ParseContext context, Microsoft.R.Core.AST.Operators.Definitions.IOperator currentOperator) Line 499 C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Expressions.Expression.HandleOperatorPrecedence(Microsoft.R.Core.Parser.ParseContext context, Microsoft.R.Core.AST.Operators.Definitions.IOperator currentOperator) Line 472  C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Expressions.Expression.HandleOpenBrace(Microsoft.R.Core.Parser.ParseContext context, out Microsoft.R.Core.Parser.ParseErrorType errorType) Line 365   C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Expressions.Expression.ParseExpression(Microsoft.R.Core.Parser.ParseContext context) Line 96  C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Expressions.Expression.Parse(Microsoft.R.Core.Parser.ParseContext context, Microsoft.R.Core.AST.Definitions.IAstNode parent) Line 41  C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Statements.ExpressionStatement.Parse(Microsoft.R.Core.Parser.ParseContext context, Microsoft.R.Core.AST.Definitions.IAstNode parent) Line 31  C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.Scopes.Scope.Parse(Microsoft.R.Core.Parser.ParseContext context, Microsoft.R.Core.AST.Definitions.IAstNode parent) Line 85    C#
    Microsoft.R.Core.dll!Microsoft.R.Core.AST.AstRoot.Parse(Microsoft.R.Core.Parser.ParseContext context, Microsoft.R.Core.AST.Definitions.IAstNode parent) Line 85 C#
    Microsoft.R.Core.dll!Microsoft.R.Core.Parser.RParser.Parse(Microsoft.Languages.Core.Text.ITextProvider textProvider, Microsoft.Languages.Core.Text.ITextRange range) Line 33    C#
    Microsoft.R.Core.dll!Microsoft.R.Core.Parser.RParser.Parse(Microsoft.Languages.Core.Text.ITextProvider textProvider) Line 17    C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Tree.TextChangeProcessor.FullParse(Microsoft.R.Editor.Tree.EditorTreeChangeCollection changes, Microsoft.Languages.Core.Text.ITextProvider newSnapshot) Line 126  C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Tree.TreeUpdateTask.ProcessTextChanges(Microsoft.R.Editor.Tree.TextChange changeToProcess, bool async, System.Func<bool> isCancelledCallback) Line 410    C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Tree.TreeUpdateTask.ProcessPendingTextBufferChanges.AnonymousMethod__0(System.Func<bool> isCancelledCallback) Line 378    C#
    Microsoft.Languages.Editor.dll!Microsoft.Languages.Editor.Tasks.CancellableTask.Run.AnonymousMethod__0(object taskId) Line 74   C#
    mscorlib.dll!System.Threading.Tasks.Task.InnerInvoke()  Unknown
    mscorlib.dll!System.Threading.Tasks.Task.Execute()  Unknown
    mscorlib.dll!System.Threading.Tasks.Task.ExecutionContextCallback(object obj)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot)    Unknown
    mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution) Unknown
    mscorlib.dll!System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued)    Unknown
    mscorlib.dll!System.Threading.Tasks.TaskScheduler.TryRunInline(System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued)  Unknown
    mscorlib.dll!System.Threading.Tasks.Task.InternalRunSynchronously(System.Threading.Tasks.TaskScheduler scheduler, bool waitForCompletion)   Unknown
    mscorlib.dll!System.Threading.Tasks.Task.RunSynchronously() Unknown
    Microsoft.Languages.Editor.dll!Microsoft.Languages.Editor.Tasks.CancellableTask.Run(System.Action<System.Func<bool>> runAction, bool async) Line 79 C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Tree.TreeUpdateTask.ProcessPendingTextBufferChanges(Microsoft.Languages.Core.Text.ITextProvider newTextProvider, bool async) Line 378 C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Tree.TreeUpdateTask.ProcessPendingTextBufferChanges(bool async) Line 349  C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Tree.TreeUpdateTask.EnsureProcessingComplete() Line 494   C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Tree.EditorTree.EnsureTreeReady() Line 96 C#
    Microsoft.R.Editor.dll!Microsoft.R.Editor.Formatting.FormatOnPasteCommand.Invoke(System.Guid group, int id, object inputArg, ref object outputArg) Line 59  C#
    Microsoft.Languages.Editor.dll!Microsoft.Languages.Editor.Controller.Controller.Invoke(System.Guid group, int id, object inputArg, ref object outputArg) Line 49    C#
    Microsoft.Languages.Editor.dll!Microsoft.Languages.Editor.Controller.ViewController.Invoke(System.Guid group, int id, object inputArg, ref object outputArg) Line 106   C#
    Microsoft.VisualStudio.R.Package.dll!Microsoft.VisualStudio.R.Package.Repl.Commands.ReplCommandController.Invoke(System.Guid group, int id, object inputArg, ref object outputArg) Line 106 C#
    Microsoft.VisualStudio.R.Package.dll!Microsoft.VisualStudio.R.Package.Interop.CommandTargetToOleShim.Exec(ref System.Guid guidCommandGroup, uint commandID, uint commandExecOpt, System.IntPtr variantIn, System.IntPtr variantOut) Line 48 C#

Crash dump is also available if desired.

int19h commented 8 years ago

Seems to be a consistent repro for me - doesn't matter what else is in the REPL at the moment the snippet is pasted.

huguesv commented 8 years ago

I can repro too.

MikhailArkhipov commented 8 years ago

Simple repro

a() %>% b