Skip to content

Prevent undefined behavior in QUICHE logging#15635

Merged
alyssawilk merged 4 commits intoenvoyproxy:mainfrom
DavidSchinazi:lognull
Mar 31, 2021
Merged

Prevent undefined behavior in QUICHE logging#15635
alyssawilk merged 4 commits intoenvoyproxy:mainfrom
DavidSchinazi:lognull

Conversation

@DavidSchinazi
Copy link
Copy Markdown
Contributor

Commit Message:
This change adds a NullGuard which will prevent us
from sending null strings to output streams to avoid
undefined behavior.

Signed-off-by: David Schinazi dschinazi@google.com

Additional Description: None
Risk Level: Low
Testing: Local
Docs Changes: None
Release Notes: None
Platform Specific Features: None

Fixes #15620

This change adds a NullGuard which will prevent us
from sending null strings to output streams to avoid
undefined behavior.

Signed-off-by: David Schinazi <dschinazi@google.com>
@alyssawilk
Copy link
Copy Markdown
Contributor

Looks like the gcc failure might be real - mind checking out CI?

This commit works around this bug in GCC:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282

Signed-off-by: David Schinazi <dschinazi@google.com>
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

Code looks good; hoping for more testing of it.

EXPECT_DEBUG_DEATH({ QUICHE_DCHECK_NE(1 + 1, 2); },
"CHECK failed: 1 \\+ 1 \\(=2\\) != 2 \\(=2\\)");
EXPECT_DEBUG_DEATH({ QUICHE_DCHECK_NE(nullptr, nullptr); },
"CHECK failed: nullptr \\(=\\(null\\)\\) != nullptr \\(=\\(null\\)\\)");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was expecting to see tests where you used quic logging macros passing in null strings and having them not crash, but instead spew out "(null)".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh I think I see what's going on...you are testing we spew 'nullptr' but then to get the log at all you have to ultimately crash? Isn't there the equivalent of a LOG(ERROR) you can capture?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! I've added more testing

Signed-off-by: David Schinazi <dschinazi@google.com>
Signed-off-by: David Schinazi <dschinazi@google.com>
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

@envoyproxy/senior-maintainers

@alyssawilk alyssawilk merged commit b8aabf6 into envoyproxy:main Mar 31, 2021
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.

build: can not build quiche at latest commit

3 participants