Skip to content

IOBuffer resource leak in compile_rust_to_llvm_ir error paths #178

@terasakisatoshi

Description

@terasakisatoshi

Bug Description

In compile_rust_to_llvm_ir() in compiler.jl, IOBuffer objects are not properly closed in error paths, leading to resource leaks.

Location

  • src/compiler.jl (compile_rust_to_llvm_ir function)

Problem

When compilation errors occur, IOBuffers used for capturing stderr/stdout are not explicitly closed before the error is thrown. While Julia's GC will eventually clean these up, repeated compilation failures could accumulate unclosed IOBuffer resources.

Suggested Fix

Use try-finally to ensure IOBuffers are closed:

buf = IOBuffer()
try
    # ... compilation logic
finally
    close(buf)
end

Severity

LOW - Resource leak in error paths

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions