Validate instruction addresses and memory bounds in the emulator
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- operating-systems
Research direction
Start in emulator/main.c, in the instruction decoding loop identified in the issue. Trace how BASE, instruction values, and computed addresses are used before memory reads, then check the emulator's existing build or run instructions. Done when malformed bases, addresses, and instructions stop safely with descriptive errors and valid programs still work.
Written by the indexing model from the issue text.
Description
Summary
The emulator derives memory addresses from instruction values without validating them, which can read beyond the allocated memory and crash or corrupt state.
Problem
The code computes address = memory[i] % BASE and reads memory[address] for every instruction. If the program or base value is malformed, address may be outside the bounds of the memory array. Similarly, the instruction stream itself is not validated before decoding.
Expected behavior
- Check
BASEandaddressranges before reading memory. - Reject instructions that are invalid for the current architecture.
- Stop safely with a descriptive error on malformed programs.
Relevant code
emulator/main.cin theforloop that decodes instructions and accesses memory.
Suggested fix
Add range checks before each memory read and each address calculation. Reject BASE <= 0 and guard memory accesses with 0 <= address && address < MEMORY_SIZE before dereferencing them. Report invalid instructions instead of falling through to undefined behavior.
- Dominant language
- C++
- Stars
- 0
- Forks
- 0
- Avg merge
- 1m
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DavidSkillman/LittleManCompiler
-
bug copilot enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
bug compiler copilot good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
All issues in DavidSkillman/LittleManCompiler
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
rhalbersma/xstd-ints#395 ·
Maintainers usually reply within 1 day
-
[Bug] Root filesystem scope (/) incorrectly rejects all descendant pathsPossibly taken @mugenkyou claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
neutralinojs/neutralino.js#304 · 1 comment ·
-
FuSa
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tenstorrent/tt-umd#3851 ·
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
mattgodbolt/zindex#67 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100