EWSoftware / SHFB

Sandcastle Help File Builder (SHFB). A standalone GUI, Visual Studio integration package, and MSBuild tasks providing full configuration and extensibility for building help files with the Sandcastle tools.
Other
2.19k stars 367 forks source link

Stack overflow exception when building project on 2019.3.31 release #691

Closed JohnTenney closed 5 years ago

JohnTenney commented 5 years ago

Here's what I saw running a build that has succeeded in the past many times. It happens in the VS2017 and VS2019 plugins and in the standalone app. I reverted to the v2018.7.8.0 release, and it is working again.


[Sandcastle Help File Builder and Tools, version 2019.3.31.0] Creating output and working folders... Finding tools... The Sandcastle tools are located in 'C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\' Searching for HTML Help 1 compiler... Found HTML Help 1 compiler in 'C:\Program Files (x86)\HTML Help Workshop\' Locating components in the following folder(s): D:\johnt\CAS\Applications\Cas_LIve Documentation C:\ProgramData\EWSoftware\Sandcastle Help File Builder\Components and Plug-Ins\ C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\ Using framework reflection data for '.NET Framework 4.7.2' located in 'C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\Data.NETFramework' Using presentation style 'VS2013' located in 'C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\PresentationStyles\VS2013' Loading and initializing plug-ins... Lightweight Website Style Version 2019.3.31.0 Copyright © 2006-2019, Eric Woodruff, All Rights Reserved Portions Copyright © 2014, Sam Harwell, All Rights Reserved

Clearing working folder...

Validating and copying documentation source information Source: D:\johnt\CAS\CellAnalysisSuite\Core.csproj Found project 'D:\johnt\CAS\CellAnalysisSuite\Core.csproj'

Parsing project files Found assembly 'D:\johnt\CAS\CellAnalysisSuite\bin\Debug\CellAnalysisSuite.Core.dll'

References to include (excluding framework assemblies): Clipper_Library Emgu.CV.World Interop.SPIIPLUSCOM660Lib IronPython, Version=2.7.8.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL IronPython.Modules, Version=2.7.8.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL Microsoft.Dynamic, Version=1.2.0.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL Microsoft.Scripting, Version=1.2.0.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL Ookii.Dialogs Ookii.Dialogs.Wpf OxyPlot OxyPlot.WindowsForms, Version=0.0.1.0, Culture=neutral, PublicKeyToken=245eacd6b5d2d338, processorArchitecture=MSIL OxyPlot.Wpf Prism, Version=6.3.0.0, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL Prism.Wpf, Version=6.3.0.0, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL PythonControls, Version=1.0.17.23860, Culture=neutral, processorArchitecture=MSIL System.Data.SQLite, Version=1.0.98.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL Xceed.Wpf.Toolkit, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL ZedGraph SHFB: Warning BE0062: No documentation source XML comments files found. The help file will not contain any member comments.

Generating shared content files (en-US, English (United States))... Last step completed in 00:00:00.0313

Generating API filter for MRefBuilder... Last step completed in 00:00:00.0156

Generating reflection information... [C:\Program Files (x86)\MSBuild\14.0\bin\amd64\MSBuild.exe - GenerateRefInfo.proj] Build started 4/4/2019 8:30:40 AM. Project "D:\johnt\CAS\Applications\Cas_LIve Documentation\Help\Working\GenerateRefInfo.proj" on node 1 (default targets). PrepareForBuild: Creating directory "obj\Debug\". GenerateRefInfo: MRefBuilder (v2019.3.31.0) Copyright c 2006-2019, Microsoft Corporation, All Rights Reserved. Portions Copyright c 2006-2019, Eric Woodruff, All Rights Reserved. No source code context base path specified. Source context information is unavailable. Loaded 1 assemblies for reflection and 124 dependency assemblies. Using automatic redirect 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in place of 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Using automatic redirect 'System.ObjectModel, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.ObjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Using automatic redirect 'System.Drawing.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Process is terminated due to StackOverflowException.

dwhearn commented 5 years ago

I am also seeing this error after upgrading from the 2018.12.10.0 version in one of our projects. Other projects build without error.

EWSoftware commented 5 years ago

If your projects aren't using the Cross-Platform option for the Framework Version, try that. @dwhearn: Do upgrade to the latest release as changes were made to try and address this issue.

If the problem isn't resolved, can either or both of you supply examples? Fair warning though. I have yet to successfully reproduce the issue. It seems to be related to the version of Visual Studio and/or the SDKs, or something that I cannot seem to replicate.

JohnTenney commented 5 years ago

Same thing occurred with Cross-Platform option. Tough to provide an example, though.

17> Removing build files... 17> Removing build folders... 17> Building D:\johnt\CAS\Applications\Cas_LIve Documentation\Cas_Live Documentation.shfbproj 17> Initializing 17> ValidatingDocumentationSources 17> GenerateSharedContent 17> GenerateApiFilter 17> GenerateReflectionInfo 17>SHFB(0,0): error BE0065: BUILD FAILED: Unexpected error detected in last build step. See build log for details. 17> Failed 17> Build details can be found in D:\johnt\CAS\Applications\Cas_LIve Documentation\Help\LastBuild.log 17>Done building project "Cas_Live Documentation.shfbproj" -- FAILED.

dwhearn commented 5 years ago

The project is pulling in Sandcastle from the NuGet packages. If I use the 2018.12.10 package, the project builds. If I use the 2019.3.31 package it fails. I also have Visual Studio 2019 installed, but I don't think that matters. I am attaching the log files from each of these builds. 2018.12.10 LastBuild.log 2019.3.31 LastBuild.log

EWSoftware commented 5 years ago

I can see that it's using incorrect assemblies in the auto-redirects but I need an example that I can try to duplicate the problem with in order to fix it properly. Otherwise, I'm just guessing as to whether that's the actual cause and that it fixes it.

EWSoftware commented 5 years ago

I've published a new release (v2019.4.7.0) that fixes the incorrect auto-redirects. Whether that fixes the stack overflow exception, I can't say for sure. If it doesn't I will need and example in order to see if I can duplicate it.

JohnTenney commented 5 years ago

Thanks, Eric! I got it to work, but still had to tweak the binding redirects as described at https://stackoverflow.com/questions/47791178/sandcastle-help-file-builder-and-tools-error-unresolved-assembly-reference

This is the LastBuild.txt I get before tweaking the redirects: EW.txt

EWSoftware commented 5 years ago

@JohnTenney You might try switching back to the .NET 4.7.2 framework version to see if that works now. That might take care of the mscorlib reference issue.

dwhearn commented 5 years ago

I no longer see the stack overflow exception after upgrading to the v2019.4.7.0 version. Thanks for resolving the issue so quickly!

kelly987654 commented 5 years ago

I was seeing this StackOverflow exception after updating to v2019.3.31.0 (everything was working on 2018.7.8.0, but I had to update for VS 2019 compatibility). After updating to v2019.4.7.0, I no longer see the StackOverflow exception, however I now see a System.AccessViolationException.

When I remove one project from the documentation sources, the build works. This project has some custom attributes, which seem to be mentioned GetCustomAttribute call in the stack trace.

Any idea on what could cause this? Thanks!

`GenerateRefInfo:
  MRefBuilder (v2019.4.7.0)
  Copyright c 2006-2019, Microsoft Corporation, All Rights Reserved.
  Portions Copyright c 2006-2019, Eric Woodruff, All Rights Reserved.
  No source code context base path specified.  Source context information is unavailable.
  Loaded 5 assemblies for reflection and 105 dependency assemblies.
  Using automatic redirect 'System.Diagnostics.Debug, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Diagnostics.Debug, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Xml.XDocument, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Xml.XDocument, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Reflection, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Collections, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Runtime.Extensions, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Globalization, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Xml.XmlSerializer, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Xml.XmlSerializer, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.IO, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Xml.ReaderWriter, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Xml.ReaderWriter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.Runtime.Serialization.Primitives, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.Runtime.Serialization.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  Using automatic redirect 'System.ObjectModel, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in place of 'System.ObjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Compiler.Metadata.MemoryCursor.ReadUTF8(Int32 bytesToRead)
   at System.Compiler.Metadata.Reader.GetCustomAttributeLiteralValue(MemoryCursor sigReader, TypeNode& type)
   at System.Compiler.Metadata.Reader.GetCustomAttribute(Method cons, MemoryCursor sigReader, Int32 blobLength)
   at System.Compiler.Metadata.Reader.GetCustomAttribute(Int32 i)
   at System.Compiler.Metadata.Reader.GetCustomAttributesFor(Int32 parentIndex)
   at System.Compiler.Metadata.Reader.GetTypeAttributes(TypeNode type, Object handle)
   at System.Compiler.TypeNode.get_Attributes()
   at Microsoft.Ddue.Tools.Reflection.ApiFilter.IsExposedType(TypeNode type)
   at Microsoft.Ddue.Tools.ManagedReflectionWriter.VisitNamespaces(NamespaceList spaces)
   at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitApis()
   at Microsoft.Ddue.Tools.MRefBuilderCore.Main(String[] args)
   at Microsoft.Ddue.Tools.MSBuild.MRefBuilder.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
   at Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__24.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(TaskLoggingContext taskLoggingContext, ItemBucket bucket, IDictionary`2 taskIdentityParameters, TaskHost taskHost, TaskExecutionMode howToExecuteTask)
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteBucket>d__19.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Dictionary`2 lookupHash)
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__18.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TaskExecutionMode mode, Lookup lookup)
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__13.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TargetLoggingContext loggingContext, BuildRequestEntry requestEntry, ITargetBuilderCallback targetBuilderCallback, ProjectTargetInstanceChild taskInstance, TaskExecutionMode mode, Lookup inferLookup, Lookup executeLookup, CancellationToken cancellationToken)
   at Microsoft.Build.BackEnd.TargetEntry.<ProcessBucket>d__51.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(ITaskBuilder taskBuilder, TargetLoggingContext targetLoggingContext, TaskExecutionMode mode, Lookup lookupForInference, Lookup lookupForExecution)
   at Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__44.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(ITaskBuilder taskBuilder, BuildRequestEntry requestEntry, ProjectLoggingContext projectLoggingContext, CancellationToken cancellationToken)
   at Microsoft.Build.BackEnd.TargetBuilder.<ProcessTargetStack>d__21.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(ITaskBuilder taskBuilder)
   at Microsoft.Build.BackEnd.TargetBuilder.<BuildTargets>d__10.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, String[] targetNames, Lookup baseLookup, CancellationToken cancellationToken)
   at Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__58.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.RequestBuilder.BuildProject()
   at Microsoft.Build.BackEnd.RequestBuilder.<BuildAndReport>d__50.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport()
   at Microsoft.Build.BackEnd.RequestBuilder.<RequestThreadProc>d__49.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc(Boolean setThreadParameters)
   at Microsoft.Build.BackEnd.RequestBuilder.<StartBuilderThread>b__45_2()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.TaskScheduler.TryExecuteTask(Task task)
   at Microsoft.Build.BackEnd.RequestBuilder.DedicatedThreadsTaskScheduler.<InjectThread>b__6_0()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
    Last step completed in 00:00:32.6103
+Failed`
EWSoftware commented 5 years ago

@kelly987654 As noted above, I need an example that I can use to try and reproduce the problem.

kelly987654 commented 5 years ago

Hi Eric,

In this example solution, I have the main Sandcastle documentation project, and a Documentation.References project used suppress the ResolveReferenceLinks warnings for the third party assemblies. This Documentation.References project has references to Newtonsoft.Json.dll and a NetStandard project within the solution. If I remove either one, the build works, but if both are referenced, I get the System.AccessViolationException.

Thanks again for your help!

SandcastleIssueRepro.zip

EWSoftware commented 5 years ago

@kelly987654 This was related to #692 where it wasn't correctly redirecting mscorlib to netstandard when mixing .NET Standard and full .NET Framework assemblies in the same documentation project. A new release that fixes the issue will be available shortly.