Skip to content

Subtraction overflow in mem balancer implementation #765

@qinsoon

Description

@qinsoon

If we replace the following subtraction with checked_sub, it may fail.

self.allocation_pages = (mmtk.plan.get_reserved_pages() - self.gc_end_live_pages) as f64;

I observed this in Julia with non-moving immix:

      From worker 3:    thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /tmp/nix-build-julia-mmtk-patched.drv-0/git/checkouts/mmtk-core-89cdc7bf360cce7f/2a6e38e/src/util/heap/gc_trigger.rs:276:100
      From worker 3:    stack backtrace:
      From worker 3:       0: rust_begin_unwind
      From worker 3:       1: core::panicking::panic_fmt
      From worker 3:       2: core::panicking::panic
      From worker 3:       3: <mmtk::util::heap::gc_trigger::MemBalancerTrigger as mmtk::util::heap::gc_trigger::GCTriggerPolicy<VM>>::on_gc_start
      From worker 3:       4: mmtk::scheduler::controller::GCController<VM>::run
      From worker 3:       5: start_spawned_controller_thread
      From worker 3:       6: fn_spawn_controller_thread
      From worker 3:       7: start_thread
      From worker 3:       8: __GI___clone
      From worker 3:    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
      From worker 3:    fatal runtime error: failed to initiate panic, error 5

I don't know the root cause yet. bdb5dff did not fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-heapArea: Heap (including Mmapper, VMMap)C-bugCategory: BugP-lowPriority: Low. A low-priority issue won't be scheduled and assigned. Any help is welcome.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions