ports/149621: valgrind failng shmat(). Returns Invalid Argument.

Stephen Sanders ssanders at opnet.com
Fri Aug 13 15:30:02 UTC 2010


>Number:         149621
>Category:       ports
>Synopsis:       valgrind failng shmat().  Returns Invalid Argument.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 13 15:30:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Stephen Sanders
>Release:        FreeBSD 8.1
>Organization:
OPNET Technologies
>Environment:
FreeBSD al3170-1.opnet.com 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     root at mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
We have a large program that runs in a normal environment but is failing to run under valgrind and outputting the following before exiting.

==53581== Warning: set address range perms: large range [0x33ea000, 0x28bea000) (defined)
npQueueManager::npQueueManager(int, int)(271) - failed on 'Invalid argument'
2010/08/13 11:14:13.857 al3170-1.opnet.com .libs/mt-hcfestats ERROR MQ-1002: Fail to get share memory of the size initsize

Using the attached test program, shmat() fails under valgrind but not in a normal environment.

This bug sounds very similar to Valgrind Bugs numbers 157665 and 116483.

The output of valgind when running the attached test is presented below.

==53556== Memcheck, a memory error detector
==53556== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==53556== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==53556== Command: ./a.out
==53556== 
shmat failed on 'Invalid argument'
==53556== 
==53556== HEAP SUMMARY:
==53556==     in use at exit: 4,096 bytes in 1 blocks
==53556==   total heap usage: 3 allocs, 2 frees, 4,202 bytes allocated
==53556== 
==53556== LEAK SUMMARY:
==53556==    definitely lost: 0 bytes in 0 blocks
==53556==    indirectly lost: 0 bytes in 0 blocks
==53556==      possibly lost: 0 bytes in 0 blocks
==53556==    still reachable: 4,096 bytes in 1 blocks
==53556==         suppressed: 0 bytes in 0 blocks
==53556== Rerun with --leak-check=full to see details of leaked memory
==53556== 
==53556== For counts of detected and suppressed errors, rerun with: -v
==53556== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

>How-To-Repeat:
Compile and run the attached test program.  Once in under the OS and again using valgrind.
>Fix:
None

Patch attached with submission follows:

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <machine/param.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>


int main( char **argv, int argc )
{
    int shmId = shmget( 0, 4096, IPC_PRIVATE|SHM_R|SHM_W);
    char *page =  NULL; 

    if( shmId == -1 )
    { 
         printf("shmget failed on '%s'\n", strerror( errno ));
         exit( 0 );
    }

    page = shmat( shmId, 0, 0 );
    if( page == (char *)-1 )
    {
         printf("shmat failed on '%s'\n", strerror( errno ));
         exit( 0 );
    }

    if( shmdt( page ) != 0 )
    {
         printf("shmdt failed on '%s'\n", strerror( errno ));
         exit( 0 );
    }

}


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list