| Ivan,
Can you try and reproduce this on the latest 10.5.x instead of 10.4.x?
Thanks!
davez
On Mar 13, 2008, at 3:31 PM, Ivan Shcheklein wrote: Once again new details of this strange behaviour.
Here is complete and very simple "killing" application. And here (http://discussions.apple.com/thread....36846&tstart=0) this "bug" was confirmed on the similar system. Firstly you should run this one (and DO NOT perform exit from it):
========================================================= #include <stdio.h> #include <sys/mman.h> #include <sys/stat.h> #include <string.h> #include <sys/types.h> #include <fcntl.h>
#define SHM_NAME "/tmp/zeroSharedMemory" /* Shared memory name */ #define SHM_SIZE 0x10000 /* Shared memory region size in bytes (64Kb) */ /* Clean ups given shared memory object */ static inline void destroy_shared_memory(int shm_fd, const char* shm_name) { if(-1 == close(shm_fd)) { perror("close"); exit(-1); } if (-1 == shm_unlink(shm_name)) { perror("shm_unlink"); exit(-1); } }
/* Creates shared memory object, zeroing it and waiting any key to be inputted */ int main (int argc, const char * argv[]) { int shm_fd; //shared memory file descriptor void* shm_addr; //shared memory attach address
/* Create new shared memory object on filesystem */ shm_fd = shm_open(SHM_NAME, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); if(shm_fd == -1) { perror("shm_open"); return -1; }
/* Truncate to the defined size */ if (ftruncate(shm_fd, (off_t) SHM_SIZE) == -1) { perror("ftruncate"); destroy_shared_memory(shm_fd, SHM_NAME); return -1; }
/* mmap shared memory object into virtual address space */ shm_addr = mmap(NULL, (size_t)(SHM_SIZE), PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, (off_t)0);
if(shm_addr == MAP_FAILED) { perror("mmap"); destroy_shared_memory(shm_fd, SHM_NAME); return -1; }
/* Zeroing memory */ memset(shm_addr, 0, (size_t)SHM_SIZE);
/* Waiting until key pressed ... and perform cleanup */ printf("Press any key to perform cleanup and exit ...\n"); getchar(); destroy_shared_memory(shm_fd, SHM_NAME); return 0; } =========================================================
Now start this one:
========================================================= #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/stat.h> #include <string.h> #include <sys/types.h> #include <fcntl.h>
#define SHM_NAME "/tmp/zeroSharedMemory" /* Shared memory name */ #define SHM_SIZE 0x10000 /* Shared memory region size in bytes (64Kb) */ #define REGIONS_NUM 16000 /* mmap regions number */
/* Close shared memory object descriptor */ static inline void close_shared_memory(int shm_fd, const char* shm_name) { if(-1 == close(shm_fd)) { perror("close"); exit(-1); } }
/* Opens shared memory object, mmaps it REGIONS_NUM times, checks each header and exits */ int main (int argc, const char * argv[]) { int shm_fd; //shared memory file descriptor void* shm_addr[REGIONS_NUM]; //shared memory attach address(es) int i; //for iteration
/* Open shared memory object on filesystem */ shm_fd = shm_open(SHM_NAME, O_RDWR, 0); if(shm_fd == -1) { perror("shm_open"); return -1; }
/* mmap zero page of the shared memory object into virtual address space */ printf("Going to create initial mapping ..."); for(i = 0; i < REGIONS_NUM; i++) { shm_addr = mmap(NULL, (size_t)SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, (off_t) 0); if(MAP_FAILED == shm_addr) { perror("mmap"); close_shared_memory(shm_fd, SHM_NAME); return -1; } } printf(" OK\n"); printf("Going to unmap ..."); /* unmap a number of blocks */ for(i = 0; i < REGIONS_NUM; i++) { // Check header of the block if( ((char*)(shm_addr))[0] != '\0') { // Actually we don't perform this operation in this example application since header // always contains zeroes ... munmap(shm_addr, (size_t)SHM_SIZE); } } printf(" OK\n");
/* Waiting until key pressed ... and perform cleanup */ printf("Press any key to perform clean up and exit ...\n"); getchar(); close_shared_memory(shm_fd, SHM_NAME); return 0; } =========================================================
My system (PPC, 10.4.11) hangs (only mouse pointer is alive) on exit from the second process for 3-4 seconds. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/email@hidden
This email sent to email@hidden |