CV wchan's disappearing

I am using cv’s for some of the features of forking processes, but I keep running into an error where the wchan associated with the CV becomes NULL. I have used gdb and cv_destroy is never called before one of these disappearances so that is not the problem. The internals of the cv are not even looked at by my code. This is the error checking code that I use when the wchan in initialized in cv_create from assignment 1.

cv->cv_wchan = wchan_create(cv->cv_name);
if (cv->cv_wchan == NULL) {
	return NULL;

Similar code (not written by me) is used throughout sys161 for checking for null pointers. Does anyone have any ideas why the cv wchan’s would be changing to NULL? Could it be an issue with DUMBVM and how would I be able to get around that?

It’s getting set to NULL somewhere, if you dig a little in gdb you will find you can set conditional breakpoints. Try setting one for when a condition variable you know you’ll lose is set to 0, and then you can find out where the pointer loss occurs.

There’s nothing wrong with dumbvm.

Usually this happens because you are manipulating some other part of memory incorrectly and overwriting part of the CV structure. Unfortunately these kinds of bugs can be very, very hard to find. But if you have some idea of what code is triggering it that can be a starting point.

1 Like