Skip to content

[minipal] Don't assert when writing empty string #115824

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

Merged
merged 1 commit into from
May 22, 2025

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented May 21, 2025

No description provided.

@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 11:00
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 21, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the assertion that disallowed empty log messages and instead returns early when msg is an empty string.

  • Replaced assert(msg != NULL && msg[0] != '\0') with an assert only on non-null and an early return for empty messages
  • Applied the change to both overloads of minipal_log_write
Comments suppressed due to low confidence (1)

src/native/minipal/log.c:134

  • New behavior handling empty messages should be covered by unit tests to ensure this early-return behavior doesn’t regress in the future.
if (msg[0] == '\0')

assert(msg != NULL && msg[0] != '\0');
assert(msg != NULL);

if (msg[0] == '\0')
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

The empty-string check logic is duplicated in both log write functions. Consider extracting this into a common helper to reduce duplication and ease maintenance.

Suggested change
if (msg[0] == '\0')
if (is_empty_string(msg))

Copilot uses AI. Check for mistakes.

@BrzVlad
Copy link
Member Author

BrzVlad commented May 21, 2025

Hit assertion when having some JIT debug env vars enabled. Assertion introduced in #113416, not sure if there was a specific reason behind. @lateralusX

@BrzVlad BrzVlad added area-PAL-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels May 21, 2025
@BrzVlad BrzVlad requested review from janvorli and lateralusX May 21, 2025 11:04
@lateralusX
Copy link
Member

Hit assertion when having some JIT debug env vars enabled. Assertion introduced in #113416, not sure if there was a specific reason behind. @lateralusX

Reason was to flush out loggings using empty strings, but if that ends up begin a pattern, then we could relax it.

@BrzVlad BrzVlad merged commit a1f6dec into dotnet:main May 22, 2025
161 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants