POSIX doesn't state that if mmap() is given only PROT_WRITE, then
that memory region will have read access too. It's an implementation
issue of the platform.

On a platform which don't imply read access when only PROT_WRITE is given,
such a situation happens:
  1) a child process decrements the semaphore with sem_wait(sem)
  2) then tries to dereference create_cnt via (*create_cnt)++. This
     will result in a SIGSEGV, and the child will be terminated.

Therefore the semaphore will be left in a "decremented" state and this
test case will hang.

To overcome this problem we should explicitly pass PROT_READ to mmap().

Signed-off-by: Stanislav Kholmanskikh <[email protected]>
---
 .../conformance/interfaces/shm_open/23-1.c         |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/shm_open/23-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/shm_open/23-1.c
index 40d7a19..7a82f88 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/shm_open/23-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/shm_open/23-1.c
@@ -105,7 +105,7 @@ int main(void)
                return PTS_UNRESOLVED;
        }
 
-       create_cnt = mmap(NULL, sizeof(*create_cnt), PROT_WRITE,
+       create_cnt = mmap(NULL, sizeof(*create_cnt), PROT_WRITE | PROT_READ,
                          MAP_SHARED, result_fd, 0);
        if (create_cnt == MAP_FAILED) {
                perror("An error occurs when calling mmap()");
-- 
1.7.1


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to