Files
sbox-public/engine/Sandbox.Compiling/Compiler/Compiler.Generator.cs
Lorenz Junglas bc36ace71e Fix array pool use after free exploit (#4161)
* ! Reimplement SharedArrayPool because it is internal in .net runtime

* ! Expose PublicArrayPool that maps to our copy of SharedArrayPool

* ! CodeGenerator that remaps System.Buffers.ArrayPool.Shared calls to Sandbox.PublicArrayPool

* ! Don't run ArrayPoolUpgrader in full engine builds

* ! Add tests that verifies ArrayPool.Shared replacements

* ! Remove ArrayPool.Shared from whitelist

* ! Build AST from nodes instead of parsing text

* ! Use Reflection to grab Gen2GcCallback instead of event polling
2026-03-03 19:34:26 +00:00

42 lines
1009 B
C#

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
namespace Sandbox;
partial class Compiler
{
private Generator.Processor RunGenerators( CSharpCompilation compiler, List<SyntaxTree> syntaxTrees, CompilerOutput output )
{
var processor = new Generator.Processor()
{
AddonName = Name,
AddonFileMap = output.Archive.FileMap,
EnableCorelibPolyfills = _config.Whitelist
};
if ( Group.AllowFastHotload && incrementalState.HasState )
{
processor.Run( compiler, syntaxTrees, incrementalState.Compilation, incrementalState.PreHotloadSyntaxTrees );
}
else
{
processor.Run( compiler, syntaxTrees );
}
output.Diagnostics.AddRange( processor.Diagnostics );
// Error within code generation itself
if ( processor.Exception != null )
{
Log.Error( processor.Exception, "Error when generating code" );
Sentry.SentrySdk.CaptureException( processor.Exception, scope =>
{
scope.SetTag( "group", "generator" );
} );
}
return processor;
}
}