lol

I
just registered to link this here, since I found this post while searching for solutions before I found the problem.
Since I have just gone through all the funny "let's figure out why graphviz is broken!" stuff and won, I'd be happy to help investigate this issue.
First things first: Grab the URL of your broken graph image and download it manually, for example with wget or curl. Look at it in a hex editor.
If you see text or nothing, then there was nothing actually being generated.
If you see a bunch of gibberish (i.e. binary data), then there's data there, and we'll have to figure out what it is: Check if the bytes 89 50 4E 47 (probably displayed as ".PNG") are at the very beginning, or close to it.
If at the very beginning, then the file at least starts as a proper PNG file, and there must be corruption later on.
If close to the beginning, but not quite, you probably have the same issue I had. See if my patch helps you.
If there's no such value at the beginning, you're getting garbage data, and we'll have to figure out why.
Assuming you either got text/nothing or garbage data, we'll check if graphviz works first:
Assuming you have shell access, save the following code
Code: Select all
digraph G
{
node [shape = record];
node0 [ label ="<f0> | <f1> J | <f2> "];
node1 [ label ="<f0> | <f1> E | <f2> "];
node4 [ label ="<f0> | <f1> C | <f2> "];
node6 [ label ="<f0> | <f1> I | <f2> "];
node2 [ label ="<f0> | <f1> U | <f2> "];
node5 [ label ="<f0> | <f1> N | <f2> "];
node9 [ label ="<f0> | <f1> Y | <f2> "];
node8 [ label ="<f0> | <f1> W | <f2> "];
node10 [ label ="<f0> | <f1> Z | <f2> "];
node7 [ label ="<f0> | <f1> A | <f2> "];
node3 [ label ="<f0> | <f1> G | <f2> "];
"node0":f0 -> "node1":f1;
"node0":f2 -> "node2":f1;
"node1":f0 -> "node4":f1;
"node1":f2 -> "node6":f1;
"node4":f0 -> "node7":f1;
"node4":f2 -> "node3":f1;
"node2":f0 -> "node5":f1;
"node2":f2 -> "node9":f1;
"node9":f0 -> "node8":f1;
"node9":f2 -> "node10":f1;
}
as a text file (dottest.txt), and try to run graphviz manually with it, like
Code: Select all
dot -Tpng -o dottest.png dottest.txt
see if dottest.png is a proper PNG file. If so, the issue is not with graphviz.
It it's not, try
and see what it complains about. It's possible it's simply not compiled with support, or you're lacking a library.
If that succeeded, go into core/graphviz_api.php
and look for
Code: Select all
$t_descriptors = array(
0 => array(
'pipe',
'r',
),
1 => array(
'pipe',
'w',
),
2 => array(
'file',
'php://stderr',
'w',
),
)
comment it out, and replace it with
Code: Select all
$t_descriptors = array(
0 => array("pipe", "r"),
1 => array("file", "/tmp/dot_file.png", "a"),
2 => array("file", "/tmp/error-output.txt", "a")
)
Warning: On my server, that regularly tried to exceed PHP's memory limits. Make sure you have a sane cutoff in the config, or make sure you have a kill switch at hand before you trigger this.
Once you do run it, you will find out something very important: Whether the issue is with the creation of the image, or with the saving/sending part.
Since the actual graph now bypasses Mantis's processing and sending, simply checking whether /tmp/dot_file.png is a proper graph should tell you whether the graph gets created alright or not.
(Remember to revert the array change once you have a clear result.)
If the graph not being properly created when bypassing Mantis, check /tmp/error-output.txt, and, if that is empty, check if your webserver-user has the proper access rights to graphviz and that kind of stuff.
If the graph
is properly being created, the issue is with the saving/outputting and sending of the graph, which will narrow the search down a bit.
As someone who just spent several hours debugging an error like this, rest assured, I know how frustrating it is.
The best thing you can do is systematically rule out error sources and narrow down what and where the actual issue is.
- Is it in the file?
- Is it in GraphViz?
- Is it in PHP or the webserver?
- Is it in Mantis?
Once you know what you can rule out, it'll be much easier to find the actual source.
Hope this helps a little, and do report back what you find.