-
Notifications
You must be signed in to change notification settings - Fork 837
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
Allow ncclDebugLog to print messages longer than 1024 bytes #1215
base: master
Are you sure you want to change the base?
Conversation
Can you explain concretely why it's better than it was? I.e. what didn't work before that works now, and how it's achieved. Also, from a quick glance at the code, it looks like when len == sizeof(buffer) we write \0 in buffer[len], which is out of bounds. |
Thank you for looking at this! Here's the use case:
Before the patch this would print:
After the patch this would print:
How is this achieved: long strings are not copied into the on-stack buffer and are passed directly to It may seem a bit silly to support such long strings, but I ran into this in a real use case: printing out some JSON. |
For
so we'll move |
Ok, it took me a long time but I now understand what we do. Instead of developping That works, but then a lot of the rest of the code seems incorrect. If we keep I think we should fail (or just print an error message) if the Header + fmt doesn't fit within the buffer size; that will simplify the code a lot. We don't want to truncate, rewind, add \n, \0 etc. So I'd want some refactoring of this code if we change our strategy completely, to make it clean and safe. |
The only weird case would be when we truncate the format string after a But I agree that this could be simplified a lot. Let me take another stab at it. |
Cleaned this up a bit. I believe this version is always safe, even if the format string is too long. |
Other uses also run into this limitation: #825 |
Instead of copying the message into the 1KB buffer, use the buffer to create a prefixed format string and then directly pass that to
vfprintf
. This makes it possible to print larger messages which can be handy for debugging.