bugDotGNU Portable.NET - Bugs: bug #9542, GCHandle.AddrOfPinnedObject gives...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #9542: GCHandle.AddrOfPinnedObject gives incorrect address for arrays

Submitted by:  Marcus Urban <mathpup>
Submitted on:  Sat 03 Jul 2004 09:49:14 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Wed 07 Jul 2004 10:27:55 PM UTC, comment #2:

fixed in cvs

Richard Baumann <Rich333>
Project Member
Sat 03 Jul 2004 11:08:30 PM UTC, comment #1:

Here's a patch to resolve. I'm no sure if that will break something else...

Summary:

Added to pnet/engine/lib_gc.c in _IL_GCHandle_GCAddrOfPinnedObject:

The ILObject needs to be checked whether its an array so the "real" buffer can be passed.

object = GetObjectFromGcBase(ptr);
if (_ILIsSArray((System_Array *)object))
{
object = ((void )(((System_Array )(object)) + 1));
}

Output:
$ ilrun test.exe
270700556 270700556
size of array[x]: 1
==> array(1982) = 1
==> array(1983) = 2

Llewellyn Pritchard <leppie>
Project Member
Sat 03 Jul 2004 09:49:14 PM UTC, original submission:

When a GCHandle with GCHandleType.Pinned is created, it should be possible to obtain the address of the object with GCHandle.AddrOfPinnedObject(). When the object in question is an array, Pnet appears to return a pointer to some header information that preceeds the actual appear data. However, Rotor returns a pointer to the first element of the array. Note in the output samples below that element 1 is incorrect and that the array indexes are offset.

To compile the test cases, use

1. gcc -shared -o libtest.so test.c
2. cscc -o test.exe test.cs
3. ilrun test.exe

Output from ilrun:

136372232 136372232
size of array[x]: 1
==> array(1) = 48
==> array(1986) = 1
==> array(1987) = 2

Output from Rotor:

1093363496 1093363496
size of array[x]: 1
==> array(1982) = 1
==> array(1983) = 2

Marcus Urban <mathpup>

 

Attached Files
file #1465:  leppie-040704.patch added by leppie (32KiB - application/octet-stream)
file #1464:  test.cs added by mathpup (510B - text/x-csharp - Test case (C# component))
file #1463:  test.c added by mathpup (345B - text/x-csrc - Test case (C component))

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 5 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Wed 07 Jul 2004 10:27:55 PM UTCRich333StatusNone=>Fixed
  Open/ClosedOpen=>Closed
Sat 03 Jul 2004 11:08:30 PM UTCleppieAttached File-=>Added leppie-040704.patch, #1458
Sat 03 Jul 2004 09:50:13 PM UTCmathpupAttached File-=>Added test.cs, #1457
Sat 03 Jul 2004 09:49:15 PM UTCmathpupAttached File-=>Added test.c, #1456

Back to the top


Powered by Savane 3.1-cleanup1