[Git][ghc/ghc][master] Truncate eventlog event for large payload (#20221)
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Thu Dec 8 13:32:37 UTC 2022
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00
Truncate eventlog event for large payload (#20221)
RTS eventlog events for postCapsetVecEvent are truncated if payload
is larger than EVENT_PAYLOAD_SIZE_MAX
Previously, postCapsetVecEvent records eventlog event with payload
of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without
any validation, resulting in corrupted data.
For example, this happens when a Haskell binary is invoked with very
long command line arguments exceeding 2^16 bytes (see #20221).
Now we check the size of accumulated payload messages incrementally,
and truncate the message just before the payload size exceeds
EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing
how many arguments are truncated.
- - - - -
1 changed file:
- rts/eventlog/EventLog.c
Changes:
=====================================
rts/eventlog/EventLog.c
=====================================
@@ -754,7 +754,17 @@ void postCapsetVecEvent (EventTypeNum tag,
for (int i = 0; i < argc; i++) {
// 1 + strlen to account for the trailing \0, used as separator
- size += 1 + strlen(argv[i]);
+ int increment = 1 + strlen(argv[i]);
+ if (size + increment > EVENT_PAYLOAD_SIZE_MAX) {
+ errorBelch("Event size exceeds EVENT_PAYLOAD_SIZE_MAX, record only %"
+ FMT_Int " out of %" FMT_Int " args",
+ (long long) i,
+ (long long) argc);
+ argc = i;
+ break;
+ } else {
+ size += increment;
+ }
}
ACQUIRE_LOCK(&eventBufMutex);
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2057c77d08cb8422857d182a3691f98dccd0c7d6
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2057c77d08cb8422857d182a3691f98dccd0c7d6
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221208/800d4d3e/attachment-0001.html>
More information about the ghc-commits
mailing list