#pragma omp parallel: igraph_error.c:186: IGRAPH_FINALLY_REAL: Assertion `no < 100' failed

Dear igraph users,

I’m running my c++ code under multiple threads on Ubuntu with OpenMP and functions from the igraph c library. However, sometimes I get the error ‘igraph_error.c:186: IGRAPH_FINALLY_REAL: Assertion `no < 100’ failed.’, and when I run it without parallelism, there’s no error.

Could any of you give some hints about what’s going wrong?

Thanks in advance.
Peng

In order to use igraph in a multi-threaded setting, you must pass the option --enable-tls (enable thread-local storage) to ./configure when compiling igraph. This should resolve the problem you are seeing, but this option is not very well tested. Personally, I have never used igraph from multiple threads.

Note that this option does not make it safe to manipulate igraph_t objects from multiple threads. If you are running a graph algorithm which only reads, but never modifies the graph, then it should be okay. Trying to modify the graph from multiple threads will mess things up though.

Let us know how it went with --enable-tls. Feedback is always welcome.

1 Like

Thanks for the response.

I think in my case it was very likely because of data racing when writing from different threads to the shared object. I did not re-compile igraph with the --enable-tls flag, and instead, I declared that each thread should copy (and thus initialized with) the shared object first before computing, by adding the firstprivate clause in the OpenMP section, and it worked (i.e. instead of writing to the shared object, I copy it in each thread and write to the copies as temporal objects independently). Sorry my code is too long to demonstrate how it worked here, and it seems the problem had nothing to do with the igraph but my fault.

P

igraph uses global data structures internally, for error handling. If these are shared between threads, something is pretty much guaranteed to fail eventually. It is not sufficient to copy an igraph_t that you are working with.

EDIT: To be clear, what you are doing is bound to fail, whether your program has already crashed or not. Any readers of this beware, do not do this!

Thanks and good to know that :slight_smile:
I avoided using igraph_t and used matrices (igraph_matrix_t) instead in such case, and things seem went smoothly.

P