locked
Field signatures in StandaloneSig table

    Question

  • I have encountered the following problem while writing a .NET module parser:

     

    Despite the fact that ECMA 335 claims that the StandaloneSig table is only used for local variable and method signatures, I have also encountered Field signatures referenced by this table.

    I was not able to figure out, wheter these rows are actually used anywhere in the module. Is this a bug in the implementation of the metadata emitter or some undocumented feature?

     

    Thanks. Markus

    Thursday, October 04, 2007 8:05 AM

Answers

  • Hello Markus,

     

    I am the owner of MetaData APIs and their implementation in CLR. I think there is no usage for Field signatures in StandaloneSig table.

    I don't think it is a bug in MetaData emitter in CLR - MetaData Emit API don't look into signatures compilers are emitting. My guess is that the image containing this Field signatures is either corrupted or was produced with a buggy compiler. Do you know where the image comes from? Do you know which compiler was used to create it? Do you have a small repro to create such image with a compiler?

     

    Thanks,

    -Karel

    Thursday, October 04, 2007 6:04 PM
    Moderator
  • Mello Markus,

     

    sorry for late response. It took me some time to track down the source of this issue.

    It turns out that even a simple empty Managed C++ application contains the field entries in StandAloneSig table. I tracked it down to its source in mstartup.obj in MSVCMRT.lib (%ProgFiles%\Microsoft Visual Studio 8\VC\LIB directory). Metadata of mstartup.obj are merged into the result exe file.

    I will follow up with CRT/Managed C++ compiler teams to find out if the field signatures are bogus or if it is a specific Managed C++ feature (it might take several more days).

     

    Thanks,

    -Karel

    Tuesday, October 09, 2007 11:11 PM
    Moderator

All replies

  • Hi Markus,

    That's interesting.  I agree that this would appear to be invalid according to the ECMA spec.  Specifically II.22.36 (4th ed) says: "The signature 'blob' indexed by Signature shall be a valid METHOD or LOCALS signature [ERROR]".  I also checked my copy of the annotated standard to see if Jim Miller had any Microsoft-specific notes around this table, but there aren't any.

     

    Can you give me more details about the scenarios in which you see this?  Specifically, I'm wondering who is producing this metadata.  A simple repro would be ideal if you can give it to me.  I think the metadata emitter isn't designed to validate all the rules, so it's more likely to be a bug in whoever is using the emitter (eg., I've seen bugs in the C# compiler in the past with producing technically invalid metadata which in most cases works fine anyway).

     

    Thanks,

      Rick

     

    Thursday, October 04, 2007 5:56 PM
    Owner
  • Hello Markus,

     

    I am the owner of MetaData APIs and their implementation in CLR. I think there is no usage for Field signatures in StandaloneSig table.

    I don't think it is a bug in MetaData emitter in CLR - MetaData Emit API don't look into signatures compilers are emitting. My guess is that the image containing this Field signatures is either corrupted or was produced with a buggy compiler. Do you know where the image comes from? Do you know which compiler was used to create it? Do you have a small repro to create such image with a compiler?

     

    Thanks,

    -Karel

    Thursday, October 04, 2007 6:04 PM
    Moderator
  • Hello Rick, Hello Karel,

     

    The smallest example I have found by quickly scanning through .NET 2.0 is Microsoft.VisualC.Dll.

     

    It contains 12 rows in the StandaloneSig table, 11 of which point to Field Signatures.

    Friday, October 05, 2007 7:05 AM
  • Mello Markus,

     

    sorry for late response. It took me some time to track down the source of this issue.

    It turns out that even a simple empty Managed C++ application contains the field entries in StandAloneSig table. I tracked it down to its source in mstartup.obj in MSVCMRT.lib (%ProgFiles%\Microsoft Visual Studio 8\VC\LIB directory). Metadata of mstartup.obj are merged into the result exe file.

    I will follow up with CRT/Managed C++ compiler teams to find out if the field signatures are bogus or if it is a specific Managed C++ feature (it might take several more days).

     

    Thanks,

    -Karel

    Tuesday, October 09, 2007 11:11 PM
    Moderator
  • Thank you Karel for all the investigation.
    For now I am satisfied to assume that the signatures are probably bogus and can be ignored.

    Markus
    Friday, October 12, 2007 1:04 PM