[go: up one dir, main page]

Plan to Remove global library state

Steps to reproduce

I implemented a graph viewer Widget for Qt, using a QPainter renderer plugin, like gtk+pango. It is based on QQuickPaintedItem. I also use the Event loop approach in struct gvdevice_engine_s::finalize callback as in gtk. The parsing and layouting takes place in a separate QThread. When the finalize step of the Painter Device is reached, a nested QEventLoop is started which simply waits. The refresh callback is called in the context of QQuickPaintedItem::paint().

Having exactly one instance of the Widget works very well. But when I create multiple instances, the application crashes due to graphviz assertations:

appDemoGui: graph.c:116: agclose: Zusicherung »dtsize(g->n_id) == 0« nicht erfüllt.

Following #1282 (closed), graphviz is known to be not thread-safe. This is due to a lot of global and static local variables. I ran a very quick check with clang-tidy, which has a cppcoreguidelines-avoid-non-const-global-variables check. Running this check on every .c file under lib/ gave approx. 630 hits, which means that more than 600 non-const global variables exists. There are probably a lot which can be marked as const.

Is there any plan to change that? Of course, I'm happy to help.

More background: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rconc-multi

Expected Behaviour

Graphviz being able to run multiple gvc instances in distinct threads.

Actual Behaviour

Show any unexpected output

OS Version

openSuSE Tumbleweed

Graphviz Version

dot - graphviz version 2.49.3 (0)

Additional info

Fill in with anything else that might be important.