Skip to content
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

Avoid accessing empty vector in realloc_deepdata in checkCoreFile #1648

Closed

Conversation

cary-ilm
Copy link
Member

The code was taking &(*ud)[0] even when ud is null (in the case of no samples to decode), and even though it wasn't actually referencing the value, the address sanitizer catches the reference, and it appears GCC 14 aborts with an failed assert.

This hopefully address #1639.

…e()`

The code was taking `&(*ud)[0]` even when `ud` is null (in the case of
no samples to decode), and even though it wasn't actually referencing
the value, the address sanitizer catches the reference, and it appears
GCC 14 aborts with an failed assert.

This hopefully address AcademySoftwareFoundation#1639.

Signed-off-by: Cary Phillips <cary@ilm.com>
@cary-ilm cary-ilm requested a review from kdt3rd February 27, 2024 22:30
Copy link
Contributor

@kdt3rd kdt3rd left a comment

Choose a reason for hiding this comment

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

huh, I don't believe ud is actually null - that (in this case anyway) is always passed in from a stack variable. Rather, the vector itself is empty, meaning bytes is calculated to be 0 (which happens an empty scanline with no deep samples), so it's actually the [] operator doing math on a null pointer, at least that's what I see. I have a fix for that (such that it ignores this step entirely on an empty scanline), which I believe to be the more appropriate fix

@kdt3rd
Copy link
Contributor

kdt3rd commented Mar 2, 2024

@cary-ilm I believe I have implemented (and merged after review from LG) the more complete fix for this (to avoid calling on a 0-sample deep scanline in #1652

@cary-ilm
Copy link
Member Author

cary-ilm commented Mar 3, 2024

I'd still argue that ud->data() is preferable to &((*ud)[0]), although your fix addresses the condition before it gets to that line.

@cary-ilm cary-ilm closed this Mar 3, 2024
@kdt3rd
Copy link
Contributor

kdt3rd commented Mar 3, 2024

oh, probably, I write &(foo[0]) to be more generic, but it's not a generic routine so using data would be clearer... although if all we did was change it to ->data(), it would just fail a few lines later, adding an offset to a null pointer anyway... I will switch it to ->data which will come in some later PR

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.

2 participants