Skip to content

Fix SegFault of using the logger to print the stream_id (which is char[16]) as a string. - #117

Merged
Zhihua Lai (doctorlai-msrc) merged 1 commit into
devfrom
fixprint16
Jul 2, 2025
Merged

Zhihua Lai (doctorlai-msrc) merged 1 commit into
devfrom
fixprint16

Conversation

@doctorlai-msrc

@doctorlai-msrc Zhihua Lai (doctorlai-msrc) commented Jun 30, 2025 •

Copy link
Copy Markdown
Collaborator

This PR fixes the bug that causes a segfault by using the logger to print the stream_id (which is char[16]) as a string. Therefore, this PR converts the stream_id to string first before using the jbpf_logger to print it as string type e.g. %s.

Tested in pipeline:
image

@xfoukas Xenofon Foukas (xfoukas) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The description of the PR is somehow misleading. The stream id is not a string, so it shouldn't be used for logging, unless it is first converted to string (which is what this PR does). Please update the description to explain that this is a bugfix in the way that the logger was used to print a non-string.

@doctorlai-msrc Zhihua Lai (doctorlai-msrc) changed the title Fix SegFault by printing %s stream_id Fix SegFault of using the logger to print the stream_id (which is char[16]) as a string. Jul 1, 2025
@doctorlai-msrc

Copy link
Copy Markdown
Collaborator Author

The description of the PR is somehow misleading. The stream id is not a string, so it shouldn't be used for logging, unless it is first converted to string (which is what this PR does). Please update the description to explain that this is a bugfix in the way that the logger was used to print a non-string.

Fixed.

auto-merge was automatically disabled July 1, 2025 18:13

Pull request was closed

Comment thread src/io/jbpf_io_channel.c
io_channel,
io_channel->stream_id.id);
char sname[JBPF_IO_STREAM_ID_LEN * 3];
_jbpf_io_tohex_str(io_channel->stream_id.id, JBPF_IO_STREAM_ID_LEN, sname, JBPF_IO_STREAM_ID_LEN * 3);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

will this add a NULL terminator ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes:

pout[0] = 0;

@matthewbalkwill
matthewbalkwill self-requested a review July 2, 2025 09:14
@doctorlai-msrc
Zhihua Lai (doctorlai-msrc) dismissed Xenofon Foukas (xfoukas)’s stale review July 2, 2025 09:25

Addressed the comment by modifying the PR description - dismissed it to get in quicker.

@doctorlai-msrc
Zhihua Lai (doctorlai-msrc) added this pull request to the merge queue Jul 2, 2025
Merged via the queue into dev with commit 4079638 Jul 2, 2025
@doctorlai-msrc
Zhihua Lai (doctorlai-msrc) deleted the fixprint16 branch July 2, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants