NodeArray.h Assertion Failed When Accessing X-Coordinate

316 views
Skip to first unread message

dago...@soe.ucsc.edu

unread,
Aug 19, 2015, 9:04:32 PM8/19/15
to ogdf
I see this message whenever I attempt to read/write to the x-coordinate of a node:
Assertion failed: (v->graphOf() == m_pGraph), function operator[], file /usr/local/include/ogdf/basic/NodeArray.h, line 184.

This occurs when I run the example code given here for manual creation and layout of a graph in OGDF. The assertion failed message appears when I reach line 15:
GA.x(left) = -5*(i+1);

What's strange is that accessing the y-coordinate does not cause the assertion to fail, only the x-coordinate, which means it also crashes at line 21 if I comment out line 15. I did not modify the example code at all. It crashes out of the box. The random example code given here compiles, runs, and outputs a graph as expected. Although when I re-run it, the graph looks the same every time.

Any idea why I'm getting this assertion failed?

I compiled ogdf 2015.05 as a static lib from source on Mac OS X 10.7.5 with GNU 4.9.2 and cmake 3.2.3. I ran the unit tests and everything seemed to work okay (I believe there were some errors/warnings, but not until the very end. I will run it again and post the output in a reply. I will also try re-compiling without using cmake.

Tilo

unread,
Aug 20, 2015, 3:10:38 AM8/20/15
to ogdf
If you are absolutely sure you have made no modifications to the source code there must be something fishy.
The failed assertion indicates that the node does not belong to the graph associated with the attributes (more specifically with the node array m_x in the GraphAttributes object).
You could check these values manually but i can't see where this could go wrong.

Did you run the tests in debug mode?

dago...@soe.ucsc.edu

unread,
Aug 22, 2015, 6:59:58 PM8/22/15
to ogdf
Hello Tito,

Thanks for the reply. I am sure that the code is identical to the manual example code on the website: http://ogdf.net/doku.php/tech:howto:manual

I am not sure how to run the tests in debug mode. I've tried everything I can think of, but there's not debug output. I compiled and linked a debug version of OGDF by running
make debug
inside the ogdf folder, which I've checked out from github. So this time, I did not use cmake, but the default ogdf build system instead. This produced debug versions of the ogdf libraries. 

Then, I used cmake to compile my example code in debug mode by running:
cmake -DCMAKE_BUILD_TYPE=Debug ..

Here is the output:
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/bin/g++
-- Check for working CXX compiler: /usr/local/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Performing Test COMPILER_SUPPORTS_CXX0X
-- Performing Test COMPILER_SUPPORTS_CXX0X - Success
-- CMAKE_C_COMPILER: /usr/local/bin/gcc
-- CMAKE_CXX_COMPILER: /usr/local/bin/g++
-- CMAKE_COMPILER_IS_GNUCC: 1
-- CMAKE_COMPILER_IS_GNUCXX : 1
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/dagoodma/asl/dubins_coverage_cpp/examples/build-debug

Then when I run
make
I see
Scanning dependencies of target manual
[ 33%] Building CXX object CMakeFiles/manual.dir/manual.cpp.o
Linking CXX executable manual
[ 33%] Built target manual
Scanning dependencies of target random
[ 66%] Building CXX object CMakeFiles/random.dir/random.cpp.o
Linking CXX executable random
[ 66%] Built target random
Scanning dependencies of target sierpinski
[100%] Building CXX object CMakeFiles/sierpinski.dir/sierpinski.cpp.o
Linking CXX executable sierpinski
[100%] Built target sierpinski

Here is the verbose output where make is compiling the manual.cpp example:



I have a few different binaries. Random is the random generation example, which works fine. Sierpinksi is a sierpinski graph example I got from this website. It crashes in the same way that the manual graph example crashes: when it tries to access the x member of any node in the graph.

Here's the output when I try and run the manual example from the ogdf website that I mentioned in my previous post:
./manual
Assertion failed: (v->graphOf() == m_pGraph), function operator[], file /usr/local/include/ogdf/basic/NodeArray.h, line 184.
Abort trap: 6

As you can see, there's not debug output here, just the failed assertion. I am not quite sure what else I can try to trigger debugging output from OGDF. I was hoping to see some sort of stack trace or something along with the failed assertion, but there's nothing. Any idea what I should do?

Best,

dago...@soe.ucsc.edu

unread,
Aug 22, 2015, 7:02:50 PM8/22/15
to ogdf
Oops, I was posting the verbose output from make for manual.cpp and pressed Post before pasting it. This group will not let me edit my posts. Anyways, here is the output of make for manual.cpp:

[ 33%] Building CXX object CMakeFiles/manual.dir/manual.cpp.o
/usr/local/bin/g++    -std=c++11 -g -I/usr/local/include/ogdf -I/usr/local/include/coin    -o CMakeFiles/manual.dir/manual.cpp.o -c /Users/dagoodma/asl/dubins_coverage_cpp/examples/manual.cpp
Linking CXX executable manual
/usr/local/bin/g++    -std=c++11 -g -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/manual.dir/manual.cpp.o  -o manual  -lOGDF

Tilo

unread,
Aug 24, 2015, 9:35:18 AM8/24/15
to ogdf
Hi,

if you execute
cmake
after running
makeMakefile.py
you will override the Makefile generated by our script.


As you can see, there's not debug output here, just the failed assertion.

That's basically all the debug output you will get.
I was simply wondering whether you ran the OGDF unit tests in debug mode since you claimed they were passing.
Use a debugger to obtain a stack trace.

You might be doing something wrong when linking against the OGDF if the error occurs only in your executables but not in our tests.
Could you append the CMakeLists.txt used to configure your example and the code that produces the error?

Cheers
Tilo

dago...@soe.ucsc.edu

unread,
Sep 4, 2015, 7:34:54 AM9/4/15
to ogdf
I've tried getting gdb to produce a stack trace, but it never runs. It fails reading symbols for the shared libraries. Here is the output: http://pastebin.com/QQRW9d6C. According to a stackoverflow article, on a Mac the debug info is not linked into the symbol. Instead the .o files are in the /tmp folder. Apparently, the .o files are deleted after linking. I suppose I could try recompiling ogdf with the -save-temps=obj flag to keep the .o files under /tmp. This seems kind of silly to me though.

I'm sure that I've done something wrong, but what? I placed the libOGDF.a and libCOIN.a under /usr/local/lib, and I placed all of the header files under /usr/local/incude/ogdf and /usr/local/include/coin. I tried compiling and linking in separate steps to leave the object files from my example code in place, and I see the same problems. Here are the commands I used: 

g++ -g -ggdb -pedantic -Wall -std=c++0x -c ../manual.cpp
g
++ -g -o manual manual.o -static-libstdc++ -lOGDF -lCOIN

Here is my CMakeLists.txt:
# CMakeLists
cmake_minimum_required(VERSION 3.1)
project (EXAMPLES)

find_library(OGDF ogdf)
find_library(COIN coin)

## Set c++11
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

# Build and Link Executables

ADD_EXECUTABLE( manual manual.cpp )
ADD_EXECUTABLE( random random.cpp )
ADD_EXECUTABLE( sierpinski sierpinski.cpp )

TARGET_LINK_LIBRARIES( manual OGDF COIN )
TARGET_LINK_LIBRARIES( random OGDF COIN )
TARGET_LINK_LIBRARIES( sierpinski OGDF COIN )

# the compiler used for C files
MESSAGE( STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} )

# the compiler used for C++ files
MESSAGE( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )

# if the compiler is a variant of gcc, this should be set to 1
MESSAGE( STATUS "CMAKE_COMPILER_IS_GNUCC: " ${CMAKE_COMPILER_IS_GNUCC} )

# if the compiler is a variant of g++, this should be set to 1
MESSAGE( STATUS "CMAKE_COMPILER_IS_GNUCXX : " ${CMAKE_COMPILER_IS_GNUCXX} )

And here is the source file that fails, manual.cpp:
#include <ogdf/basic/Graph.h>
#include <ogdf/basic/GraphAttributes.h>
#include <ogdf/fileformats/GraphIO.h>

using namespace ogdf;

int main()
{
    Graph G;
    GraphAttributes GA(G, GraphAttributes::nodeGraphics | GraphAttributes::edgeGraphics );

    const int LEN = 11;
    for(int i = 1; i<LEN; ++i) {
        node left = G.newNode();
        GA.x(left) = -5*(i+1);
        GA.y(left) = -20*i;
        GA.width(left) = 10*(i+1);
        GA.height(left) = 15;

        node bottom = G.newNode();
        GA.x(bottom) = 20*(LEN-i);
        GA.y(bottom) = 5*(LEN+1-i);
        GA.width(bottom) = 15;
        GA.height(bottom) = 10*(LEN+1-i);

        edge e = G.newEdge(left,bottom);
        DPolyline &p = GA.bends(e);
        p.pushBack(DPoint(10,-20*i));
        p.pushBack(DPoint(20*(LEN-i),-10));
    }

    GraphIO::writeGML(GA, "manual_graph.gml");

    return 0;
}


Any more thoughts? Thanks again for your help.

Tilo

unread,
Sep 4, 2015, 8:23:27 AM9/4/15
to ogdf
> I've tried getting gdb to produce a stack trace, but it never runs. It fails reading symbols for the shared libraries.

You could try to update gdb. I had a similar issue using an older version. gdb 7.9 works for me.
Did you compile the OGDF in debug mode, too?


> I placed the libOGDF.a and libCOIN.a under /usr/local/lib

There usually is no need to copy OGDF headers / libraries anywhere.
You could instead tell CMake to use the include directory of your OGDF folder.
Likewise you may link directly against the compiled (non-copied) version of the OGDF and COIN static libraries.
This way, you can be sure that the library matches the included files.
This will of cource only help if something went wrong during copying the files.

You link your program using "-static-libstdc++", have you tried adding the same option to the OGDF compilation?

I am able to compile "manual.cpp" using this CMakeLists.txt:
# CMakeLists
cmake_minimum_required
(VERSION 3.1)
project
(EXAMPLES CXX)


## Set c++11
include
(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG
("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG
("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
   
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif
(COMPILER_SUPPORTS_CXX0X)
   
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message
(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif
()


include_directories
("~/workspace/OGDF/include")
link_directories
("~/workspace/OGDF")


# Build and Link Executables

ADD_EXECUTABLE
( manual manual.cpp )


TARGET_LINK_LIBRARIES
( manual OGDF COIN )

# the compiler used for C files
MESSAGE
( STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} )

# the compiler used for C++ files
MESSAGE
( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )

# if the compiler is a variant of gcc, this should be set to 1
MESSAGE
( STATUS "CMAKE_COMPILER_IS_GNUCC: " ${CMAKE_COMPILER_IS_GNUCC} )

# if the compiler is a variant of g++, this should be set to 1
MESSAGE
( STATUS "CMAKE_COMPILER_IS_GNUCXX : " ${CMAKE_COMPILER_IS_GNUCXX} )

Note that I had to specify the language of the project (Line 3).

Hope this helps in some way but I have no experience with Mac OS specific stuff.

dago...@soe.ucsc.edu

unread,
Sep 4, 2015, 4:40:07 PM9/4/15
to ogdf
Tilo,

I finally got it working! Manual runs and generates the gml file as expected. I set CXX for my project in cmake (like you showed in line 3 of your modified version of CMakeLists.txt). I think that was the fix. I also took your advice and linked to the libraries and header files in my OGDF folder. I tried that earlier though and it didn't work, which is why I later copied them to /usr/local. 

I am still trying to get gdb working. I updated gdb from v6.3.50 to v7.9.1. I had installed gcc-4.9.2 with a package manager (homebrew) to get c++11 support, but I never installed a compatible version of gdb, so I was still using an old version that came with XCode a few years ago. I am currently in the process of code-signing gdb so that it can run. Currently I see this message when I try to run the code I see this message:

Starting program: .../examples/ogdf/build-debug/manual
Unable to find Mach task port for process-id 71443: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

I will post here again with the results of my attempt to get gdb running incase someone else runs into the same issue.

Thanks again Tilo! 
 
Unable to find Mach task port for process-id 71443: (os/kern) failure (0x5).

dago...@soe.ucsc.edu

unread,
Sep 4, 2015, 9:15:47 PM9/4/15
to ogdf
To get the homebrew gdb working for mac, I followed the code-signing link posted above. I ended up with a lldb_codesign.cer on my desktop. Then, I ran 

codesign -s ~/Desktop/lldb_codesign /usr/local/bin/gdb

and entered my password. gdb now runs, but I do see lots of warnings about missing symbols in /tmp. Oh well, it seems to do what it's supposed to. Problem solved.

Franziska

unread,
Dec 29, 2017, 5:06:27 PM12/29/17
to ogdf
Dear Tilo,

I have the same issue and using your Cmake file does not help me. I build it from the current git version and get the message: 

build_debug franziska$ ./ogdfLayoutTest
Assertion failed: (v->graphOf() == m_pGraph), function operator[], file /Users/franziska/external_libraries/ogdf-2017-12-25/OGDF/include/ogdf/basic/NodeArray.h, line 172.
Abort trap: 6

Building the .cpp file from https://ogdf.github.io/doc/ogdf-snapshot/ex-basic.html with your cmake file and the correct paths to the ogdf-include and ogdf-library works without any linking errors and only executing the object-file results in the assertion.

...
[100%] Linking CXX static library libOGDF.a
[100%] Built target OGDF

Here the cmake changes I have done:

include_directories("/Users/franziska/external_libraries/ogdf-2017-12-25/OGDF/include")
include_directories
("/Users/franziska/external_libraries/ogdf-2017-12-25/ogdf-debug/include")
link_directories
("/Users/franziska/external_libraries/ogdf-2017-12-25/ogdf-debug")

"cmake":
 
{
 
"build_folder": "/Users/franziska/ogdf_test/build_debug",
 
"command_line_overrides":
 
{
 
"CMAKE_BUILD_TYPE": "Debug"
 
},
 
"generator": "Unix Makefiles",
 
"windows":
 
{
 
"generator": "Visual Studio"
 
}
 
},


The output of the cmake:

-- CMAKE_C_COMPILER:
-- CMAKE_CXX_COMPILER: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- CMAKE_COMPILER_IS_GNUCC:
-- CMAKE_COMPILER_IS_GNUCXX :
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/franziska/ogdf_test/build_debug
[Finished in 0.1s]

The output of the build:

Scanning dependencies of target ogdfLayoutTest
[ 50%] Building CXX object CMakeFiles/ogdfLayoutTest.dir/src/runnables/ogdf_ManualCreateLayout.cpp.o
[100%] Linking CXX executable ogdfLayoutTest
[100%] Built target ogdfLayoutTest
[Finished in 1.6s]

I would be very thankful for your help.

Best regards,
Franzi

Tilo

unread,
Jan 2, 2018, 3:26:19 AM1/2/18
to ogdf
Dear Franzi,

the old CMakeLists.txt is still working for me.
Note that I never tested it with XCode/Clang.

The OGDF's latest git version includes targets for compiling example files.
See doc/examples/basic/manual.cpp that can be compiled and executed by calling
make ex-manual && doc/examples/basic/ex-manual

Cheers
Tilo

Franziska

unread,
Jan 7, 2018, 9:03:31 AM1/7/18
to ogdf
Dear Tilo,

that worked. However, it is not a solution for me to integrated into my project, which uses cmake. I do not know what causes the problem. For building OGDF, I used clang as well so if this is the problem I expect a failure during the OGDF build or a linking error during my build, but not this. 

Thanks.

Franzi

Tilo

unread,
Jan 8, 2018, 2:20:32 AM1/8/18
to ogdf
Hi Franziska,

> that worked.

This shows that there is a problem with your build script / configuration rather than with the OGDF.

>  it is not a solution for me to integrated into my project, which uses cmake. I do not know what causes the problem.

You should be able to figure out the problem by gradually switching from our build process to yours.

You wrote that you made sure to use matching library/headers and debug mode for your executable. Still, I recommend to double-check this.
Is your OGDF source directory clean or did you generate build files in-source as well? That could mess things up.

Hope this helps
Tilo

Franziska

unread,
May 23, 2018, 4:08:43 AM5/23/18
to ogdf
Hi Tilo,

sorry for my late response. The error is only generated in DEBUG mode and not in Release mode. To run my own code in DEBUG mode I had to use the DEBUG version of OGDF. No additional flags needed. 

Best regards,
Franzi
Reply all
Reply to author
Forward
0 new messages