harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ian Rogers (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6138) Implementation of hyvmem_reserve_memory in Windows is inconsistent with doc/UNIX
Date Fri, 03 Apr 2009 12:24:12 GMT
Implementation of hyvmem_reserve_memory in Windows is inconsistent with doc/UNIX
--------------------------------------------------------------------------------

                 Key: HARMONY-6138
                 URL: https://issues.apache.org/jira/browse/HARMONY-6138
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M8
         Environment: Harmony M8, Windows Vista 32bit
            Reporter: Ian Rogers


In Windows a call to hyvmem_reserve_memory with the default page size, rwx and commit, will
cause the memory to be committed and no reservation to take place. As such the call will fail
as the memory hasn't been reserved. The documentation says:

 * \arg HYPORT_VMEM_MEMORY_MODE_COMMIT commits memory as part of the reserve

However, a separate commit is necessary following a reserve (and the first reserve must clear
the commit flag). For example,

HyPortVmemIdentifier ident;
ident.pageSize = 4096;
ident.mode = HYPORT_VMEM_MEMORY_MODE_READ | HYPORT_VMEM_MEMORY_MODE_WRITE | HYPORT_VMEM_MEMORY_MODE_EXECUTE
| HYPORT_VMEM_MEMORY_MODE_COMMIT;
hyvmem_reserve_memory(..., baseAddr, 4096, &ident, ident.mode, ident.pageSize);

if baseAddr is varied then on Linux many reserve/commitable pages are found, but on Windows
only pages belonging to the application are found (as they are already reserved).

The offending code is:

  /* Handle default page size */
  if ((HYPORT_VMEM_PAGE_SIZE_DEFAULT == pageSize)
      || (PPG_vmem_pageSize[0] == pageSize))
    {
      DWORD allocationType;

      /* Determine if a commit is required */
      if (0 != (HYPORT_VMEM_MEMORY_MODE_COMMIT & mode))
        {
          allocationType = MEM_COMMIT;
        }
      else
        {
          /* 
           * If we don't reserve with PAGE_NOACCESS, CE won't give us large blocks. 
           * On Win32 the protection bits appear to be ignored for uncommitted memory. 
           */
          allocationType = MEM_RESERVE;
          protection = PAGE_NOACCESS;
        }

A simple fix may be to make "allocationType = MEM_COMMIT | MEM_RESERVE;" (that is at line
200 in /modules/portlib/src/main/native/port/windows/hyvmem.c ).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message