Skip to content

Internal compiler error when creating Portable PDB files for source files with very long lines #3866

@praeclarum

Description

@praeclarum

When compiling code with long source lines and generating debug symbols, the F# compiler complains:

error FS0193 : internal error : Specified argument was out of the range of valid values.Parameter name: value

From the error log it looks like the PDB writer is failing to write some Int32 or UInt32 values.

This was originally reported here: https://bugzilla.xamarin.com/show_bug.cgi?id=60467

Repro steps

Provide the steps required to reproduce the problem

  1. Create a complex app in F#

  2. Compile it with Portable PDB symbols

Expected behavior

Compilation succeeds.

Actual behavior

Compiler fails with:

    error FS0193 : internal error : Specified argument was out of the range of valid values.Parameter name: value
    
    Unhandled Exception:
    System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: value
      at System.Reflection.Throw.ValueArgumentOutOfRange () [0x00000] in <6e996dbb3f9b4d42bb708be9f37ced22>:0 
      at System.Reflection.Metadata.BlobWriterImpl.WriteCompressedInteger (System.Reflection.Metadata.BlobBuilder writer, System.UInt32 value) [0x0003b] in <6e996dbb3f9b4d42bb708be9f37ced22>:0 
      at System.Reflection.Metadata.BlobBuilder.WriteCompressedInteger (System.Int32 value) [0x00000] in <6e996dbb3f9b4d42bb708be9f37ced22>:0 
      at Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter.generatePortablePdb$cont@341 (Microsoft.FSharp.Compiler.AbstractIL.IL+ILSourceDocument[] docs, System.Reflection.Metadata.Ecma335.MetadataBuilder metadata, System.Collections.Generic.Dictionary`2[TKey,TValue] documentIndex, Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter+PdbSequencePoint[] sps, System.Reflection.Metadata.BlobBuilder builder, Microsoft.FSharp.Core.Unit unitVar) [0x0018f] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter.f@1-13 (Microsoft.FSharp.Compiler.AbstractIL.IL+ILSourceDocument[] docs, System.Reflection.Metadata.Ecma335.MetadataBuilder metadata, System.Collections.Generic.Dictionary`2[TKey,TValue] documentIndex, Microsoft.FSharp.Core.FSharpRef`1[T] lastLocalVariableHandle, Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter+PdbMethodData minfo) [0x00075] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter.generatePortablePdb (System.Boolean embedAllSource, Microsoft.FSharp.Collections.FSharpList`1[T] embedSourceList, System.String sourceLink, System.Boolean showTimes, Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter+PdbData info, System.Boolean isDeterministic) [0x002a5] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter.writeBinaryAndReportMappings (System.String outfile, Microsoft.FSharp.Compiler.AbstractIL.IL+ILGlobals ilg, Microsoft.FSharp.Core.FSharpOption`1[T] pdbfile, Microsoft.FSharp.Core.FSharpOption`1[T] signer, System.Boolean portablePDB, System.Boolean embeddedPDB, System.Boolean embedAllSource, Microsoft.FSharp.Collections.FSharpList`1[T] embedSourceList, System.String sourceLink, System.Boolean emitTailcalls, System.Boolean deterministic, System.Boolean showTimes, System.Boolean dumpDebugInfo, Microsoft.FSharp.Compiler.AbstractIL.IL+ILModuleDef modul) [0x019b3] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter.WriteILBinary (System.String filename, Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter+options options, Microsoft.FSharp.Compiler.AbstractIL.IL+ILModuleDef input) [0x00001] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.Driver.main4[a] (Microsoft.FSharp.Core.FSharpOption`1[T] dynamicAssemblyCreator, Microsoft.FSharp.Compiler.Driver+Args`1[T] _arg1) [0x00189] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.Driver.main4[a] (Microsoft.FSharp.Core.FSharpOption`1[T] dynamicAssemblyCreator, Microsoft.FSharp.Compiler.Driver+Args`1[T] _arg1) [0x001ae] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, System.String[] argv, Microsoft.FSharp.Compiler.ReferenceResolver+Resolver legacyReferenceResolver, System.Boolean bannerAlreadyPrinted, System.Boolean openBinariesInMemory, System.Boolean defaultCopyFSharpCore, Microsoft.FSharp.Compiler.ErrorLogger+Exiter exiter, Microsoft.FSharp.Compiler.Driver+ErrorLoggerProvider loggerProvider, Microsoft.FSharp.Core.FSharpOption`1[T] tcImportsCapture, Microsoft.FSharp.Core.FSharpOption`1[T] dynamicAssemblyCreator) [0x00039] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.Driver.mainCompile (Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+CompilationThreadToken ctok, System.String[] argv, Microsoft.FSharp.Compiler.ReferenceResolver+Resolver legacyReferenceResolver, System.Boolean bannerAlreadyPrinted, System.Boolean openBinariesInMemory, System.Boolean defaultCopyFSharpCore, Microsoft.FSharp.Compiler.ErrorLogger+Exiter exiter, Microsoft.FSharp.Compiler.Driver+ErrorLoggerProvider loggerProvider, Microsoft.FSharp.Core.FSharpOption`1[T] tcImportsCapture, Microsoft.FSharp.Core.FSharpOption`1[T] dynamicAssemblyCreator) [0x00001] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.CommandLineMain+Driver.main (System.String[] argv) [0x0003e] in <59c44fc0c960099ba7450383c04fc459>:0 
      at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00042] in <59c44fc0c960099ba7450383c04fc459>:0 
      at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x000d2] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.ErrorLogger.errorRecovery (System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00006] in <59c44fb6f1806346a7450383b64fc459>:0 
      at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00056] in <59c44fc0c960099ba7450383c04fc459>:0 

Known workarounds

If I disable debugging information, compilation succeeds.

Metadata

Metadata

Assignees

Labels

Area-Debugstepping, debug points, stacks and moreBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions