Skip to content
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

slang-netlist appends garbage at end of (short) .dot files #955

Closed
udif opened this issue Apr 7, 2024 · 0 comments · Fixed by #959
Closed

slang-netlist appends garbage at end of (short) .dot files #955

udif opened this issue Apr 7, 2024 · 0 comments · Fixed by #959

Comments

@udif
Copy link
Contributor

udif commented Apr 7, 2024

@jameshanlon

Describe the bug
When creating short .dot files, garbage binary data is appended to the output.

To Reproduce

udif@localhost:~/git/slang$ cat t19.v
module x;
endmodule
udif@localhost:~/git/slang$ slang-netlist --netlist-dot t19.dot t19.v
Top level design units:
    x

Build succeeded: 0 errors, 0 warnings
udif@localhost:~/git/slang$ od -xc t19.dot
0000000    6964    7267    7061    2068    0a7b    2020    6f6e    6564
          d   i   g   r   a   p   h       {  \n           n   o   d   e
0000020    5b20    6873    7061    3d65    6572    6f63    6472    3b5d
              [   s   h   a   p   e   =   r   e   c   o   r   d   ]   ;
0000040    7d0a    950a    7ffd
         \n   }  \n 225 375 177
0000046

Additional context
As you can see, the t19.dot valid data is followed by 3 random binary bytes.
Following the code, the source of the bug is because printDOT() is using slang::FormatBuffer buffer to collect output data.
This buffer is not cleared when allocated, but has a size field instead.
In the end of printDOT(), the buffer is printed by OS::writeFile(fileName, buffer.data());, but as far as I can tell, buffer.data() no longer carries the size, only a pointer to the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants