Bug 5633 - Method on a base generic class does not let you use indexer of double pointer
Summary: Method on a base generic class does not let you use indexer of double pointer
Status: RESOLVED NORESPONSE
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-06-13 11:02 UTC by Jake Morgan
Modified: 2017-07-07 18:45 UTC (History)
4 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 NORESPONSE

Description Jake Morgan 2012-06-13 11:02:39 UTC
Scary bug. I was getting segfaults when using these unmanaged double byte pointers. Turns out when the method was defined on a generic base class, the JIT compiler completely ignores any indexing of the double byte pointer. Moving the base method to a base class that wasn't generic fixed the problem.

Visual Studio deleted my temp project, so I don't have the mock source I created, but here is the gist:

class BaseBaseClass<T>
{
  public void BaseBaseMethod(byte** test)
  {
    Console.WriteLine(test[0]);
    Console.WriteLine(test[1]); // WRONG this returns same address as test[0], even test[1000000] returns the same
  }
}

class BaseClass : BaseBaseClass<object>
{
  public void BaseMethod(byte** test)
  {
    Console.WriteLine(test[0]);
    Console.WriteLine(test[1]); // this works
  }
}

class MyClass : BaseClass
{
  public void MyMethod()
  {
    var test= stackalloc byte[10];
    test[0] = (byte*)(IntPtr)0;
    test[1] = (byte*)(IntPtr)1;

    this.BaseBaseMethod(test); // WRONG bad
    this.BaseMethod(test); // works
  }
}
Comment 1 Zoltan Varga 2012-06-14 17:48:17 UTC
Please attach a test case which compiles.
Comment 2 Zoltan Varga 2012-06-24 16:46:14 UTC
-> NEEDINFO.
Comment 3 Ludovic Henry 2017-07-07 18:45:42 UTC
If you can still reproduce with latest mono version, please feel free to reopen the bug. Thank you.