harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Catherine Hope (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-6315) [classlib][nio] FileChannel.map throws IOException when called with size 0
Date Mon, 24 Aug 2009 11:04:59 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Catherine Hope updated HARMONY-6315:
------------------------------------

    Attachment: 6315-patch.txt

Problem also occurs on Windows platform so I've made the change in the Java file before the
native call - calling org.apache.harmony.luni.platform.OSMemory.mmap will return 0 if the
size requested to map is 0.

Patch includes a new test to MappedByteBufferTest and some error handling to OSMemoryLinux32.c

The fix applies to Java 6 also.

> [classlib][nio] FileChannel.map throws IOException when called with size 0
> --------------------------------------------------------------------------
>
>                 Key: HARMONY-6315
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6315
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Unix
>            Reporter: Catherine Hope
>         Attachments: 6315-patch.txt
>
>
> Creating a MappedByteBuffer by calling FileChannel.map with size 0 throws an IOException,
as the native call to mmap will fail with invalid argument when called with size 0.  Also
the IOException is thrown without any message from the Java after the native has returned
with -1, which isn't ideal.  On IBM and Sun Java a MappedByteBuffer is constructed with 0
capacity.
> The stack trace of the error is:
> java.io.IOException: Call to mmap failed with error 22: Invalid argument
> 	at org.apache.harmony.luni.platform.OSMemory.mmap(OSMemory.java:547) /* after calling
OSMemoryLinux32.c which calls mmap */ 
> 	at org.apache.harmony.luni.platform.PlatformAddressFactory.allocMap(PlatformAddressFactory.java:37)
/* returns a PlatformAddress of where the map is */
> 	at org.apache.harmony.nio.internal.FileChannelImpl.mapImpl(FileChannelImpl.java:191)
/* creates PlatformAddress, which is passed to MappedByteBuffer constructor */
> 	at org.apache.harmony.nio.internal.ReadOnlyFileChannel.map(ReadOnlyFileChannel.java:89)
> 	at org.apache.harmony.nio.tests.java.nio.MappedByteBufferTest.testEmptyBuffer(MappedByteBufferTest.java:70)
> I think where to fix this is the native function, and return a dummy long address, as
the implementation of the MappedByteBuffer constructor (in my testcase this is a ReadOnlyDirectByteBuffer)
requires a PlatformAddress.

-- 
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