Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in GraphSymmetryFinder destructor #3954

Open
andre-tebart opened this issue Oct 13, 2023 · 5 comments
Open

Segmentation fault in GraphSymmetryFinder destructor #3954

andre-tebart opened this issue Oct 13, 2023 · 5 comments
Assignees
Labels
Help Needed Modeling/Usage problem Lang: C++ Native implementation issue Solver: Graph and Algorithm Solvers in the graph/ and algorithms/ directories
Milestone

Comments

@andre-tebart
Copy link

andre-tebart commented Oct 13, 2023

What version of OR-Tools and what language are you using?
Version: v9.7
Language: C++

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
GraphSymmetryFinder

What operating system (Linux, Windows, ...) and version?
Ubuntu 22.04

What did you do?
Steps to reproduce the behavior:

#include <doctest/doctest.h>
#include <ortools/algorithms/sparse_permutation.h>
#include <ortools/algorithms/find_graph_symmetries.h>
#include <ortools/graph/graph.h>

TEST_SUITE("or-tools symmetry finder") {
    TEST_CASE("finds symmetries") {
        auto graph = operations_research::GraphSymmetryFinder::Graph{};
        graph.Build();

        auto symmetryFinder = operations_research::GraphSymmetryFinder(graph, true);
    }
}

I run this code snippet via doctest.

What did you expect to see
I expect this to just run through.

What did you see instead?
The program crashes with a segmentation violation signal. This is the stack trace I get:

std::_Rb_tree_increment(std::_Rb_tree_node_base*) 0x00007fffefa6a1d4
operations_research::StatsGroup::~StatsGroup() 0x00007ffff0ad87e9
operations_research::GraphSymmetryFinder::Stats::~Stats find_graph_symmetries.h:249
operations_research::GraphSymmetryFinder::~GraphSymmetryFinder find_graph_symmetries.h:45
DOCTEST_ANON_SUITE_14::DOCTEST_ANON_FUNC_15 graph_symmetry.test.cpp:12
doctest::Context::run doctest.h:7007
main test_main.cpp:8
<unknown> 0x00007fffef79bd90
__libc_start_main 0x00007fffef79be40
_start 0x0000555555555145

Anything else we should know about your project / environment
We also use CP-SAT in our project and don't have any issues there.

@Mizux Mizux added this to the v9.9 milestone Oct 13, 2023
@Mizux
Copy link
Collaborator

Mizux commented Oct 13, 2023

From an internal test:

using Graph = GraphSymmetryFinder::Graph;

Graph graph;
for (const std::pair<int, int>& arc : arcs) {
graph.AddArc(arc.first, arc.second);
}
graph.Build();
GraphSymmetryFinder symmetry_finder(graph, GraphIsSymmetric(graph));

two questions:

  1. Does a graph with no arc "is symmetric" ?
  2. Why not using GraphIsSymmetric(graph) ?
@Mizux
Copy link
Collaborator

Mizux commented Oct 13, 2023

  1. Does a graph with no arc is symmetric ?

Seems the second arg means "is_undirect"

// If the Graph passed to the GraphSymmetryFinder is undirected, i.e.
// for every arc a->b, b->a is also present, then you should set
// "is_undirected" to true.
// This will, in effect, DCHECK() that the graph is indeed undirected,
// and bypass the need for reverse adjacency lists.
//
// If you don't know this in advance, you may use GraphIsSymmetric() from
// ortools/graph/util.h.
//
// "graph" must not have multi-arcs.
// TODO(user): support multi-arcs.
GraphSymmetryFinder(const Graph& graph, bool is_undirected);

@Mizux Mizux self-assigned this Oct 13, 2023
@Mizux Mizux added Help Needed Modeling/Usage problem Lang: C++ Native implementation issue Solver: Graph and Algorithm Solvers in the graph/ and algorithms/ directories labels Oct 13, 2023
@andre-tebart
Copy link
Author

The error also occurs with a non empty undirected graph. You get correct results from the symmetry finder but it still crashes in the destructor.

@lperron
Copy link
Collaborator

lperron commented Oct 16, 2023

We have added unit test on our code, and it does not crash.

@Mizux
Copy link
Collaborator

Mizux commented Oct 16, 2023

see d0eb8dd

note: currently not supported nor run when using cmake based build...

@Mizux Mizux modified the milestones: v9.9, v10.0 Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Needed Modeling/Usage problem Lang: C++ Native implementation issue Solver: Graph and Algorithm Solvers in the graph/ and algorithms/ directories
3 participants