Bug 12113 - mono_method_desc_new() parsing '::' incorrectly
Summary: mono_method_desc_new() parsing '::' incorrectly
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Interop ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-05-06 06:29 UTC by Sean Hanna
Modified: 2013-05-06 11:07 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Sean Hanna 2013-05-06 06:29:35 UTC
it seems that the mono_method_desc_new() function in debug-helpers.h was intended to accept a '::' double-colon separator between class and method name by the comment /* allow two :: to separate the method name */

when parsing a method desc in this format however, the class name of the resulting method desc structure retains a trailing colon character, leading to lookup failures 

a simple repo tested on debian with an up-to-date build of mono compiled from git

// file methodDescParseError.c
// compile with gcc methodDescParseError.c `pkg-config --cflags --libs mono-2`
#include <mono/metadata/debug-helpers.h>
#include <string.h>

int main (int argc, const char *argv[]) {
  MonoMethodDesc *l_desc = mono_method_desc_new ("System.Object::GetHashCode()", 1);

  const char *l_classNameField = *(char**)(((char*)l_desc)+8);

  fprintf(stdout, "Parsed class name is %s\n", l_classNameField);

  // return success if class name does not contain any ':' characters
  if (!strchr(l_classNameField, ':')) {
    return 0;
  } else {
    return 1;
  }
}

solution seems simple too (/mono/metadata/debug-helpers.c:330)

/* allow two :: to separate the method name */
if (*method_name == ':')
//  method_name++;
    *method_name++ = 0;
Comment 1 Zoltan Varga 2013-05-06 11:07:31 UTC
Fixed in master (3f3092b4776a554abcf13f698a488adf749bba57), and 2.10 (f4239234a2af76dc1b1b288c4ef880e1351c7417).