Menu

Problems running test suite

Help
Vic
2004-03-19
2004-03-22
  • Vic

    Vic - 2004-03-19

      I'm looking to use your Allocator classes for some work that I'm doing - it seems to be exactly what I need.  I'm having some problems getting to to work, though.  I'm unable to get locks created - semaphore problems.  I've checked everything I can think of, and thought you might be able to help. 

      The simplest case I'm running into the problem on is in the test directory, shared_header.
    The bit_vector test completes perfectly.  When I run shared_header, I get:

    ./shared_header
    key_file = /tmp/allocate_key
    mykey = 34684992
    num_in_array = 250
    Status:../src/shared_memory.cc:69: semid: -1  Invalid argument
    File: ../src/shared_memory.cc:114:locks::locks(): semaphore initialization error: Invalid argument
    make: *** [run_test] Aborted

    The line numbers are a bit screwy since I added some debug.  The actual line that causes the error is:

        semid = semget(mykey, num_in_array, IPC_CREAT | IPC_EXCL | 0666);

    in locks::locks

    Here is some system info:
    [vic@gold-linux src]$ uname -a
    Linux gold-linux 2.4.21-9.0.1.EL #1 Mon Feb 9 22:44:14 EST 2004 i686 i686 i386 GNU/Linux

    (Redhat Enterprise Workstation version 3)

    I'm using the latest version of Allocator from the sourceforge web site: 1.07

    I'm using g++:

    [vic@gold-linux src]$ g++ -v
    Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
    Thread model: posix
    gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-24)

     
    • Marc Bumble

      Marc Bumble - 2004-03-19

      Before  you  run  the   program,  are  there  any  existing  allocated
      semaphores,  left over perhaps  from an  earlier crash?   What happens
      when you use the UNIX utility ipcs to check ?

      $ ipcs

      There should be a line

      ------ Semaphore Arrays --------
      key        semid      owner      perms      nsems    

      with probably  nothing under  it when the  program starts.   Maybe its
      just that  the semphores, allocated earlier were  not properly cleaned
      up?

      Marc

       
    • Vic

      Vic - 2004-03-19

      I did check ipcs - nothing was there.  To double check, I did a clean reboot, and tried again - same problems.

      Vic

       
      • Vic

        Vic - 2004-03-21

        The differences in the output were due to some debug I put in.  I reinstalled the released version, and got the following.....

        (The first two errors in lock test seem to be an anamoly due to the test program trying to create a file in /, rather than in /tmp where the real code puts the file)

        Vic

        ./shared_header
        File: ../src/shared_memory.cc:111:locks::locks(): semaphore initialization error: Invalid argument
        make: *** [run_test] Aborted
        [vic@gold-linux test]$ make lock_test
        make: `lock_test' is up to date.

        [vic@gold-linux test]$ lock_test
        Cannot open key file: Permission denied
        Cannot open key file: Permission denied
        ----------------------------------------
        Lock class test.
                Constructor test
                Copy Constructor test
                Assignment Test
                Equality Test

        locks::print()
        semid    = -1
        semval[] =
                   :2:0:48083:49151:1:0:48035:49151:47808:49151:62400:46926:1:0:47808:49151:26446:46914:62400:46926:48083:49151:1:0:26379
                   :46914:3672:46927:62400:46926:48083:49151:47856:49151:31039:46914:62400:46926:48083:49151:1:0:1:0:1:0:0:0:0:0
                   :3672:46927:62400:46926:61216:46926:47896:49151:51325:46913:62400:46926:48083:49151:1:0:1:0:1:0:19068:46939:48083:49151:23136
                   :46939:47928:49151:29204:46933:48083:49151:1:0:1:0:62400:46926:19068:46939:1:0:48040:49151:32360:46932:48000:49151:48083:49151
                   :1:0:53872:46941:22816:46939:57268:46941:1284:46944:54284:46941:64689:46929:48136:49151:32123:46932:19068:46939:24320:46939:48000:49151:48056
                   :49151:32024:46932:22816:46939:48035:49151:1:0:48036:49151:28362:46914:0:0:32123:46932:19068:46939:24320:46939:3672:46927:62400:46926
                   :61216:46926:48072:49151:46971:46913:62400:46926:19068:46939:24320:46939:48192:49151:48088:49151:7569:46937:62400:46926:19068:46939:48136:49151:33585
                   :46932:24424:46939:48192:49151:48120:49151:7569:46937:19068:46939:48192:49151:48136:49151:19068:46939:48192:49151:48192:49151:48168:49151:25832:46935
                   :24320:46939:10:0:48200:2815:19068:46939:28362:46914:17200:2053:48232:49151:31220:46935:48192:49151:3672:46927:62400:46926:61216:46926:48216
                   :49151:46971:46913:62400:46926:19068:46939:24320:46939:59196:46926:48232:49151:7569:46937:62400:46926:19068:46939:48280:49151:33585:46932:24424:46939
        my_lock1.lock(1)
        ../src/shared_memory.cc:202: locks::lock(): semaphore lock: Invalid argument result: -1
        : semaphore lock errno: Invalid argument result: -1 lock attempt error. semid: -1 page_num: 1
        Aborted

         
        • Marc Bumble

          Marc Bumble - 2004-03-21

          The two files generated in lock_test were probably from earlier versions and have been removed from versions I just used to update CVS.  The locks class constructor makes these ftok files if they do not already exist.

          Meanwhile the semval[] array displayed above is corrupted and full of garbage. Perhaps some change to the locks class that you have locally is corrupting the semval[] array?

          The test should look like the following:

          ./lock_test
          ----------------------------------------
          Lock class test.
                  Constructor test
                  Copy Constructor test
                  Assignment Test
                  Equality Test

          locks::print()
          semid    = 1376261
          semval[] =
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
          my_lock1.lock(1)

          locks::print()
          semid    = 1376261
          semval[] =
                     :1:0:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
          my_lock1.unlock(1)

          locks::print()
          semid    = 1376261
          semval[] =
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
          my_lock4.lock(30)

          locks::print()
          semid    = 1376261
          semval[] =
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:0:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
          my_lock4.unlock(30)

          locks::print()
          semid    = 1376261
          semval[] =
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                     :1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1
                  Destructor test
          Passed: 3
          Failed: 0
          ----------------------------------------

           
          • Vic

            Vic - 2004-03-22

            I'm running my test with a vanilla 1.07 version downloaded directly from the website - I blew away the version that had local mods.  Should I try to use a different version?

            I think the reason that the array is garbage is that the semaphore is never getting allocated.  I've checked all the values in gdb, and they look o.k. compared with the man page for semget.

            Any other thoughts?

            Thanks for all your time.

            Vic

             
            • Marc Bumble

              Marc Bumble - 2004-03-22

                > Any other thoughts?

              Last thought, can you check the version out of CVS and test with that?  Does that give you the same errors?

              Marc

               
    • Marc Bumble

      Marc Bumble - 2004-03-20

      There is a separate test for the  lock class which is what I would use
      to debug the  semaphores.  In the test subdirectory,  try doing a make
      lock_test.  That should run some test  on just the lock class.  See if
      you  get the  same failure.   On my  version of  the code,  the output
      statements which would generate the

      Status:../src/shared_memory.cc:69: semid: -1 Invalid argument

      Is  commented out.   Also, when  I compile  shared_header in  the test
      directory by doing:

      make shared_header

      and run  the resulting binary, I  see the following  output which does
      not match the output in your first email:

      ./shared_header
      ----------------------------------------
      Shared memory header test.
              Marking pages 0 through 4
              Finding 4 free pages
              Clearing pages 2 through 4
              Find 3 free pages
              Marking pages 0 through 997
              Finding 3 free pages
              Testing page offset.
              Testing page offset.
              Path name test: /key_name_is_not_path
      Passed: 5
      Failed: 0
      ----------------------------------------

      In the first email its looks  like ./shared_header is run and give the
      following ouput, which is different:

      ./shared_header
      key_file = /tmp/allocate_key
      mykey = 34684992
      num_in_array = 250
      Status:../src/shared_memory.cc:69: semid: -1 Invalid argument
      File: ../src/shared_memory.cc:114:locks::locks(): semaphore initialization error: Invalid argument
      make: *** [run_test] Aborted

       
    • Vic

      Vic - 2004-03-22

      Sigh.

      Checked out CVS version - same exact results (see below)

      Have you tried this on Redhat Enterprise WS 3?  Could I be running into a versioning issue?

      [vic@gold-linux test]$ lock_test
      ----------------------------------------
      Lock class test.
              Constructor test
              Copy Constructor test
              Assignment Test
              Equality Test

      locks::print()
      semid    = -1
      semval[] =
                 :2:0:57187:49151:1:0:57139:49151:56912:49151:62400:46926:1:0:56912:49151:26446:46914:62400:46926:57187:49151:1:0:26379
                 :46914:3672:46927:62400:46926:57187:49151:56960:49151:31039:46914:62400:46926:57187:49151:1:0:1:0:1:0:0:0:0:0
                 :3672:46927:62400:46926:61216:46926:57000:49151:51325:46913:62400:46926:57187:49151:1:0:1:0:1:0:19068:46939:57187:49151:23136
                 :46939:57032:49151:29204:46933:57187:49151:1:0:1:0:62400:46926:19068:46939:1:0:57144:49151:32360:46932:57104:49151:57187:49151
                 :1:0:53872:46941:22816:46939:57268:46941:1284:46944:54284:46941:64689:46929:57240:49151:32123:46932:19068:46939:24320:46939:57104:49151:57160
                 :49151:32024:46932:22816:46939:57139:49151:1:0:57140:49151:28362:46914:0:0:32123:46932:19068:46939:24320:46939:3672:46927:62400:46926
                 :61216:46926:57176:49151:46971:46913:62400:46926:19068:46939:24320:46939:57296:49151:57192:49151:7569:46937:62400:46926:19068:46939:57240:49151:33585
                 :46932:24424:46939:57296:49151:57224:49151:7569:46937:19068:46939:57296:49151:57240:49151:19068:46939:57296:49151:57296:49151:57272:49151:25832:46935
                 :24320:46939:10:0:57304:2815:19068:46939:28362:46914:19824:2053:57336:49151:31220:46935:57296:49151:3672:46927:62400:46926:61216:46926:57320
                 :49151:46971:46913:62400:46926:19068:46939:24320:46939:59196:46926:57336:49151:7569:46937:62400:46926:19068:46939:57384:49151:33585:46932:24424:46939
      my_lock1.lock(1)
      ../src/shared_memory.cc:202: locks::lock(): semaphore lock: Invalid argument result: -1
      : semaphore lock errno: Invalid argument result: -1 lock attempt error. semid: -1 page_num: 1
      Aborted
      [vic@gold-linux test]$

       
      • Marc Bumble

        Marc Bumble - 2004-03-22

        No, I just RedHat 9.0 here to test with. 

        I would test with the semaphore directly
        and verify that the system calls work as
        expected,  the verify the lock_test.

        I am not sure what problem you are facing.

        Marc

         
    • Vic

      Vic - 2004-03-22

      I've looked at the problem a bit more, and I've found the following.  In the constructor, there is an assumption that anytime the semid < 0 it is because the semaphore already exists.  In this case, we're getting a different error.  But we try to attach the semaphore, and we end up with a buffer full of garbage.  The sem_otime field generally ends up being non-zero, so the code thinks that our garbage is an initialized semaphore.....

      Vic

       
    • Vic

      Vic - 2004-03-22

      In Redhat Enterprise 3 (at least), the default parameters for the number of semaphores is set to 100 / set.

      To fix it, I did the following:

      as root added the following to /etc/sysctl.conf
      kernel.sem=250 32000 100 128

      This changes the value of semmsl, semmns, semopm, semmni (in that order)

      Then, still as root, do a sysctl -p to get the system to reread the conf file.

      To check your values, you can do the following

      cat /proc/sys/kernel/sem

      Marc - thanks for all your help!

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.