fix(elc): add el_mem_check() memory guard — abort before OS OOM-kill
Add el_mem_check() to el_runtime.c: reads ELC_MAX_MEM_MB (default 512), checks RSS via getrusage (macOS bytes / Linux KB normalised to MB), prints a clear diagnostic to stderr and exits(1) if exceeded. Wire it into two places: - compiler.el: upfront check at --emit-header entry point - codegen.el: per-function check in the streaming loop after each el_arena_pop, so runaway growth is caught at the earliest function boundary rather than after the machine is already dying.
This commit is contained in:
@@ -3730,6 +3730,7 @@ fn codegen_streaming(tokens: [Any], sigs: [Map<String, Any>], source: String) ->
|
||||
cg_fn(stmt)
|
||||
el_release(stmt)
|
||||
el_arena_pop(fn_arena_mark)
|
||||
el_mem_check()
|
||||
}
|
||||
} else {
|
||||
if is_top_level_decl(stmt) {
|
||||
|
||||
@@ -571,6 +571,7 @@ fn main() -> Void {
|
||||
// BinOp chains (e.g. checkout.el) — parse() builds O(whole-program AST)
|
||||
// while scan_fn_sigs_el keeps peak memory at O(tokens).
|
||||
if do_emit_header {
|
||||
el_mem_check()
|
||||
let raw_source: String = fs_read(src_path)
|
||||
let hdr_tokens: [Any] = lex(raw_source)
|
||||
let hdr_sigs: [Map<String, Any>] = scan_fn_sigs_el(hdr_tokens)
|
||||
|
||||
Reference in New Issue
Block a user