[NSWI004] Strange bug in syscall exit implementation.

Tomáš Drozdík drozdik.tomas at gmail.com
Thu Feb 13 11:22:46 CET 2020


Hi,

I've encountered a strange bug while working on assignment 6 which
after circa 20 seconds of work which I cannot step through starts a
presumably infinite loop of "Kernel panic: Exception..." prints.

I've managed to achieve hitting a break point in user-space main
function thus entering msim interactive mode as was suggested in task
description. Then I've tried to implement a syscall as handling of
general exception with cause 8 which caused correct switch back to
kernel. Then I've just implemented a handle syscall for exit which
calls `thread_finish` with the argument of `exit` syscall. This has to
clear the address space of given thread which it does according to the
debugger and when it needs to call `kfree` on as_t structure I'm no
longer able to step through it an it hangs followed by an infinity
loop described above.

Since the program enters an infinite loop of kernel panics, which
should not happen at all, the code must have been modified during an
execution. Then the function `handle_exception_general` must have been
called repeatedly with invalid `cause` resulting in that kind of
behavior. I think that there may be a problem with disabling of
interrupts, which I don't do in handling of syscalls since we might
hit another (e.g. TLB exception) which we do not want to ignore.

Code is in my repo:
https://gitlab.mff.cuni.cz/teaching/nswi004/winter-2019-20/team-i_cant_c/tree/as6
  (branch as6)
Commit: b86c92e187e41e0ef342b1c82b39055e68d8a896   (BUG version)
Commit: 45be7eeecc2fa9f80bd26a55c6fc52ce6d793b6b   (handling of
syscall on kernel side with manual break point in main)

Any suggestion would be appreciated.
Thanks in advance.

Best regards
Tomáš Drozdík


More information about the NSWI004 mailing list