8000 gh-111178: fix UBSan failures in `Objects/exceptions.c` by picnixz · Pull Request #128154 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-111178: fix UBSan failures in Objects/exceptions.c #128154

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

Merged
merged 25 commits into from
Feb 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2683a25
fix UBSan failures for `PyBaseExceptionObject`
picnixz Dec 21, 2024
3f1196b
fix UBSan failures for `PyStopIterationObject`
picnixz Dec 21, 2024
1886b07
fix UBSan failures for `PySystemExitObject`
picnixz Dec 21, 2024
3df93a5
fix UBSan failures for `PyImportErrorObject`
picnixz Dec 21, 2024
96f97a5
fix UBSan failures for `PyOSErrorObject`
picnixz Dec 21, 2024
09514a9
fix UBSan failures for `PyNameErrorObject`
picnixz Dec 21, 2024
9d3c8b8
fix UBSan failures for `PyAttributeErrorObject`
picnixz Dec 21, 2024
2640a34
fix UBSan failures for `PySyntaxErrorObject`
picnixz Dec 21, 2024
150f34e
fix UBSan failures for `KeyError`
picnixz Dec 21, 2024
11d9e31
remove un-necessary casts for `UnicodeError*`
picnixz Dec 21, 2024
96430d9
remove un-necessary casts for `MemoryError`
picnixz Dec 21, 2024
0437291
fix UBSan failures for `PyBaseExceptionGroupObject`
picnixz Dec 21, 2024
d17a9b4
unify naming for cast functions
picnixz Dec 21, 2024
0d2434e
Merge remote-tracking branch 'upstream/main' into fix/ubsan/exception…
picnixz Jan 14, 2025
793196d
fixup
picnixz Jan 14, 2025
6abf1d8
fixup
picnixz Jan 14, 2025
6c2ef08
align naming convention
picnixz Jan 14, 2025
96f2d2d
remove redundant casts
picnixz Jan 16, 2025
0cd116b
Merge branch 'main' into fix/ubsan/exceptions-111178
picnixz Jan 18, 2025
248f195
Merge remote-tracking branch 'upstream/main' into fix/ubsan/exception…
picnixz Jan 25, 2025
e4daf11
remove un-necessary cast
picnixz Feb 6, 2025
565edab
Merge branch 'main' into fix/ubsan/exceptions-111178
picnixz Feb 7, 2025
122c914
Do not use `_` + capital letter in cast macros as it is also UB.
picnixz Feb 8, 2025
7906e3b
Do not use `_` + capital letter in cast macros as it is also UB.
picnixz Feb 8, 2025
8862b83
Merge branch 'main' into fix/ubsan/exceptions-111178
picnixz Feb 8, 2025
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
Prev Previous commit
Next Next commit
fix UBSan failures for KeyError
  • Loading branch information
picnixz committed Dec 21, 2024
commit 150f34ef45a1b6f2b4fc0ef938e07dfef449ea41
6 changes: 4 additions & 2 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2719,8 +2719,9 @@ SimpleExtendsException(PyExc_LookupError, IndexError,
/*
* KeyError extends LookupError
*/

static PyObject *
KeyError_str(PyBaseExceptionObject *self)
KeyError_str(PyObject *op)
{
/* If args is a tuple of exactly one item, apply repr to args[0].
This is done so that e.g. the exception raised by {}[''] prints
Expand All @@ -2731,10 +2732,11 @@ KeyError_str(PyBaseExceptionObject *self)
string, that string will be displayed in quotes. Too bad.
If args is anything else, use the default BaseException__str__().
*/
PyBaseExceptionObject *self = _PyBaseExceptionObject_CAST(op);
if (PyTuple_GET_SIZE(self->args) == 1) {
return PyObject_Repr(PyTuple_GET_ITEM(self->args, 0));
}
return BaseException_str(self);
return BaseException_str(op);
}

ComplexExtendsException(PyExc_LookupError, KeyError, BaseException,
Expand Down
0