-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime assertion in lfs_format due to uninitialized variable use (VS 2022) #756
Comments
Hi @knaxr, thanks for creating an issue. Do you know does MSVC report which line is responsible for the uninitialized read? I wonder if this is caused by the move of the variable onto the explicit stack here. This stack contains most of the variables in the function, some which are uninitialized but never read depending on the code path. I'm also curious why the Valgrind testing doesn't report this. |
Hello, We just wanted to update from 2.4.2 to the newest 2.5.1 and ran into the same problem under VS 2019. Our test suite also initializes an empty file system in a ram buffer and runs into the same not initialized exception. We get it on the same line 864 when copying the value to the explicit stack. |
Hello again, this issue is currently marked as "needs investigation". Therefore, I wanted to ask if we could help in any way to get this minor fix under way. Scenario:We have a big buffer array of bytes in ram and want to initialize the file system with lfs_format. Callstack:
What happens:First time in the while (true) loop:
Second time in the while (true) loop:
Initializing the disk variable like @knaxr described earlier fixes this access violation. The test suite runs without any problem after the fix. I initially wanted to try and isolate the problem in more detail to also ensure that our ram device simulation is not the source of the mistake. I was sadly unable to patch our ram device into the test suite or even comprehend how to write tests for littlefs. The code generation for the test system went over my head. Please feel free to let us know if we can help in any way. |
Hi @downtimes, @knaxr, sorry for not updating this issue. Thanks to @mdahamshi, this is being patched in the next patch release: #855 Just to clarify, this is an innocuous assertion. We only use the The reason this triggers MSVC is because we move the
Yeah, unfortunately I imagine the test framework is a bit impenetrable at the moment. The simulated block device is tightly integrated into the test framework to allow testing physical conditions such as bad blocks and different powerloss failure modes. |
Thank you very much. Sorry for the unnecessary ping, I should have looked through the Pull-Requests as well... |
No worries, it was good because I missed that this issue would also be resolved by the PR. |
MSVC debug build will emit a runtime assertion related to the use of uninitialized variable in
lfs_dir_traverse:
"Run-Time Check Failure #3 - The variable 'disk' is being used without being initialized."
This occurs when calling lfs_format on a completely erased (0xff bytes) ram block device.
callstack:
We removed the displayed assertion message box by initializing struct lfs_diskoff disk with 0 in lfs.c line 811:
struct lfs_diskoff disk = {0};
Can someone confirm, that zero-initializing
disk
is safe or if this may lead to unexpected side effects?If required, I'm happy to provide more information.
The text was updated successfully, but these errors were encountered: