shmat返回的地址一访问就段错误

{
    unsigned int iShmId = 0;
    unsigned int uiShmKey = 0x10724;
    unsigned int *ptest = RRM_PNULL;

    iShmId = shmget_wrapper(uiShmKey, 0, (IPC_CREAT | 0666));
    if (iShmId >= 0)
    {
        fprintf(stderr, "iShmId(%d) exist\n", iShmId);
        /* IF key exist then remove SHM*/
        shmctl_wrapper_ipc_rmid(iShmId);
    }

    /* Get the shared memory ID */
    iShmId = shmget_wrapper(uiShmKey, sizeof(unsigned int),(IPC_CREAT | 0666));
    if (0 > iShmId)
    {
        fprintf(stderr, "SHM(%d) get failed\n", uiShmKey);
        return;
    }

    /* Map Shared memory */
    ptest = (unsigned int *)shmat_wrapper(iShmId, RRM_PNULL, 0);   
    fprintf(stderr,"ptest(%p)", ptest);
    if ((void *)-1 == ptest)
    {
        fprintf(stderr,"SHM(%d) attach failed", uiShmKey);
        shmctl_wrapper_ipc_rmid(iShmId);
        iShmId = -1;
        return;
    }

    /* Initialize shared memory */
    memset(ptest, 0, sizeof(unsigned int));   
    fprintf(stderr,"SHMend", uiShmKey);
}