-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix gvRenderData bytes output #424
Fix gvRenderData bytes output #424
Conversation
…correct result even if the output contains NULL bytes For example, this allows AGraph._draw() to return a correct result with the "png" format
My local SWIG installation is 4.0.1, so this contains additional modifications. This also required an additional compile variable in setup.py. It is probably not necessary if the files are regenerated with SWIG 4.0.2 again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Nagael , this seems good. The one missing piece is a test that illustrates the failure; i.e. something that fails with the current code that passes with this patch. Do you have any example cases where you hit this problem that could be added to the test suite?
Thanks for your answer. I just added a commit with a test that fails on the current version. It asks for the |
Codecov Report
@@ Coverage Diff @@
## main #424 +/- ##
==========================================
- Coverage 80.87% 80.86% -0.02%
==========================================
Files 5 5
Lines 1255 1254 -1
==========================================
- Hits 1015 1014 -1
Misses 240 240
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @Nagael . I went ahead and re-generated graphviz.py
and graphviz_wrap.c
with SWIG 4.0.2. I'm not too familiar with SWIG, so if you wouldn't mind taking a quick look at the generated graphviz_wrap.c
code to verify that everything looks as expected that'd be great.
I also went ahead and renamed/added a comment to the test so we have a better idea of what it's designed to catch. If you have any wording/name changes you think would be better, please go ahead and make them. Other than that, this LGTM! We always squash-merge so no need to worry about cleaning up the history.
Thanks @rossbar, everything looks just as expected and works smoothly. Looks good to me too! |
Great, then in this goes (the failing CI is a known issue). Thanks again @Nagael ! |
* Bugfix: correctly use the size returned by gvRenderData, returning a correct result even if the output contains NULL bytes For example, this allows AGraph._draw() to return a correct result with the "png" format * Regenerate SWIG-generated files. * Add test demonstrating failure with png output format due to NULL in cstring Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
This PR fixes the
AGraph._draw(format='png')
case. The PNG format can contain NULL bytes, so this call could result in an assertion error:This fix correctly uses SWIG's
%cstring_output_allocate_size(parm, szparm, release)
instead of%cstring_output_allocate(parm, release)
(as explained in 11.3.4 of https://www.swig.org/Doc4.0/Library.html)Unfortunately my local SWIG installation is 4.0.1, so the regenerated SWIG files are more different than strictly necessary. The first commit is the main one, though.