Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  CPLEX 12.4 IloNumArray2 Segmentation Fault using Mac OS X Lion clang++

    Posted Fri August 31, 2012 05:13 PM

    Originally posted by: SystemAdmin


    Hi,

    Recently I downloaded CPLEX 12.4 for Mac OS X. I tried to compile a simple app using clang++ compiler (with c++0x feature and libc++ as STL) and CPLEX libs. The source is the following:

    #include <iostream>
    #include <vector>
    #include <ilcplex/ilocplex.h>

    ILOSTLBEGIN

    int main()
    { cout << "Instantiating vector<>..." << endl;
    vector<int> v;

    IloEnv env;

    try
    { cout << "Instantiating IloNumArray..." << endl;
    IloNumArray a(env);

    cout << "Instantiating IloNumArray2..." << endl;
    IloNumArray2 rba(env);

    cout << "Creating model..." << endl;
    IloModel mod(env);
    IloCplex cplex(mod);
    }

    catch (IloException& ex) { cerr << "Error: " << ex << endl; }
    catch (...) { cerr << "Error: Unknown exception caught!" << endl; }

    env.end();

    return 0;
    }

    The compilation line is:

    $ clang++ -g -m64 -fPIC -fexceptions -DNDEBUG -DIL_STD -std=c++0x -stdlib=libc++
    -I/Users/Mark/Applications/IBM/ILOG/CPLEX_Studio124/cplex/include
    -I/Users/Mark/Applications/IBM/ILOG/CPLEX_Studio124/concert/include
    -L/Users/Mark/Applications/IBM/ILOG/CPLEX_Studio124/cplex/lib/x86-64_darwin9_gcc4.0/static_pic
    -L/Users/Mark/Applications/IBM/ILOG/CPLEX_Studio124/concert/lib/x86-64_darwin9_gcc4.0/static_pic seg_fault.cpp
    -o seg_fault -lcplex -lilocplex -lconcert -lpthread -lstdc++.6 -lm
    Then, I run it and I get:

    Instantiating vector...
    Instantiating IloNumArray...
    Instantiating IloNumArray2...
    Segmentation fault: 11

    So, it seems that it IloNumArray works fine, but it cannot instatiate IloNumArray2.

    Any hint??

    System info:
    Mac OS X Lion 10.7.4
    Apple clang++ version 4.0 (based on LLVM 3.1svn)
    clang++ language and STL options: -std=c++0x -stdlib=libc++
    CPLEX 12.4 libs for x86-64_darwin9_gcc4.0
    Thanks in advance
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX 12.4 IloNumArray2 Segmentation Fault using Mac OS X Lion clang++

    Posted Fri August 31, 2012 05:24 PM

    Originally posted by: SystemAdmin


    I just compiled your code on Linux and it runs without problem there.
    Can you please try the following:
    1. Go to /Users/Mark/Applications/IBM/ILOG/CPLEX_Studio124/cplex/examples/x86-64_darwin9_gcc4.0/static_pic
    2. Type 'make execute_cpp'
    3. Pick up the compiler and linker flags that you see when make builds compiles and links the C++ sources.
    4. Use the exact same flags with your compilation.
    Does this help?
    If not, could you provide a backtrace from a debugger?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPLEX 12.4 IloNumArray2 Segmentation Fault using Mac OS X Lion clang++

    Posted Fri August 31, 2012 06:40 PM

    Originally posted by: SystemAdmin


    Hi,
    Thanks for such a quick reply!! I've tried the compilation+linking options but they don't make any better.
    Please, note that I'm using clang++ compiler with the c++0x option and their libstd++ STL implementation.
    I mean that, if I delete any reference to an STL object (i.e. vector) and then compile without the "-stdlib=libc++" and "-lstdc++.6" options, the program will run OK.

    The debugger backtrace is:
    (gdb) run
    Starting program: /Users/Mark/Developer/_CPLEX_seg_fault_/seg_fault
    Reading symbols for shared libraries +......................... done
    Instantiating vector...
    Instantiating IloNumArray...
    Instantiating IloNumArray2...

    Program received signal EXC_BAD_ACCESS, Could not access memory.
    Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
    0x00000001007b64bb in IloArrayI::IloArrayI ()
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: CPLEX 12.4 IloNumArray2 Segmentation Fault using Mac OS X Lion clang++

    Posted Fri August 31, 2012 06:47 PM

    Originally posted by: SystemAdmin


    Sorry, the copy+paste missed the backtrace:

    (gdb) backtrace
    #0 0x00000001007b64bb in IloArrayI::IloArrayI ()
    #1 0x0000000100002381 in IloArray<IloNumArray>::IloArray (this=0x7fff5fbff8b8, env={_impl = 0x101801c00}, max=0) at iloenv.h:2161
    #2 0x0000000100002303 in IloNumArray2::IloNumArray2 (this=0x7fff5fbff8b8, env={_impl = 0x101801c00}, n=0) at iloenv.h:2447
    #3 0x0000000100001af5 in IloNumArray2::IloNumArray2 (this=0x7fff5fbff8b8, env={_impl = 0x101801c00}, n=0) at iloenv.h:2447
    #4 0x000000010000143c in main () at seg_fault.cpp:22
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: CPLEX 12.4 IloNumArray2 Segmentation Fault using Mac OS X Lion clang++

    Posted Fri August 31, 2012 06:47 PM

    Originally posted by: SystemAdmin


    Sorry, the copy+paste missed the backtrace:

    (gdb) backtrace
    #0 0x00000001007b64bb in IloArrayI::IloArrayI ()
    #1 0x0000000100002381 in IloArray<IloNumArray>::IloArray (this=0x7fff5fbff8b8, env={_impl = 0x101801c00}, max=0) at iloenv.h:2161
    #2 0x0000000100002303 in IloNumArray2::IloNumArray2 (this=0x7fff5fbff8b8, env={_impl = 0x101801c00}, n=0) at iloenv.h:2447
    #3 0x0000000100001af5 in IloNumArray2::IloNumArray2 (this=0x7fff5fbff8b8, env={_impl = 0x101801c00}, n=0) at iloenv.h:2447
    #4 0x000000010000143c in main () at seg_fault.cpp:22
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: CPLEX 12.4 IloNumArray2 Segmentation Fault using Mac OS X Lion clang++

    Posted Wed September 19, 2012 03:26 AM

    Originally posted by: SystemAdmin


    I have double checked the source code and could not find any issue.
    The officially supported compiler/runtime environment on MacOS is g++.
    So I'm afraid that the problem arises from some incompatibility between the C++ runtime libraries. There is not much you can do other than switching to g++ or not linking with the offending libraries :-(
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: CPLEX 12.4 IloNumArray2 Segmentation Fault using Mac OS X Lion clang++

    Posted Thu September 20, 2012 03:58 AM

    Originally posted by: SystemAdmin


    OK, I understand. Actually, if I compile the source without using libc++, it works fine. So, I'll try to switch to g++ for Mac OS.

    Thank you very much
    #CPLEXOptimizers
    #DecisionOptimization