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

Submitter:  Marcus Urban <mathpup>
Submitted:  Sat 03 Jul 2004 09:49:14 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

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

fixed in cvs

Richard Baumann <Rich333>
Group 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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

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

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 5 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-07-07 Rich333 StatusNone Fixed
    Open/ClosedOpen Closed
2004-07-03 leppie Attached File- Added leppie-040704.patch, #1458
2004-07-03 mathpup Attached File- Added test.cs, #1457
2004-07-03 mathpup Attached File- Added test.c, #1456

Back to the top

Powered by Savane 3.12