devkitPro / libfat

FAT library for GBA, DS, Gamecube & Wii
http://devkitpro.org/viewforum.php?f=24
56 stars 36 forks source link

(libogc) fatUnmount() crashes system if you chdir()'d into that device earlier #21

Closed Naim2000 closed 1 year ago

Naim2000 commented 1 year ago

Steps to reproduce:

  1. Mount a device. sd_mounted = fatMountSimple("sd", sd_card);

  2. chdir() into it. chdir("sd:/"); return sd_mounted;

  3. Try unmount the device. if (sd_mounted) { fatUnmount("sd"); sd_card->shutdown(); sd_mounted = false; }

  4. Press RESET to exit the exception screen. IMG_20231118_101633

0x800f9e60 <_free_r+140>:       0x90a4000c      0x90850008      0x418201d0      0x61270001
0x800f9e70 <_free_r+156>:       0x90ea0004      0x91260000      0x280901ff      0x4181007c
0x800f9e80 <_free_r+172>:       0x55270038      0x80880004      0x5526d97e      0x38e70008

0x800f9df8 <_free_r+36>:        0x80bffffc      0x3d008014      0x395ffff8      0x39083cb8
0x800f9e08 <_free_r+52>:        0x54a9003c      0x80e80008      0x7cca4a14      0x7c073000
0x800f9e18 <_free_r+68>:        0x80e60004      0x54e7003a      0x418201c0      0x70a50001

0x80007470 <main+412>:       bl      0x80006900 <unmountSD> <-- culprit
0x80007474 <main+416>:       bl      0x80006a34 <unmountUSB> 
DacoTaco commented 1 year ago

@Naim2000 : hey man, just did some minimal testing with the following code and this didn't crash for me. could you make a minimal project we could look at, or produce the code that causes the issue?

libfat-test.zip

Naim2000 commented 1 year ago

Just for everyone else to see it. https://github.com/Naim2000/directory/tree/_free_r https://files.catbox.moe/c1d30j.elf IMG_20231119_184633 (1)

WinterMute commented 1 year ago

This isn't a minimal project and uses inappropriate bodged up libraries. We can't reproduce this issue with stock install.