Reputation: 6030
var xrr = __arglist(Convert.ToUInt32(1),
Convert.ToUInt32(2),
Convert.ToUInt32(3));
The above code would make the compiler crash on build. I would expect the compiler to stop with a meaningful error-message, instead of trying to compile the code. Could it be a bug in the compiler? If not, how can I solve this error?
Upvotes: 10
Views: 451
Reputation: 46008
Looks like an issue with Visual Studio, not compiler:
VS2010
System.AccessViolationException
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source
Microsoft.VisualStudio.CSharp.Services.Language
Stack Trace
at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.CompilerIDEInterop.Compilation_CompileMethod(Handle handle, Handle baseNodeOwner, IntPtr baseNodePtr, Handle& treeHandle)
at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.CompileMethod(ParseTreeNode node)
at Microsoft.RestrictedUsage.CSharp.Compiler.IDE.IDECompilation.CompileMethod(MethodBaseNode method)
at Microsoft.RestrictedUsage.CSharp.Semantics.SemanticParseTreeVisitor.<>c__DisplayClassc.<DispatchMethodBody>b__a()
at Microsoft.RestrictedUsage.CSharp.Extensions.ExpressionTreeFinder.get_ExpressionTree()
at Microsoft.RestrictedUsage.CSharp.Extensions.CompilationExtensions.FindExpressionTree(Compilation compilation, SourceFile sourceFile, ParseTreeNode leafNode)
at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.GetUniqueLocals(CSharpMemberReference member, ParseTreeNode node, SourceLocation loc, Dictionary`2 dictionary)
at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.GetUniqueLocals(Dictionary`2 locals)
at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.GetMemberChildren()
at Microsoft.VisualStudio.Labs.MemberContainsProvider.MemberContainsItemsSource.InitializeItemCollection()
at Microsoft.VisualStudio.Labs.ItemsSource`2.InitializeItems()
at Microsoft.VisualStudio.Labs.ItemsSource`2.get_Items()
at Microsoft.VisualStudio.Labs.AggregateItemsSource.InitializeItemCollection()
at Microsoft.VisualStudio.Labs.ItemsSource`2.InitializeItems()
at Microsoft.VisualStudio.Labs.ItemsSource`2.get_Items()
at Microsoft.VisualStudio.Labs.BrowserNavigationEntry.GetTree(String relationship, Func`2 treeActivator)
at Microsoft.VisualStudio.Labs.Browser.OnSelectedRelationshipChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Microsoft.VisualStudio.Labs.Browser.OnCurrentNavigationEntryChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyPropertyKey key, Object value)
at Microsoft.VisualStudio.Labs.Browser.NavigateTo(Object root, IRelationship relationship)
at Microsoft.VisualStudio.Labs.Browser.NavigateTo(Object root)
at Microsoft.VisualStudio.Labs.TextViewCreationListener.TextViewSinkManager.TextViewSink.RenderSelectionPopup(Object item, PopupType popupType)
at Microsoft.VisualStudio.Labs.TextViewCreationListener.TextViewSinkManager.TextViewSink.PotentiallyShowCSharpPopup(CSharpTextSelection activeSelection, PopupType popupType)
at Microsoft.VisualStudio.Labs.TextViewCreationListener.TextViewSinkManager.TextViewSink.textView_MouseHover(Object sender, MouseHoverEventArgs e)
at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.RaiseHoverEvents()
at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.OnHoverTimer(Object sender, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
Upvotes: 4
Reputation: 887479
That is not a bug in the compiler; the compiler gives a proper error message.
Instead, this is a bug in Visual Studio's editor language service, which causes Visual Studio to crash.
However, your code is illegal anyway; __arglist(...)
expressions can only be used to call a function that takes an __arglist
.
Upvotes: 6