Open
Description
Description of defect
Program runs into deadlock once FATFileSystem::file_truncate(...) is called: any subsequent member function call from a different thread context is blocked as mutex is not returned.
int FATFileSystem::file_truncate(fs_file_t file, off_t length)
{
FIL *fh = static_cast<FIL *>(file);
lock();
// save current position
FSIZE_t oldoff = f_tell(fh);
// seek to new file size and truncate
FRESULT res = f_lseek(fh, length);
if (res) {
unlock();
return fat_error_remap(res);
}
res = f_truncate(fh);
if (res) {
unlock();
return fat_error_remap(res);
}
// restore old position
res = f_lseek(fh, oldoff);
if (res) {
unlock();
return fat_error_remap(res);
}
****missing unlock() here****
return 0;
}
Target(s) affected by this defect ?
All targets
Toolchain(s) (name and version) displaying this defect ?
arm-none-eabi-gcc (1.70201.0)
pio version 5.1.1
What version of Mbed-os are you using (tag or sha) ?
mbed 6.6.0
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
n/a
How is this defect reproduced ?
The defect can only be reproduced when member functions are accessed from different threads; problem does not occur if member functions are called from the same thread as mutex is already owned by this thread.