Lesson 23: Error correction: Invalid opcode(6 interrupt)

Author: Mr666ddCreated Oct 28, 2024Updated Oct 28, 2024

Description

Good afternoon! While working through Lesson 23, I encountered an issue when running the code. After compiling and starting the machine, I invoked PAGE(kmalloc() in kernel) and observed that the console began endlessly displaying error messages: received interrupt: 6 Invalid Opcode

Steps to Reproduce

  1. Compile the code from Lesson 23.
  2. Start the machine.
  3. Call PAGE.

Issue

The console floods with the above error messages without stopping.

Debugging Attempts

I tried debugging with gdb, but it didn’t help. Upon reviewing and modifying the code manually, I found the cause of the issue: the variables char page_str[16] and char phys_str[16] were initialized with empty strings, which triggered this problem.

Solution

After removing the empty string initialization, the issue was resolved. I suggest modifying the following lines in the code:

c
// kernel/kernel.c

void user_input(char *input) {
// Change this:
char page_str[16] = "";
char phys_str[16] = "";
// To this:
char page_str[16];
char phys_str[16];
}