[io] fix crash due to overflow in buffer length variable#14627
[io] fix crash due to overflow in buffer length variable#14627vepadulano merged 2 commits intoroot-project:masterfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Sure. It makes sense. |
Finally I did not do it because there are cases with fixed width of 8 that are not data types. So like now I think it's compact enough. In the future, maybe the whole WriteFastArray function could be templates with some specializations/overriding for the fixed 8byte stuff. |
vepadulano
left a comment
There was a problem hiding this comment.
Thank you so much! Here some comments/suggestions
Also, I would agree we should introduce the Fatal everywhere the 1GB limit may play a role. Maybe the other classes can be improved in a follow-up PR though
|
Starting build on |
1 similar comment
|
Starting build on |
|
Build failed on ROOT-ubuntu2204/nortcxxmod. Failing tests: |
|
Build failed on ROOT-ubuntu2004/python3. Failing tests: |
|
Build failed on ROOT-performance-centos8-multicore/soversion. Failing tests: |
vepadulano
left a comment
There was a problem hiding this comment.
@ferdymercury thank you so much for this! Everything looks good on my side now. We have a bit of a noisy CI these days but the failures look unrelated to me.
pcanal
left a comment
There was a problem hiding this comment.
Thanks for this nice improvements.
|
Thanks to you for your review! Should we add a new issue to keep track of applying similar changes in the future to:
|
Done #14770 |
|
@ferdymercury Maybe also in this PR it would be nice to clean the commit history, I guess we want to keep the first two commits as they are independent non-trivial changes but squash the following 2 commits as they were part of the review process |
Fixes root-project#14644 ROOT is known to have a 1 GB maximum IO size, but did not provide since safety checks against this (since 18y). This lead to silent crashes. The length of the buffer Int_t l takes a negative value if we do not add these checks and n is high enough. [io] add underflow safety checks for writefastarray-objects [io] check for already preallocated elements apply pcanals suggestion [io] prevent underflow in SetByteCount cnt variable could go into negative otherwise [io] simplify width Co-authored-by: Philippe Canal <pcanal@fnal.gov> [io] more detailed assertion [io] raise fatal error instead of silently skipping apply pcanals suggestion
[core,io] clarify intent and comments
840fbbd to
e7fa7e8
Compare
|
Starting build on |
Done :) |
|
Build failed on ROOT-ubuntu2204/nortcxxmod. Failing tests: |
|
Build failed on ROOT-ubuntu2004/python3. Failing tests: |
|
I am not sure how but the failure in Ubuntu2310: https://github.com/root-project/root/actions/runs/7971661830/job/21783650878?pr=14627 seems limites to this PR .... |
Weird. No clue. |
This test sporadically fails on that platform, not the first time I see it. I doubt it is related to this PR. Let me rerun just that platform |
|
Latest ubuntu2310 run is green, the error is not related to this PR strictly. Merging now, thanks again @ferdymercury for the contribution! |
This Pull request:
Changes or fixes:
ROOT is known to have a 1 GB maximum IO size, see #6734, but did not provide proper safety checks against this (since 18y). This lead to silent crashes in the WriteFastArray function. The length of the buffer Int_t l takes a negative value if we do not add these checks and n is high enough.
This fixes the crash reported here: https://root-forum.cern.ch/t/crash-when-writing-canvas-to-tfile/58010/8?u=ferhue
A reproducer of the crash is also in that link.
Seems there are more people seeing a similar crash on the forum https://root-forum.cern.ch/t/writing-out-events-larger-than-1-gb/33106
I did not check in depth, but this PR also probably fixes cms-sw/cmssw#40132
Checklist:
Fixes #14644