[Ipopt-tickets] Re: [Ipopt] #48: segmentation fault in AMPL run with external functions

Ipopt coin-trac at coin-or.org
Sun Nov 25 14:09:26 EST 2007


#48: segmentation fault in AMPL run with external functions
--------------------------------+-------------------------------------------
  Reporter:  andreasw           |       Owner:  andreasw
      Type:  defect             |      Status:  assigned
  Priority:  normal             |   Component:  Ipopt   
   Version:  3.3 (C++ Version)  |    Severity:  normal  
Resolution:                     |    Keywords:          
--------------------------------+-------------------------------------------
Changes (by andreasw):

  * status:  new => assigned

Comment:

 It is very difficult to debug this without the code, since the problem
 seems to be related to the external C++ functions bound into AMPL.

 The first step for debugging that can be done is to run Ipopt from AMPL,
 with the memory checker ''valgrind''.  It is probably installed on most
 Linux distributions, and it can be downloaded from http://valgrind.org/.

 For you to run Ipopt through the memory checker, please copy the following
 lines into a file called "{{{ipopt_dbg}}}":

 {{{
 #!/bin/sh
 valgrind ipopt $*
 }}}

 After that file has been created, please make it executable (e.g., with
 "{{{chmod 755 ipopt_dbg}}}"), and put it into your PATH (e.g., into the
 same directory, where the original "{{{ipopt}}}" program is).

 Then, in your AMPL script, use
 {{{
 option solver ipopt_dbg;
 }}}
 to specify the NLP solver.  When you run your AMPL script now, it should
 run through valgrind, i.e., you will see output such as

 {{{
 ampl: solve;
 ==17787== Memcheck, a memory error detector.
 ==17787== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
 ==17787== Using LibVEX rev 1732, a library for dynamic binary translation.
 ==17787== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
 ==17787== Using valgrind-3.2.3, a dynamic binary instrumentation
 framework.
 ==17787== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
 ==17787== For more details, rerun with: -v
 ==17787==
 Ipopt 3.3dev:

 ******************************************************************************
 This program contains Ipopt, a library for large-scale nonlinear
 optimization.
  Ipopt is released as open source code under the Common Public License
 (CPL).
          For more information visit http://projects.coin-or.org/Ipopt
 ******************************************************************************

 [...]

 EXIT: Optimal Solution Found.
 ==17787==
 ==17787== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 25 from 1)
 ==17787== malloc/free: in use at exit: 0 bytes in 0 blocks.
 ==17787== malloc/free: 17,649 allocs, 17,649 frees, 172,320,910 bytes
 allocated.
 ==17787== For counts of detected errors, rerun with: -v
 ==17787== All heap blocks were freed -- no leaks are possible.

 Ipopt 3.3dev: Optimal Solution Found
 }}}

 If there is a problem with memory (which is the case if you encounter a
 segmentation fault), valgrind will output more lines that tell you where
 in the program something went wrong.

 As a first check, you can just run your current setup with "ipopt"
 replaced by "ipopt_dbg" and see where valgrind's output tells you that an
 invalid memory access occurred.  The output will tell you, in which source
 file this happens, and if the first error occurs in your own code (the C++
 code defining your new AMPL functions) then you need to fix that first.
 If it happens in Ipopt code, please attach some output to this ticket, but
 use the debug version described next.

 In order to really see where the error occurs, you need to compile the
 code with debug information.  For Ipopt, this means you need to redo all
 the {{{configure}}} and {{{make install}}} steps (in a clean directory,
 also delete anything in the "bin" and "lib" subdirectories if there is
 something from your previous compilation).  This time, you need to run the
 configure script with the "{{{--enable-debug}}}" option, as in
 {{{
 ./configure --enable-debug
 }}}
 plus all the other options you used (except any compiler flag options).

 If the error is in your code, you need to recompile that one also with
 debug information, i.e., use the "{{{-g}}}" flag and no "{{{-O}}}" flag.

 Note: The program will run much slower with valgrind than usually, so you
 need to be somewhat patient.

-- 
Ticket URL: <https://projects.coin-or.org/Ipopt/ticket/48#comment:1>
Ipopt <http://projects.coin-or.org/Ipopt>
Interior-point optimizer for nonlinear programs.



More information about the Ipopt-tickets mailing list