Skip to contentSkip to conversation

Problem with shared memory (no entry in /dev/shm)

Xenomai Franz Engel 2 participants 3 messages Jul 7, 2013

lore
Share & tools
lore
#0 lore raw

Hi,

Currently I'm upgrading my system to Xenomai 2.6.2.1 and the Linux kernel 3.5.7. Everything looks fine. I see the services starting in the dmesg and the latency test runs without problems (besides some high latencies :-)). But I have a problem with the shared memory. When I run my project in the old system, everything works fine and I saw an entry in /dev/shm. With my new system I get segmentations faults when I try to write to the shared memory I created. Futhermore I have no entries in /dev/shm. If I compile the code (in my cmake file it is possible to change between "normal" compiling and compiling with xenomai) without xenomai everything works good and I get an entry in /dev/shm. Does somebody else have the same problems with the shared memory in the new xenomai version or is something wrong with my code. Here is a small example with the corresponding cmake-file (I get no errors):

#include <errno.h>
#include <fcntl.h>anybody

int main(int argc, char *argv[])
{
    int fd = shm_open("MeinSHM", O_CREAT | O_RDWR, 0777); if (fd == -1)
    {
    printf("shm_open: %d\n", errno);
    return -errno;
    }

    if (ftruncate(fd, 65536))
    {
    printf("ftruncate: %d\n", errno);
    }
    exit(0);
}

I use this cmake file:
cmake_minimum_required(VERSION 2.8)

##################################
# BEGIN OF EDITING THIS TEMPLATE #
##################################

############################################
# PLEASE ENTER HERE THE NAME OF YOUR PROJECT

set(ProjectName "kogmo_man")

PROJECT(${ProjectName})

###############################################
# ENTER HERE THE VERSION NUMBER OF YOUR PROJECT
set(${ProjectName}_VERSION_MAJOR 1)
set(${ProjectName}_VERSION_MINOR 0)

###############################################
# ENABLE OR DIABLE THE USE OF XENOMAI AND QT option(${ProjectName}_USE_XENOMAI        "xenomai"    OFF    )

set(INSTALLDIR ${MAIN_DIR}/bin)

######
# CPPs
set(SOURCES
    main.c
)

message ("Usage of Xenomai:         ${${ProjectName}_USE_XENOMAI}")

IF(${ProjectName}_USE_XENOMAI) message(STATUS "Starting Xenomai configuration")
    find_package(PkgConfig)

    if(NOT DEFINED ENV{PKG_CONFIG_PATH})
        set(ENV{PKG_CONFIG_PATH} $ENV{PKG_CONFIG_PATH} "/usr/xenomai/lib/pkgconfig")
    endif(NOT DEFINED ENV{PKG_CONFIG_PATH})

    pkg_search_module(XENOMAI libxenomai_posix)
    if (XENOMAI_FOUND)
        set(EXTRA_DEFINITIONS ${EXTRA_DEFINITIONS} ${XENOMAI_CFLAGS})
        set(EXTRA_LIBS ${EXTRA_LIBS} ${XENOMAI_LDFLAGS})
        ADD_DEFINITIONS(${EXTRA_DEFINITIONS})
    else(XENOMAI_FOUND)
        set(XENOMAI_DIR "/usr/xenomai")
        set(XENOMAI_INCLUDE_DIR ${XENOMAI_DIR}/include)
        set(XENOMAI_INCLUDE_POSIX_DIR ${XENOMAI_DIR}/include/posix) exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=posix --ldflags" OUTPUT_VARIABLE XENOMAI_EXE_LINKER_FLAGS) set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${XENOMAI_EXE_LINKER_FLAGS}) exec_program("${XENOMAI_DIR}/bin/xeno-config --skin=posix --cflags" OUTPUT_VARIABLE XENOMAI_DEFINITIONS) set(EXTRA_DEFINITIONS ${EXTRA_DEFINITIONS} ${XENOMAI_DEFINITIONS}) ADD_DEFINITIONS(${EXTRA_DEFINITIONS})
        set(EXTRA_LIBS ${EXTRA_LIBS} rtdk)
    endif (XENOMAI_FOUND)

    message(STATUS "Xenomai configuration finished")
ELSE(${ProjectName}_USE_XENOMAI)
    set(EXTRA_DEFINITIONS ${EXTRA_DEFINITIONS} "-O2 -fno-strict-aliasing -Wstrict-prototypes -O2 -g -Wall") set(EXTRA_DEFINITIONS ${EXTRA_DEFINITIONS} "-D_GNU_SOURCE -D_REENTRANT") find_library(THREAD_LIB pthread ../usr/lib)
    set(EXTRA_LIBS ${EXTRA_LIBS} ${THREAD_LIB})
    find_library(C_LIB c ../usr/lib)
    set(EXTRA_LIBS ${EXTRA_LIBS} ${C_LIB})
    find_library(RT_LIB rt ../usr/lib)
    set(EXTRA_LIBS ${EXTRA_LIBS} ${RT_LIB})
ENDIF(${ProjectName}_USE_XENOMAI)

ADD_DEFINITIONS(${EXTRA_DEFINITIONS})

add_executable(${ProjectName} ${SOURCES})

TARGET_LINK_LIBRARIES(${ProjectName} ${EXTRA_LIBS})

install(TARGETS ${ProjectName} DESTINATION ${INSTALLDIR})

#1 lore raw
Quoted 16 lines · Franz Engel

Hi,

Currently I'm upgrading my system to Xenomai 2.6.2.1 and the Linux kernel 3.5.7. Everything looks fine. I see the services starting in the dmesg and the latency test runs without problems (besides some high latencies :-)). But I have a problem with the shared memory. When I run my project in the old system, everything works fine and I saw an entry in /dev/shm. With my new system I get segmentations faults when I try to write to the shared memory I created. Futhermore I have no entries in /dev/shm. If I compile the code (in my cmake file it is possible to change between "normal" compiling and compiling with xenomai) without xenomai everything works good and I get an entry in /dev/shm. Does somebody else have the same problems with the shared memory in the new xenomai version or is something wrong with my code. Here is a small example with the corresponding cmake-file (I get no errors):

The difference comes from the kernel configuration: if you have xenomai posix shared memory enabled in xenomai configuration, these one are used, and they do not appear in /dev/shm but in /proc/xenomai/heaps.

As for the error with xenomai skin posix shared memory I will run your sample program to see if I can reproduce it, but would need a bit more information:
what version of the I-pipe patch do you use?
is running the example you posted sufficient, or do I have to add a call to mmap and a write to the mmaped area to reproduce the bug?

Signature · 1 line
Gilles.
#2 lore raw
In reply to Franz Engel
Quoted 2 lines · Franz Engel

the latency test runs without problems (besides some high latencies :-))

That is certainly not expected, at least if you kept the default configuration.

Signature · 1 line
                                                                Gilles.