-
Notifications
You must be signed in to change notification settings - Fork 136
Harden malloc implementation #226
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
Conversation
8adfe48
to
3802292
Compare
I fetched the updated commits on my beaglebone black and rebuilt shecc. However, when using 3802292, the build process encountered a segfault issue during the stage 2 compiler build. debian@BeagleBone:~/shecc$ make
env printf "ARCH=arm" > .session.mk
Target machine code switch to arm
Warning: missing packages: dot jq
Warning: Please check package installation
CC+LD out/inliner
GEN out/libc.inc
CC out/src/main.o
LD out/shecc
SHECC out/shecc-stage1.elf
SHECC out/shecc-stage2.elf
make: *** [Makefile:129: out/shecc-stage2.elf] Segmentation fault |
For further improvements, it depends on #230 for richer expressions. |
After fetching this commit, the build still fails when compiling the stage 2 compiler on my beaglebone board. |
Since several pull requests have been merged recently, it may be necessary to rebase the latest If the build still fails on the beaglebone black after rebasing, we should review the proposed changes or the previously merged commits to identify any potential issues. |
I have fetched the latest |
@ChAoSUnItY, can you confirm with Raspberry Pi + 32-bit Raspbian/Debian? |
I've confirmed the following context:
Judging from above information, I suspect this could be memory corruption done by incorrect memory handing. |
Check #237 |
As shown in #205 (comment) , the hybrid allocation strategy seems to have no significant impact on reducing memory use. After reviewing the current source code of shecc, I noticed that most of |
The original malloc was development-only with critical flaws: - No alignment - Overflow vulnerability (calloc multiplication) - Null pointer crashes (cleanup functions) - Complex allocation logic New implementation adds: - 8-byte alignment for cache optimization - Bounds checking preventing integer overflow - Null-safe memory management operations
The original malloc was development-only with critical flaws:
New implementation adds:
Summary by Bito
This pull request enhances the malloc implementation by fixing alignment issues, preventing overflow vulnerabilities, and addressing null pointer crashes. It introduces 8-byte alignment for cache optimization, bounds checking for integer overflow, and null-safe memory management, improving reliability and performance.