File system hangs.
Re: File system hangs.
There are visual front ends to gdb. ddd is pretty good. It looks old fashioned but it can give you a better view into your program than VSCode or Eclipse. It’s often best to compile with optimizations disabled when debugging. Of course things are a bit tricky if enabling optimisation brings to light fresh bugs. Using objdump to provide a complete assembler listing of your program is also a great help.
As I said before, debugging is pretty much the same whatever language you use (although maybe superficially different for languages like Prolog, Lisp, or Smalltalk +p- not mainstream languages for OS development). It’s a question of being methodical and inspecting the machine state at appropriate points. It also helps to RTFM so that you know what any error codes signify.
I think most of my gripes with this thread could be solved by reading the forum rules, most specifically https://wiki.osdev.org/Getting_Started# ... _Knowledge and http://www.catb.org/~esr/faqs/smart-questions.html .
As I said before, debugging is pretty much the same whatever language you use (although maybe superficially different for languages like Prolog, Lisp, or Smalltalk +p- not mainstream languages for OS development). It’s a question of being methodical and inspecting the machine state at appropriate points. It also helps to RTFM so that you know what any error codes signify.
I think most of my gripes with this thread could be solved by reading the forum rules, most specifically https://wiki.osdev.org/Getting_Started# ... _Knowledge and http://www.catb.org/~esr/faqs/smart-questions.html .
-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
Thanks 

-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
Ok i tried the tools learned some more about gdb & ddd
and figured out that the return address probably gets thrown off
the stack (overflown probably) atleast from what i can gather by looking at the stack
. Because after the return statement it tries returning to 0x000000
but ofcourse there is no code there so it just hangs. But im stuck there so i would like some more help please
!





Re: File system hangs.
I already told you to look at the function you already identified. How big is the variable it declares, and how much do you write to it?
Carpe diem!
-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
Sorry didnt see your post haha 
so it writes 9 bytes over the limit of fs_root
but using gdb watches never catches it?
Code: Select all
(gdb) target remote 127.0.0.1:1234
Remote debugging using 127.0.0.1:1234
0x0000fff0 in ?? ()
(gdb) break fs_init
Breakpoint 1 at 0x200560: file src/fs/fs.c, line 13.
(gdb) ptype fs_root
type = struct {
char name[32];
uint32_t start_address;
uint32_t end_address;
uint8_t used;
} [256]
(gdb) print sizeof(fs_root)
$1 = 10496
(gdb) c
Breakpoint 1, fs_init () at src/fs/fs.c:13
13 char signature[6] = {0};
(gdb) dump binary memory fs_before.dump fs_root fs_root+10496
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x53fb5491 in ?? ()
(gdb) dump binary memory fs_after.dump fs_root fs_root+10496
(gdb) exit
Code: Select all
cmp -l fs_before.dump fs_after.dump | tail
10505 0 3
but using gdb watches never catches it?
-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
i Actually didnt i just used logging and debug statements and tests
(sorry i didnt mean gdt i meant gdb and i didnt know that was used for rust never heard of it)
-
- Member
- Posts: 232
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: File system hangs.
Have a look at these lines of code:
Code: Select all
void fs_init() {
char signature[6] = {0};
ata_read_sectors(FS_SECTOR, 1, signature);
(...)
-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
sebihepp wrote: ↑Wed Jun 04, 2025 6:04 am Have a look at these lines of code:Code: Select all
void fs_init() { char signature[6] = {0}; ata_read_sectors(FS_SECTOR, 1, signature); (...)

-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
I dont see anything wrong?zevvi wrote: ↑Wed Jun 04, 2025 7:52 amsebihepp wrote: ↑Wed Jun 04, 2025 6:04 am Have a look at these lines of code:Code: Select all
void fs_init() { char signature[6] = {0}; ata_read_sectors(FS_SECTOR, 1, signature); (...)
-
- Member
- Posts: 232
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: File system hangs.
How many bytes does ata_read_sectors() read? And how big is the variable signature?
-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
Code: Select all
(gdb) print sizeof(signature)
$1 = 6
(gdb)

and ata_lba_read reads 512 bytes
fix:
Code: Select all
unsigned char temp[512] = {0};
char signature[6] = {0};
ata_read_sectors(FS_SECTOR, 1, temp);
memcpy(signature, temp, 6);
Code: Select all
Done reading fs sectors...
-
- Member
- Posts: 232
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: File system hangs.
You can simply do this:
Next, I am not sure why you add 511 to sizeof(fs_root)?
Why not just divide by 512? What is you train of thought?
I am also not sure what filesystem you use... did you develop your own?
Code: Select all
void fs_init() {
char temp[512] = {0};
ata_read_sectors(FS_SECTOR, 1, temp);
terminal_writestring("Checking signature...\n");
if (strncmp(temp, FS_SIGNATURE, 5) == 0) {
Code: Select all
ata_read_sectors(FS_SECTOR + 1, (sizeof(fs_root) + 511) / 512, fs_root);
I am also not sure what filesystem you use... did you develop your own?
-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
thankssebihepp wrote: ↑Wed Jun 04, 2025 10:34 am You can simply do this:Code: Select all
void fs_init() { char temp[512] = {0}; ata_read_sectors(FS_SECTOR, 1, temp); terminal_writestring("Checking signature...\n"); if (strncmp(temp, FS_SIGNATURE, 5) == 0) {


yeah dont know late at night programming.sebihepp wrote: ↑Wed Jun 04, 2025 10:34 am Next, I am not sure why you add 511 to sizeof(fs_root)?Why not just divide by 512? What is you train of thought?Code: Select all
ata_read_sectors(FS_SECTOR + 1, (sizeof(fs_root) + 511) / 512, fs_root);
yes very simple just:
Code: Select all
typedef struct __attribute__((packed)) {
char name[FS_NAME_MAX];
uint32_t start_address;
uint32_t end_address;
uint8_t used;
} fs_entry_t;
static fs_entry_t fs_root[FS_MAX_ENTRIES];
-
- Posts: 21
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: File system hangs.
I still cant figure it out 

-
- Member
- Posts: 232
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: File system hangs.
Did you removed that "+ 511"?