-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix many errors that occur on 32-bit systems under UBSan (#804)
This commit fixes fixes a large number of runtime errors that occur when ksh is compiled with '-fsanitize=undefined' on Linux 32-bit using GCC. Noted changes: - Switched out long and double for Sflong_t and Sfdouble_t in many places to fix runtime errors under UBSan. (In certain places (u)int64_t was used to specify exactly 64-bits rather than intmax_t.) The following runtime errors should no longer occur (line numbers/positions as of commit e67af95): * left shift of 1 by 31 places cannot be represented in type 'long int': macro.c:2489:9, args.c:252:4, args.c:272:4, args.c:175:60, args.c:607:10, args.c:622:38 * left shift of 12 by 28 places cannot be represented in type 'long int': pty.c:355:12 * signed integer overflow: 1734423994 - -1213168416 cannot be represented in type 'long int': xec.c:2359:4 - For mamake, use 'unsigned long long' instead of 'uint64_t' to avoid requiring stdint.h. - Remove !timeofday code. All modern systems have gettimeofday, which makes this code unused and an unnecessary maintenance burden. - Define _TIME_BITS=64 to fix integer overflows in the time keyword and likely elsewhere (ksh assumes time_t is 64-bits). - Moved the AST_LC_* bitflags into the 32-bit range. - Don't assume 'long long' and 'intmax_t' are the same. While intmax_t is in practice the same as 'long long', this is not guaranteed by the C standard (it's permitted for these types to differ). For correctness, only use %jd and %ju with Sflong_t (aka intmax_t), and enforce this distinction in SFIO's handling of %ll and %j. (The extra if statements are optimized away on platforms where the types are identical.) - Use suseconds_t for tv->usec and enforce 64-bit time_t in the libast feature tests. - Casted more PIDs to Sflong_t when using PIDs with format specifiers. - Use the %zu format specifier with size_t vars rather than unnecessary casts.
- Loading branch information
Showing
34 changed files
with
131 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.