-
Notifications
You must be signed in to change notification settings - Fork 60
Fix available space check for 32-bit systems #1588
Conversation
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, but how gcc-specific is this? Looks like it's compiler-dependent, but most compilers support it?
Defining the macro is probably a good idea for preventing future issues but I would also add some manual casts in the parts we know are problematic. Here, casting |
This has nothing to do with gcc, but it rather depends on C standard library implementation. So far I can see that it's implemented in the same way in glibc and ulibc. |
Codecov Report
@@ Coverage Diff @@
## master #1588 +/- ##
==========================================
- Coverage 82.35% 82.33% -0.02%
==========================================
Files 189 189
Lines 11851 11851
==========================================
- Hits 9760 9758 -2
- Misses 2091 2093 +2
Continue to review full report at Codecov.
|
I've tried simple example and I do not see this transformation, or my test is incorrect? sudo apt-get install g++-multilib
result:
with flag:
result:
|
@kbushgit there is indeed an error in your program, it prints After the fix:
|
Can we take the idea behind Kosta's test app and turn it into a proper unit test? |
I think you are right. I wanted to avoid explicit castings, but we still might end up with u32 * u32, which is wrong. |
A proper way to do it would be to have something similar to this : https://github.com/libarchive/libarchive/blob/master/build/cmake/CheckFileOffsetBits.cmake |
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
The issue was reported by a customer. This function:
aktualizr/src/libaktualizr/storage/sqlstorage.cc
Line 1633 in 3c09519
gives incorrect results on 32-bit systems.
The root cause is that both
f_bsize
andf_bavail
members of statvfs struct are 4 bytes long. Hence, the result of this expressionaktualizr/src/libaktualizr/storage/sqlstorage.cc
Line 1640 in 3c09519
is also 4 byte long and overflows on 4GB.
This fix makes aktualizr use 64-bit filesystem interface. Member
f_bavail
becomes 8 bytes long and the expression evaluates correctly.This has no effect on 64-bit architectures.