mmap core dumps when shm is full
Video mixer for mixing live and recorded video and audio feeds
Status: Beta
Brought to you by:
pmaersk
mmap in the following code in controller.cpp core dumps when mmap is called if the shared memory file system is full.
do { pid_t pid = getpid (); #ifdef HAVE_MACOSX sprintf (pVideoMixer->m_output_memory_handle_name, "/shmpipe.%d.%d", pid, no); pVideoMixer->m_output_memory_handle = shm_open (pVideoMixer->m_output_memory_handle_name, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP); #else sprintf (pVideoMixer->m_output_memory_handle_name, "/shmpipe.%5d.%5d", pid, no); pVideoMixer->m_output_memory_handle = shm_open (pVideoMixer->m_output_memory_handle_name, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP); #endif } while (pVideoMixer->m_output_memory_handle < 0 && errno == EEXIST); if (pVideoMixer->m_output_memory_handle < 0) { fprintf (stderr, "Unable to open shared memory handle: name %s. Error : %s\n", pVideoMixer->m_output_memory_handle_name, strerror (errno)); exit (1); } if (ftruncate (pVideoMixer->m_output_memory_handle, pVideoMixer->m_output_memory_size) < 0) { perror ("Unable to resize shm area."); exit (1); } pVideoMixer->m_pOutput_memory_base = (uint8_t*) mmap (NULL, pVideoMixer->m_output_memory_size, PROT_READ | PROT_WRITE, MAP_SHARED, pVideoMixer->m_output_memory_handle, 0);