Discussion:
Failed assertion in brel
(too old to reply)
Raymond Chung
2005-04-25 19:35:42 UTC
Permalink
Hi. I am getting this error and spent a day, but couldn't find.
Here is the assertion error:

===== CreatFile filepointer: 2007748
fd : 0
===== GOSFS_Close filepointer: 2007748
Failed assertion in brel: ((struct bhead *) ((char *) b - b->bh.bsize))->prevfree == 0 at ../src/geekos/bget.c, line 881, RA=13702, thread=0x0000c000

This assertion failure came from Free(file) in vfs.c
(struct File *)file pointers are the same, when I create and closing
-- as you see the pointer is 2007748.

For the test, I did following:
The last moment I return from GOSFS_Open(), Free(file) succeeded.
The first moment I convert it from Sys_Close(), Free(file) failed.
So, I assume something is happening between them.
But, /d/somefile test is calling Close() right after Open() succeeds.
Anyone had this problem?
Nicholas Hamilton
2005-04-25 19:43:18 UTC
Permalink
Free(file) is called in VFS.c Close(), there is no need for you to call
it again.
Iulian Neamtiu
2005-04-25 19:44:41 UTC
Permalink
Why do you Free() in GOSFS_Open() ?
The whole purpose of Open is to have create a struct File * that you'll
operate on afterwards.

Iulian
Post by Raymond Chung
Hi. I am getting this error and spent a day, but couldn't find.
===== CreatFile filepointer: 2007748
fd : 0
===== GOSFS_Close filepointer: 2007748
Failed assertion in brel: ((struct bhead *) ((char *) b - b->bh.bsize))->prevfree == 0 at ../src/geekos/bget.c, line 881, RA=13702, thread=0x0000c000
This assertion failure came from Free(file) in vfs.c
(struct File *)file pointers are the same, when I create and closing
-- as you see the pointer is 2007748.
The last moment I return from GOSFS_Open(), Free(file) succeeded.
The first moment I convert it from Sys_Close(), Free(file) failed.
So, I assume something is happening between them.
But, /d/somefile test is calling Close() right after Open() succeeds.
Anyone had this problem?
Raymond Chung
2005-04-25 20:04:39 UTC
Permalink
I don't call Free(file).
It dies in the vfs.c, which I didn't modify.
I believe my code layout for (struct File *) may not be right.
But, having problem figureing out.

If I briefly describe what I am doing:
syscall.c:
Sys_Close()
...
file = userctx->fileList[fd];
Close(file);

vfs.c:
Close()
// I didn't modify this function, but it dies after it called gosfs_close.
rc = file->ops->Close(file);
// here I got the correct file descriptor,
if (rc == 0) Free(file); // <---- dies here.

gosfs.c:
GOSFS_Close()
// Currently Test print is it.
Print("===== GOSFS_Close filepointer: %ld\n", (ulong_t)file);

return 0;

With this layout of code, (struct File *)file failed to be Freed.
When I see brel(), the assertion seems to investigate if the memory
is freed before to avoid freeing twice.
My code don't Free this memory, but I think I am calling some other
function freeing this section.
Just can't find where it is.

Thank you for helping, and I appreciate any further help.

Raymond

Loading...