Skip to content

max_cliques() on a directed graph segfaults (C stack overflow) if any_multiple() was called first (igraph 2.3.3) #2748

Description

@jhollway

What happens, and what did you expect instead?

Calling max_cliques() on a directed graph crashes R with Error: segfault from C stack overflow — but only if any_multiple() has been called on the graph beforehand. Either call alone is fine.

Additional observations:

  • max_cliques(g) alone works (returns 12 cliques, with the expected "Edge directions are ignored" warning). any_multiple(g) alone works.
  • Wrapping the call in suppressWarnings() does not prevent the crash.
  • The crash is specific to any_multiple() as the priming call: which_multiple(g), any_loop(g), or is_connected(g) before max_cliques(g) do not crash.
  • Undirected graphs are unaffected: max_cliques(as_undirected(g, mode = "collapse")) after any_multiple() is fine, suggesting the trigger is the directed-graph warning path in max_cliques().
  • In a sequence that doesn't crash, the "Edge directions are ignored for maximal clique calculations" warning is mis-attributed to has_multiple_impl (In has_multiple_impl(graph = graph) : Edge directions are ignored..., source cliques/maximal_cliques_template.h:221), which may point to stale condition-handler state left by any_multiple().

Found while testing the manynet package, but reproduces with igraph alone in a fresh session.

To reproduce

library(igraph) # 2.3.3
set.seed(1)
m <- matrix(rbinom(64, 1, .5), 8, 8); diag(m) <- 0
g <- graph_from_adjacency_matrix(m) # directed
invisible(any_multiple(g))
max_cliques(g)
#> Error: segfault from C stack overflow

System information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions