Skip to content

Commit 3a2da76

Browse files
committed
Fix RISC-V stage2 compilation buffer overflow
The RISC-V target was experiencing segmentation faults during stage2 compilation when stdin was redirected. The root cause was insufficient buffer size for the SOURCE buffer when compiling large programs like shecc itself. The total size of all included source files for RISC-V was approaching the 512KB limit (MAX_SOURCE), and with stdin redirection adding overhead, this caused buffer overflow and segmentation faults. Increased MAX_SOURCE from 524288 (512KB) to 1048576 (1MB) to provide adequate buffer space for self-hosting compilation on all architectures.
1 parent 4d0b963 commit 3a2da76

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define MAX_BB_DOM_SUCC 64
2626
#define MAX_BB_RDOM_SUCC 256
2727
#define MAX_GLOBAL_IR 256
28-
#define MAX_SOURCE 524288
28+
#define MAX_SOURCE 1048576
2929
#define MAX_CODE 262144
3030
#define MAX_DATA 262144
3131
#define MAX_SYMTAB 65536

0 commit comments

Comments
 (0)