Skip to content

Commit

Permalink
VerboseGC Initialized Stanza Print Fix
Browse files Browse the repository at this point in the history
Using `printf` methods _(e.g `omrfile_printf` & `omrfilestream_printf`)_
to write to files is problematic when the output buffer contains a
string with a specifier character (e.g %s). In such a case, the special
character is intended to be be outputted raw to the file rather than
evaluated/expanded. `printf` will attempt to evaluate the specifiers
whereas the buffer must be printed raw. Currently, `printf` methods are
used when outputting verbose initialized block (string).

When outputting the init block, use the verbose writer's `outputString`
method rather than using
- `omrfilestream_printf` for FileLoggingSynchronous Writer
- `omrfile_printf` for FileLoggingBuffered Writer

`outputString` will use `omrfile_write_text` and just print the raw
characters.

Signed-off-by: Salman Rana <salman.rana@ibm.com>
  • Loading branch information
RSalman committed Feb 10, 2021
1 parent 12f08da commit 7ada644
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gc/verbose/VerboseWriterFileLoggingBuffered.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ MM_VerboseWriterFileLoggingBuffered::openFile(MM_EnvironmentBase *env, bool prin
MM_VerboseBuffer* buffer = MM_VerboseBuffer::newInstance(env, INITIAL_BUFFER_SIZE);
if (NULL != buffer) {
_manager->getVerboseHandlerOutput()->outputInitializedStanza(env, buffer);
omrfilestream_printf(_logFileStream, buffer->contents());
outputString(env, buffer->contents());
buffer->kill(env);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gc/verbose/VerboseWriterFileLoggingSynchronous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ MM_VerboseWriterFileLoggingSynchronous::openFile(MM_EnvironmentBase *env, bool p
MM_VerboseBuffer* buffer = MM_VerboseBuffer::newInstance(env, INITIAL_BUFFER_SIZE);
if (NULL != buffer) {
_manager->getVerboseHandlerOutput()->outputInitializedStanza(env, buffer);
omrfile_printf(_logFileDescriptor, buffer->contents());
outputString(env, buffer->contents());
buffer->kill(env);
}
}
Expand Down

1 comment on commit 7ada644

@maciej19861317
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Please sign in to comment.