I asked this in the CPLEX forums (where I normally ask CPLEX questions). I'm not sure if it's okay to cross-post questions, but I know there must be some people who don't look at both this site and the CPLEX Forums. If this is inappropriate, I'll remove my question from here.

I'm running CPLEX 12.1.0 on CentOS 5.3, ( Linux version 2.6.18-128.1.14.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-44))). I don't have the option to upgrade to the newest version of CPLEX on this machine because it's a cluster running at my university. I'm getting a segmentation fault when I solve my model. The most frustrating issue that I have is I'm iterating this model many times with different input values, and I get a segmentation fault after calling the function I'm copying below several times, so I don't see why it would work the first 23 times and fail on 24. I'm attaching my code below. The segmentation fault happens when I call

cplex.solve()

I'm wondering if the problem is related to how I'm building my Ilo(Var)Arrays. Specifically, I'm suspicious of code like:

IloBoolArray2 b(env);
  for (k=0; k < nVehicles; k++) {
    IloBoolArray bk(env);
    for (t=0; t < nDays; t++) {
      IloBool bkt;
      bk.add(bkt);
    }
    b.add(bk);
  }

where I'm declaring the IloBoolArrays inside the for loops, adding them to the larger arrays, and then using the array b outside of the for loop scope. Is this a problem? I'm doing this loosely based on examples included with CPLEX, such as this snippet from foodmanufact.cpp:

  NumVarMatrix   use(env, nbMonths);
  NumVarMatrix   buy(env, nbMonths);
  NumVarMatrix   store(env, nbMonths);
  IloInt i, p;
  for (i = 0; i < nbMonths; i++) {
     use[i]   = IloNumVarArray(env, nbProducts, 0, IloInfinity);
     buy[i]   = IloNumVarArray(env, nbProducts, 0, IloInfinity);
     store[i] = IloNumVarArray(env, nbProducts, 0, 1000);
  }

Thanks in advance. I have no idea how to debug this, especially because the error is inconsistent and I don't really know how to debug segfaults beyond looking at output. The function I'm pasting below gets called several times with different input data, and segmentation faults after some number of calls (sometimes 2, sometimes 25).

I'm running this on my local machine, with CPLEX 12.2 on OpenSUSE 11.4 through valgrind - it's taking hours and hasn't hit a segfault yet, but is running incredibly slow (as any code does through valgrind). Valgrind is giving me a lot of output that I don't know how to use. I'm including it after the code.

   #include "DistributeExtraDays.h"

    IloNum DistributeExtraDays (
      const IloInt nVehicles,
      const IloInt nNodes,
      const IloInt nDays,
      const IloInt timeLimit,
      const IloInt currentScenario,
      const IloBoolVarArray4 &x,
      const IloCplex &cplexBig
    )

    {

      IloEnv env;
      IloInt i,j,k,t,s,l,n,m,r,q;
      IloNum objective;
      IloIntArray3 a(env);

      std::ifstream dataFileStream("a.txt");

      if(!dataFileStream) {
        std::cout << "Cannot open input file.
";
      }
      dataFileStream >> a;
      dataFileStream.close();

      //model
      IloModel extraCapacity(env);

      IloBoolArray2 b(env);
      for (k=0; k < nVehicles; k++) {
        IloBoolArray bk(env);
        for (t=0; t < nDays; t++) {
          IloBool bkt;
          bk.add(bkt);
        }
        b.add(bk);
      }

      IloInt continueTest = 0;

      for(k = 0 ; k < nVehicles; k++) {
        for(t = 0; t < nDays; t++) {
          IloInt xCount, aCount;
          xCount = 0;
          aCount = 0;
          for(i = 0; i < nNodes; i++) {
            xCount += IloInt(cplexBig.getValue(x[i][k][t][currentScenario])+0.5);
            aCount += a[i][t][currentScenario];
          }
          if(xCount == 0 && aCount > 0) {
            b[k][t] = 1;
            continueTest++;
          }
          else {
            b[k][t] = 0;
          }
        }
      }
      if (continueTest == 0)
        return 0.0;

      // The X^i_ar align with the Ar
      IloIntVarArray2 z(env);
      for (i=0; i < nNodes; i++) {
        IloIntVarArray zi(env);
        for (j=0; j < nNodes; j++) {
          IloIntVar zij(env);
          zi.add(zij);
        }
        z.add(zi);
      }

      //define binary integers y[i][k][t]

      IloBoolVarArray3 y(env);
      for (i=0; i < nNodes; i++) {
        IloBoolVarArray2 yi(env);
        for (k=0; k < nVehicles; k++) {
          IloBoolVarArray yik(env);
          for(t=0; t < nDays; t++) {
            IloBoolVar yikt(env);
            yik.add(yikt);
          }
          yi.add(yik);
        }
        y.add(yi);
      }

      //constraints
      for(k=0; k < nVehicles; k++) {
        for(t=0; t < nDays; t++) {
          IloExpr expr(env);
          for(i = 0; i < nNodes; i++) {
            expr += y[i][k][t];
          }
          extraCapacity.add(expr == b[k][t]);
        }
      }

      for(i = 0; i < nNodes; i++) {
        for(k = 0; k < nVehicles; k++) {
          for( t = 0; t < nDays; t++) {
            y[i][k][t].setUB(a[i][t][currentScenario]);
          }
        }
      }

      //define the objective
      IloExpr obj(env);
      for(i = 0; i < nNodes; i++) {
        for(j = 0; j < nNodes; j++) {
          obj += z[i][j];
        }
      }

      //define the auxiliary variables
      for(i = 0; i < nNodes; i++) {
       for(j = 0; j < nNodes; j++) {
          IloExpr expri(env);
          IloExpr exprj(env);
          for(k = 0; k < nVehicles; k++) {
            for(t = 0; t < nDays; t++) {
              expri += y[i][k][t];
              exprj += y[j][k][t];
            }
          }
          extraCapacity.add(z[i][j] >= expri-exprj);
          extraCapacity.add(z[i][j] >= -(expri-exprj));
        }
      }

      extraCapacity.add(IloMinimize(env,obj));
      IloCplex cplex(env);
      cplex.setOut(env.getNullStream());
      cplex.setParam(IloCplex::TiLim,timeLimit);
      cplex.extract(extraCapacity);
      cplex.solve();
      IloNum objValue = (1.0/(2*nNodes*nNodes))*cplex.getObjValue();  
      env.end();
      return objValue;
    }

==10434== Memcheck, a memory error detector
==10434== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==10434== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==10434== Command: ./SAATestAll clusterData1.txt 90 8 15 5 40 50 800 1 0 0
==10434== Parent PID: 7868
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x813F4F2: ilm_api_001. (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x813F500: ilm_api_001. (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x814593D: ilm_fun_010 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==  Address 0xbecb7910 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x84F08E5: __intel_sse2_strlen (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8141662: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==  Address 0x4332db0 is 8 bytes before a block of size 513 alloc'd
==10434==    at 0x402811D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==10434==    by 0x8141593: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8141672: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x81416E8: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8141887: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==  Address 0x4332db0 is 8 bytes before a block of size 513 alloc'd
==10434==    at 0x402811D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==10434==    by 0x8141593: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x814190D: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x20711F: ???
==10434==  Address 0xbecb7cd0 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x20711F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x1F: ???
==10434==  Address 0xbecb7cd0 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x1F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==  Address 0xbecb7cd0 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xFFFFFF: ???
==10434==  Address 0xbecb7cd0 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xFFFFFF: ???
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8140677: ilm_fun_000 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x813F6AD: ilm_api_001. (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x81416C1: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==  Address 0x6d9b080 is 8 bytes before a block of size 513 alloc'd
==10434==    at 0x402811D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==10434==    by 0x814157D: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x81418E6: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==  Address 0x6d9b080 is 8 bytes before a block of size 513 alloc'd
==10434==    at 0x402811D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==10434==    by 0x814157D: ilm_fun_019 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x6804001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x6804001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xCB866803: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xCB866803: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xF4BECB85: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xF4BECB85: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xE825001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xE825001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F4E824: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F4E824: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F3: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F3: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x78A1001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x78A1001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F578A0: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F578A0: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F4: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F4: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xFD23001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xFD23001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5FD22: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5FD22: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x6D03001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x6D03001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F66D02: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F66D02: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F5: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F5: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x8CEB001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x8CEB001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F58CEA: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F58CEA: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x8F4001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x8F4001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F508F3: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F508F3: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x2540001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x2540001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F3253F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F3253F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F2: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F2: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x771C001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x771C001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5771B: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5771B: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xCA6F001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xCA6F001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5CA6E: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5CA6E: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xD6B7001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xD6B7001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5D6B6: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5D6B6: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xC1D7001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xC1D7001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F3C1D6: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F3C1D6: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xCA81001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xCA81001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F4CA80: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F4CA80: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xD9FA001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xD9FA001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5D9F9: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5D9F9: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x4E6D001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x4E6D001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x724E4E6C: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x724E4E6C: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x3840724D: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x3840724D: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x2D5E001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x2D5E001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F52D5D: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F52D5D: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x8723001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x8723001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F78722: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F78722: ???
==10434== 
==10434== 
==10434== More than 100 errors detected.  Subsequent errors
==10434== will still be recorded, but in less detail than before.
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F6: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x384088F6: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xB5F001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xB5F001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F60B5E: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F60B5E: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x54C5001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x54C5001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F554C4: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F554C4: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xED3C001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xED3C001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5ED3B: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F5ED3B: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x473001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x473001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F60472: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F60472: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xEF6D001F: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0xEF6D001F: ???
==10434== 
==10434== Invalid read of size 8
==10434==    at 0x8145CEB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F3EF6C: ???
==10434==  Address 0xbecb7a50 is just below the stack ptr.  To suppress, use: --workaround-gcc296-bugs=yes
==10434== 
==10434== Conditional jump or move depends on uninitialised value(s)
==10434==    at 0x8145CFB: ilm_fun_067 (in /home/luis/Desktop/SAATest/SAATestAll)
==10434==    by 0x88F3EF6C: ???
==10434==

asked 04 Jul '11, 00:06

Luis%20de%20la%20Torre's gravatar image

Luis de la T...
4231612
accept rate: 11%

edited 04 Jul '11, 00:07

Does the bug occur if you force your code to use a single thread?

(07 Jul '11, 11:18) Paul Rubin ♦♦

Here are a couple of CPLEX Debugging FAQs that might help in general:

https://www-304.ibm.com/support/docview.wss?uid=swg21400039

https://www-304.ibm.com/support/docview.wss?uid=swg21400038

The second contains some general Concert/C++ debugging tips. The first is for the C API, but it contains some tips that apply to C++ programs as well. Namely,

  1. Turn on CPLEX's datacheck parameter (IloCplex::DataCheck in the C++ API) and see if reveals any useful information.
  2. Write out a SAV file of the model just before the problematic solve (using IloCplex::exportModel in the C++ API). Read the SAV file into interactive CPLEX and solve it (also with the datacheck parameter turned on by 'set read datacheck yes'.

These should help you determine whether the problem occurs during the solve that causes the segmentation fault, or whether something actually went wrong earlier, but it didn't cause a crash until a subsequent iteration.

Moving on to the information you posted, here are a few more suggestions. I looked for any obvious bogus pointer usage. I didn't see any, although I could have overlooked it. Fundamentally, when you pass add a constraint involving an expression to an IloExtractable (e.g. the IloModel::add() calls in your code above), those expressions are passed by value. So, you need not worry that your local copy of that expression sits in a loop and is out of scope when the IloCplex::solve() call occurs. For more info on this, look at the Concepts->Creation of Extractable Objects section of the CPLEX C++ Reference manual.

I suggest you try commenting out some parts of the model construction. That may help you isolate the lines of code that need to be present for the crash to occur. Also, look for anything in the data instance that crashes that distinguishes it from the data instances that run smoothly. For example, I have seen numerous programs that run fine as long as the number of constraints is <= the number of variables, but crashes as soon as the # of constraints exceeds the # of variables because some row based array was inadvertently dimensioned based on the number of columns. That works fine until the you have more rows than columns, in which case a loop across all array elements will go past the end of the array.

Finally, regarding the valgrind output, those message all relate to license manager functions which are only called during the IloCplex constructor call in your program. None of those functions are called during IloCplex::solve(). Does that valgrind output occur right before the crash, or does it occur during each iteration of the loop that calls the code segment you attached? As a test, you might try inserting a cplex.end() call before the env.end() call to see if you get different behavior.

Ed

link

answered 11 Jul '11, 15:07

Ed%20Klotz's gravatar image

Ed Klotz
23623
accept rate: 11%

I haven't worked with Concert, but if bk.add() is setting a pointer to its argument rather than making a copy, or if b.add() does, then yes, the fact that bkt (resp. bk) are automatic is a problem. The fact that they go out of scope at the end of the blocks they are declared in would mean that bk (resp. b) points to memory that has been freed and possibly reused between the time you initialized it and the time you used it.

link

answered 07 Jul '11, 10:39

Matthew%20Saltzman's gravatar image

Matthew Salt... ♦
4.7k310
accept rate: 17%

1

I hate C++. Concert critters are implemented as pairs of classes, an "implementation" class and a "handle" class. If I understand this correctly (a big "if"), when bk is initialized it creates an implementation class instance, and then bk is set to a handle class instance (basically a pointer with delusions of glory). The pointer is stuffed into b, and bk going out of scope should not screw up b. If it did, I would expect the program to gork consistently in the first or second iteration, not last until the 24th call.

(07 Jul '11, 11:15) Paul Rubin ♦♦

So the automatic variable (bk) ctor creates an object pair on the heap and the dtor doesn't destroy it? That's kinda scary, unless it's doing reference counting. (Sorry about the C++ jargon...) As a long-time C programmer and C++ tyro, garbage collectors just give me the jitters.

(07 Jul '11, 13:51) Matthew Salt... ♦

@Paul shouldn't you rephrase it to "I hate pointers" ?

(07 Jul '11, 14:10) Bo Jensen ♦

@Bo: No, I hate C++; pointers are just one reason among many. The incomprehensible compiler/linker commands, the separate header and body files, lack of automatic garbage collection (unless you use a special memory class), the nonstandard (compiler-specific) "Standard" Template Library, ...

(07 Jul '11, 17:53) Paul Rubin ♦♦

@Paul I'm pretty sure the Standard Template Library is part of the standard. The compilers themselves didn't use to be completely standards compliant but AFAIK, since 4-5 years ago, my experience with them, especially with gcc has been pretty good. C++ can definitely be better though and the new C++0x standard introduces some much needed changes (though a module system is still lacking which means we're stuck with header files). Unfortunately there's no other language (apart from C) in which such efficient code can be written.

(07 Jul '11, 22:12) Sid

@Paul He he, your blood pressure rise just by the word "C++".. due to your health I will let you win without a battle :-) Though I can't help mentioning Sid's last remark, which is spot on..alternatives (with same speed) ?

(08 Jul '11, 03:37) Bo Jensen ♦

@Sid: It's quite possible STL is supposed to be standard, but before I swore off C++ (after a few years of swearing at it), I distinctly recall that the M$ version of STL had some incompatibilities with at least some other versions. (Shocking, I know.) It seems to me I've seen messages on support forums in subsequent years suggesting there were still some deviations.

@Bo: Speed is easy for me -- write the main program in Java (or maybe Python) and link to a C library that some other unfortunate soul has to develop/maintain.

(08 Jul '11, 10:13) Paul Rubin ♦♦

@Paul, thanks for shedding some light on why this is correct. It's annoying that this is inconsistent with how I expect variable scope to work. Maybe in the future I will use Java for concert. All of your answers to my Concert questions have been "here's how to fix it, but you wouldn't have to with Java" - I guess I should take the hint. Regarding your other comment about threading I haven't gotten a chance to try it yet but I will this weekend.

(08 Jul '11, 10:48) Luis de la T...
showing 5 of 8 show 3 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×191
×101
×28

Asked: 04 Jul '11, 00:06

Seen: 9,218 times

Last updated: 11 Jul '11, 15:07

OR-Exchange! Your site for questions, answers, and announcements about operations research.