Skip to content
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

Fix strtod NaN handling / fix SIGSEGV in testlib/showerror #901

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libc/testlib/showerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ static void testlib_showerror_(int line, //
}
if (!isempty(fmt)) {
if (_weaken(kvprintf)) {
tinyprint(2, "\t");
tinyprint(2, "\t", NULL);
_weaken(kvprintf)(fmt, va);
tinyprint(2, "\n");
tinyprint(2, "\n", NULL);
} else {
tinyprint(2, "\t[missing kvprintf]\n");
}
Expand Down
15 changes: 15 additions & 0 deletions test/libc/tinymath/strtod_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ static const struct {
uint64_t i;
const char *s;
} V[] = {
{0x7FF8000000000000, "nan"}, //
{0x7FF8000000000000, "NaN"}, //
{0x7FF8000000000000, "NAn"}, //
{0x7FF8000000000000, "nAN"}, //
{0x7FF8000000000000, "NAN"}, //
{0x7FF0000000000000, "INF"}, //
{0x7FF0000000000000, "iNf"}, //
{0x7FF8000000000000, "+NAN"}, //
{0xFFF8000000000000, "-NAN"}, //
{0x7FF0000000000000, "+INF"}, //
{0xFFF0000000000000, "-INF"}, //
{0x2fa7b6d71d20b96c, "4e-079"}, //
{0x09eb8d7e32be6396, "7e-261"}, //
{0x3ae7361cb863de62, "6e-025"}, //
Expand Down Expand Up @@ -85,6 +96,10 @@ static const struct {
{0x7044d64d4079150c, "647e0230"}, //
{0x64a7d93193f78fc6, "755e0174"}, //
{0x30dcd5bee57763e6, "255e-075"}, //
{0x7FF0000000000000, "INFINITY"}, //
{0x7FF0000000000000, "iNfiNiTy"}, //
{0x7FF0000000000000, "+INFINITY"}, //
{0xFFF0000000000000, "-INFINITY"}, //
{0x4c159bd3ad46e346, "3391e0055"}, //
{0x3d923d1b5eb1d778, "4147e-015"}, //
{0x3b482782afe1869e, "3996e-026"}, //
Expand Down
4 changes: 2 additions & 2 deletions third_party/gdtoa/strtod.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ strtod(const char *s00, char **se)
word1(&rv) = bits[0];
}
else {
word0(&rv) = NAN_WORD0;
word1(&rv) = NAN_WORD1;
word0(&rv) = 0x7ff80000;
word1(&rv) = 0x0;
}
goto ret;
}
Expand Down