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

memtrace: Fix underflow when stack_depth < FRAMES_TO_SKIP #873

Merged
merged 2 commits into from
Apr 23, 2024

Conversation

zhaofengli
Copy link
Contributor

Issue #, if available: N/A

Description of changes:

An underflow occurs on line 160 when stack_depth is smaller than FRAMES_TO_SKIP (i.e., stack_depth = 1). This occurs on riscv64 where the library fails to obtain a valid trace, which is a separate issue.

                memcpy(
                    (void **)&stack->frames[0],
                    &stack_frames[FRAMES_TO_SKIP],
                    (stack_depth - FRAMES_TO_SKIP) * sizeof(void *)); // <-- underflow

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

oxalica added a commit to oxalica/nixpkgs that referenced this pull request Dec 28, 2021
It causes a build failure due to test SEGFAULT on riscv64.
See: awslabs/aws-c-common#873
@oxalica
Copy link

oxalica commented Dec 29, 2021

I applied your patch and I still got a slightly different test failure when building on and targeting riscv64-linux-gnu. Is this related or another issue?

270/388 Test #257: test_memtrace_stacks .................................................Subprocess aborted***Exception:   0.62 sec
Fatal error condition occurred in /home/oxa/tmp/aws-c-common-build/source/source/memtrace.c:207: stack_item
Exiting Application
################################################################################
Stack trace:
################################################################################

@zhaofengli
Copy link
Contributor Author

Yes, that test needs to be skipped at the moment since memtrace cannot obtain a valid trace on riscv64. See zhaofengli/nixpkgs@9e7cbec

@oxalica
Copy link

oxalica commented Dec 29, 2021

Yes, that test needs to be skipped at the moment since memtrace cannot obtain a valid trace on riscv64. See zhaofengli/nixpkgs@9e7cbec

That's unfortunate. Could you elaborate the issue of backtrace? Is that something related to DWARF info?

@zhaofengli
Copy link
Contributor Author

Yes, that test needs to be skipped at the moment since memtrace cannot obtain a valid trace on riscv64. See zhaofengli/nixpkgs@9e7cbec

That's unfortunate. Could you elaborate the issue of backtrace? Is that something related to DWARF info?

Sorry, I haven't had a chance to peel off the abstractions and look at that part yet.

@DmitriyMusatkin DmitriyMusatkin merged commit 85c0873 into awslabs:main Apr 23, 2024
52 checks passed
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.

3 participants