Bug 66435 - APR_USE_SHMEM_MMAP_SHM fails on AIX
Summary: APR_USE_SHMEM_MMAP_SHM fails on AIX
Status: NEW
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: HEAD
Hardware: PC AIX
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-20 00:26 UTC by Eric Covener
Modified: 2023-01-20 13:28 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Covener 2023-01-20 00:26:58 UTC
The portable for for SHM shared memory is: shm_open, ftruncate, mmap.

In APR, apr_file_truncate is used for ftruncate, but it introduces an lseek() that fails on at least AIX. 

AIX lseek manual:

       If the FileDescriptor parameter refers to a shared memory
object, the lseek subroutine fails with EINVAL.

...

       EINVAL
            The resulting offset would be greater than the maximum
offset allowed for the file or device associated with FileDescriptor.
The lseek subroutine was used with a file
            descriptor obtained from a call to the shm_open subroutine.

For now, the decision to prefer APR_USE_SHMEM_MMAP_SHM is overridden in configure.in, but ideally it would work on AIX and somehow forego or ignore the lseek error.
Comment 1 Joe Orton 2023-01-20 09:36:07 UTC
It looks unnecessary to use an apr_file_t wrapper there at all, how about:
https://github.com/apache/apr/pull/38 

?
Comment 2 Eric Covener 2023-01-20 13:28:05 UTC
(In reply to Joe Orton from comment #1)
> It looks unnecessary to use an apr_file_t wrapper there at all, how about:
> https://github.com/apache/apr/pull/38 


looks simpler and maybe saves another unknown platform. Works for me w/ the configure.in override removed.