Skip to content

Investigate possible memory leak from hello-world example #946

Closed

Description

@dblnz

Running valgrind on the hello-world example yields the below output.
It looks like there might be some memory leak that needs investigation.

Valgrind output
➜  hyperlight git:(main) ✗ valgrind -s --leak-check=full --show-leak-kinds=all target/release/examples/hello-world
==197301== Memcheck, a memory error detector
==197301== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==197301== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==197301== Command: target/release/examples/hello-world
==197301==
--197301-- WARNING: unhandled amd64-linux syscall: 317
--197301-- You may be able to write your own handler.
--197301-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--197301-- Nevertheless we consider this a bug.  Please report
--197301-- it at http://valgrind.org/support/bug_reports.html.

thread 'main' panicked at src/hyperlight_host/examples/hello-world/main.rs:47:10:
called `Result::unwrap()` on an `Err` value: SeccompFilterError(Seccomp(Os { code: 38, kind: Unsupported, message: "Function not implemented" }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
==197301==
==197301== HEAP SUMMARY:
==197301==     in use at exit: 520 bytes in 3 blocks
==197301==   total heap usage: 625 allocs, 622 frees, 1,031,802 bytes allocated
==197301==
==197301== 16 bytes in 1 blocks are still reachable in loss record 1 of 3
==197301==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==197301==    by 0x1499F0: std::sync::poison::once::Once::call_once::{{closure}} (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x12F633: std::sys::sync::once::futex::Once::call (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x151BC8: hyperlight_host::sandbox::uninitialized_evolve::evolve_impl_multi_use::{{closure}} (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x15020E: hyperlight_host::sandbox::uninitialized_evolve::evolve_impl_multi_use (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x178011: hyperlight_host::sandbox::uninitialized::UninitializedSandbox::evolve (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x136036: hello_world::main (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x13AEA5: std::sys::backtrace::__rust_begin_short_backtrace (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x136687: std::rt::lang_start::{{closure}} (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x1EE9BF: std::rt::lang_start_internal (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x1363D4: main (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==
==197301== 48 bytes in 1 blocks are possibly lost in loss record 2 of 3
==197301==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==197301==    by 0x1EF893: std::thread::Thread::new (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x12E9AF: std::thread::current::init_current (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x149A74: std::thread::scoped::scope (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x176F60: hyperlight_host::sandbox::host_funcs::FunctionRegistry::call_host_func_impl::{{closure}} (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x17672F: hyperlight_host::sandbox::host_funcs::FunctionRegistry::call_host_func_impl (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x175E47: hyperlight_host::sandbox::host_funcs::FunctionRegistry::call_host_function (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x14FC8B: hyperlight_host::sandbox::outb::handle_outb::{{closure}} (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x14E67D: hyperlight_host::sandbox::outb::handle_outb (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x196502: <hyperlight_host::hypervisor::kvm::KVMDriver as hyperlight_host::hypervisor::Hypervisor>::handle_io::{{closure}} (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x195C23: <hyperlight_host::hypervisor::kvm::KVMDriver as hyperlight_host::hypervisor::Hypervisor>::handle_io (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x163F4C: hyperlight_host::hypervisor::VirtualCPU::run::{{closure}} (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==
==197301== 456 bytes in 1 blocks are still reachable in loss record 3 of 3
==197301==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==197301==    by 0x1F8A9A: std::sys::pal::unix::stack_overflow::thread_info::set_current_info (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x1EE873: std::rt::lang_start_internal (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==    by 0x1363D4: main (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
==197301==
==197301== LEAK SUMMARY:
==197301==    definitely lost: 0 bytes in 0 blocks
==197301==    indirectly lost: 0 bytes in 0 blocks
==197301==      possibly lost: 48 bytes in 1 blocks
==197301==    still reachable: 472 bytes in 2 blocks
==197301==         suppressed: 0 bytes in 0 blocks
==197301==
==197301== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Activity

  1. added this to the v0.11.0 milestone on Oct 8, 2025
  2. dblnz commented on Oct 15, 2025

    @dblnz
    ContributorAuthor

    Initial investigation of this potential issue leads to:

    • the way we handle seccomp rules on the executing thread for sandbox
    • the logic handling panic of host registered functions

    Once we get rid of the seccomp feature, I expect this to go away.
    I would set this issue aside and verify again once seccomp feature is removed.

  3. dblnz commented on Oct 23, 2025

    @dblnz
    ContributorAuthor

    After merging #970 this no longer applies.
    Here is the output of the same command as in the issue description after merging the removal of seccomp feature.

    Valgrind output
    ➜  hyperlight git:(main) ✗ valgrind -s --leak-check=full --show-leak-kinds=all target/release/examples/hello-world
    ==645434== Memcheck, a memory error detector
    ==645434== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
    ==645434== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
    ==645434== Command: target/release/examples/hello-world
    ==645434==
    Hello, World! I am executing inside of a VM :)
    ==645434==
    ==645434== HEAP SUMMARY:
    ==645434==     in use at exit: 456 bytes in 1 blocks
    ==645434==   total heap usage: 502 allocs, 501 frees, 1,096,664 bytes allocated
    ==645434==
    ==645434== 456 bytes in 1 blocks are still reachable in loss record 1 of 1
    ==645434==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==645434==    by 0x1E990A: std::sys::pal::unix::stack_overflow::thread_info::set_current_info (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
    ==645434==    by 0x1E0453: std::rt::lang_start_internal (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
    ==645434==    by 0x134694: main (in /home/dblnz/workspace/msft/hyperlight/target/release/examples/hello-world)
    ==645434==
    ==645434== LEAK SUMMARY:
    ==645434==    definitely lost: 0 bytes in 0 blocks
    ==645434==    indirectly lost: 0 bytes in 0 blocks
    ==645434==      possibly lost: 0 bytes in 0 blocks
    ==645434==    still reachable: 456 bytes in 1 blocks
    ==645434==         suppressed: 0 bytes in 0 blocks
    ==645434==
    ==645434== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  4. self-assigned this
    on Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions