Ticket #3605 (closed defect: fixed)

Opened 5 months ago

Last modified 3 months ago

IOError: [Errno 32] Broken pipe when rendering graph

Reported by: pickscrape Assigned to: cboos
Priority: high Component: GraphvizPlugin
Severity: critical Keywords:
Cc: Trac Release: 0.11

Description

The grahviz plugin used to work justfine for us, but at some point over the last few months it stopped doing so.

In that time we upgraded to 0.11, and also upgrade graphviz itself a number of times, so it it difficult to pinpoint exactly what caused the problem.

Anyway, the backtrace we are getting is as follows:

2008-08-25 15:52:41,487 Trac[main] ERROR: [Errno 32] Broken pipe
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 423, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 219, in dispatch
    data, content_type)
  File "/usr/lib/python2.5/site-packages/trac/web/chrome.py", line 726, in render_template
    stream.render(method, doctype=doctype, out=buffer)
  File "/usr/lib/python2.5/site-packages/genshi/core.py", line 179, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/lib/python2.5/site-packages/genshi/output.py", line 61, in encode
    for chunk in iterator:
  File "/usr/lib/python2.5/site-packages/genshi/output.py", line 311, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.5/site-packages/genshi/output.py", line 753, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.5/site-packages/genshi/output.py", line 592, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.5/site-packages/genshi/output.py", line 698, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/lib/python2.5/site-packages/genshi/output.py", line 532, in __call__
    for ev in stream:
  File "/usr/lib/python2.5/site-packages/genshi/core.py", line 283, in _ensure
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/core.py", line 283, in _ensure
    for event in stream:
  File "/usr/lib/python2.5/site-packages/trac/web/chrome.py", line 779, in _strip_accesskeys
    for kind, data, pos in stream:
  File "/usr/lib/python2.5/site-packages/genshi/core.py", line 283, in _ensure
    for event in stream:
  File "/usr/lib/python2.5/site-packages/trac/web/chrome.py", line 768, in _generate
    for kind, data, pos in stream:
  File "/usr/lib/python2.5/site-packages/genshi/core.py", line 283, in _ensure
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 569, in _include
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/markup.py", line 298, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/python2.5/site-packages/genshi/template/markup.py", line 298, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/python2.5/site-packages/genshi/template/markup.py", line 245, in _match
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 543, in _exec
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 533, in _eval
    for event in substream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 496, in _eval
    for kind, data, pos in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 551, in _flatten
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/core.py", line 283, in _ensure
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/path.py", line 141, in _generate
    subevent = stream.next()
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 569, in _include
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/markup.py", line 234, in _strip
    event = stream.next()                                                                               
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 543, in _exec
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 533, in _eval
    for event in substream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 496, in _eval
    for kind, data, pos in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 551, in _flatten
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/core.py", line 283, in _ensure
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/path.py", line 141, in _generate
    subevent = stream.next()
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 569, in _include
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/markup.py", line 234, in _strip
    event = stream.next()
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 543, in _exec
    for event in stream:
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 520, in _eval
    result = _eval_expr(data, ctxt, **vars)
  File "/usr/lib/python2.5/site-packages/genshi/template/base.py", line 286, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "/usr/lib/python2.5/site-packages/genshi/template/eval.py", line 180, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "/usr/lib/python2.5/site-packages/trac/wiki/templates/wiki_view.html", line 37, in <Expression u'wiki_to_html(context, page.text)'>
    ${wiki_to_html(context, page.text)}
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 1095, in format_to_html
    return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 1054, in generate
    escape_newlines)
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 833, in format
    self.handle_code_block(line)
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 764, in handle_code_block
    processed = self.code_processor.process(code_text)
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 179, in process
    text = self.processor(text)
  File "/usr/lib/python2.5/site-packages/trac/wiki/formatter.py", line 166, in _macro_processor
    text)
  File "build/bdist.linux-i686/egg/graphviz/graphviz.py", line 227, in expand_macro
    out, err = self.launch(cmd, content)
  File "build/bdist.linux-i686/egg/graphviz/graphviz.py", line 430, in launch
    p.stdin.write(input)
IOError: [Errno 32] Broken pipe

Now, we do know that graphviz itself is installed and working properly on the server because it works just fine with the masterticket plugin: this only seems to affect the graphviz plugin.

Any help would be appreciated: we miss our graphs. :)

Attachments

Change History

09/21/08 14:24:11 changed by franck34

Seem's a problem occured when launching graphviz tools.

In the source code, there is some debug message. Uncomment them to see all command line which are launched (2 in general). Then, try to launch them manualy. If you got a segfault or something like that, it's related to your graphviz install, but not the plugin.

Please tell us if you are using win32 or linux and which install (mod_python, other ...)

09/24/08 09:12:26 changed by pickscrape

Hi, thanks for your response.

We are running on gentoo linux with trac running through mod_python.

I enabled the debugging as requested and got the following output:

2008-09-24 14:23:40,273 Trac[graphviz] DEBUG: render_macro: render other image formats - running command [u'/usr/bin/dot', '', u'-Tpng', u'-o/var/tmp/trac/htdocs/graphviz/dbbc42700225787cb9bb6fb6f1dd75d24734b999.dot.png']
2008-09-24 14:23:40,282 Trac[graphviz] ERROR: The command
   [u'/usr/bin/dot', '', u'-Tpng', u'-o/var/tmp/trac/htdocs/graphviz/dbbc42700225787cb9bb6fb6f1dd75d24734b999.dot.png']
failed with the the following output:

Error: dot: can't open

/usr/bin/dot definitely exists and belongs to the graphviz package:

# /usr/bin/dot -V
dot - Graphviz version 2.20.2 (Mon Aug 25 13:07:52 UTC 2008)

If I just run the comment given:

/usr/bin/dot -Tpng -o/var/tmp/trac/htdocs/graphviz/8ba4511395eb047b7d14f21f88f78738037acddd.dot.png

It just sits there, presumably waiting for data to be piped to it?

As I say, graphviz works fine with the mastertickets plugin when rendering its depgraph.

09/26/08 03:59:55 changed by cboos

I just had the same issue. The problem is in the above command:

[u'/usr/bin/dot', '', u'-Tpng', ...

Note the empty first argument, this is what triggers the Error: dot: can't open message.

Possible fix:

diff -r abb5c1031a4e -r 8c16d9f0cdb3 graphviz/graphviz.py
--- a/graphviz/graphviz.py      Fri Sep 26 10:45:38 2008 +0200
+++ b/graphviz/graphviz.py      Fri Sep 26 10:49:55 2008 +0200
@@ -424,7 +424,7 @@

     def launch(self, cmd, input):
         """Launch a process (cmd), and returns exitcode, stdout + stderr"""
-        p = subprocess.Popen(cmd,
+        p = subprocess.Popen([arg for arg in cmd if arg],
                              stdin=subprocess.PIPE,
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)

09/26/08 04:19:26 changed by cboos

  • priority changed from normal to high.
  • severity changed from normal to critical.

Several duplicates (#3304, #3663), raising the priority and severity, as this prevents the plugin from working.

09/26/08 05:43:13 changed by cpenas at warp.es

I'm debuging this issue too . I found that the empty second item in the 'cmd' Array is causing the bug. This item is empty if there's no default_* options in configuration

I workarrounded it placing a cmd.remove() and then worked for me.

I'm using trac 0.11 and mod_python

09/26/08 06:49:29 changed by pickscrape

Adding the cmd.remove() worked for me too.

I'm sure the other way would also have worked too.

Thanks so much for looking at it. I have happy users again. :)

09/26/08 14:52:01 changed by bill.coffman@gmail.com

The patch in comment:3 also fixed #3756 ... thanks.

09/27/08 18:14:21 changed by kenneth

comment:3 works for me too!

10/06/08 12:09:37 changed by cboos

  • owner changed from pkropf to cboos.

patch from comment:3 applied in [4394], just because I had it lying around...

10/06/08 12:10:22 changed by cboos

  • status changed from new to closed.
  • resolution set to fixed.

... but a more extensive fix for this issue can be found in [4395] (avoiding the empty optional argument list altogether).


Add/Change #3605 (IOError: [Errno 32] Broken pipe when rendering graph)




Change Properties
Action