This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] exploded-graph-rewriter: Fix python3 string encoding issues
ClosedPublic

Authored by steakhal on Aug 10 2022, 2:53 AM.

Details

Summary

This encapsulates 3 changes:

  • DotDumpVisitor now aggregates strings instead of bytes for both python2 and python3. This difference caused crashes when it tried to write out the content as strings, similarly described at D71746.
  • graphviz.pipe() expects the input in *bytes* instead of unicode strings. And it results in bytes. Due to string concatenations and similar operations, I'm using unicode string as the default and converting to bytes on demand.
  • write_temp_file() now appends the egraph- prefix and more importantly, it will create the temp file in the current working directory instead of in the temp. This change makes Firefox be able to open the file even if the security.sandbox.content.level is set to the (default) most restricting 4. See https://support.mozilla.org/si/questions/1259285

An artifact of the bad byte handling was previously in the HTML
produced by the script that it displayed the b' string at the top left
corner. Now it won't anymore :)

I've tested that the following command works on Ubuntu 22.04:

exploded-graph-rewriter my-egraph.dot

Both python2 and python3 works as expected.


PS: I'm not adding tests, as the current test infra does not support
testing HTML outputs for this script.
Check the clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg.
We always pass the --dump-dot-only flag to the script.
Along with that, the default invocation will not only create this HTML
report but also try to open it. In addition to this, I'm not sure if the
buildbots have graphviz installed and also if this package is installed
on pip.
Unless we change some of these, we cannot test this change.
Given that D71746 had no tests, I'm not too worried about this either.

Diff Detail

Event Timeline

steakhal created this revision.Aug 10 2022, 2:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 2:53 AM
steakhal requested review of this revision.Aug 10 2022, 2:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 2:53 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal edited the summary of this revision. (Show Details)Aug 10 2022, 2:56 AM
NoQ accepted this revision.Aug 10 2022, 1:06 PM

Thanks for figuring all of this out! Looks great!

That's right, we can't and probably shouldn't test graphviz.

clang/utils/analyzer/exploded-graph-rewriter.py
862

I think the reminder is still relevant. These files can be like 100mb in size, and now that they aren't in /tmp they aren't autocleaned.

This revision is now accepted and ready to land.Aug 10 2022, 1:06 PM
This revision was automatically updated to reflect the committed changes.
steakhal marked an inline comment as done.