GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-89455: Fix an uninitialized bool in exception print context. by gpshead · Pull Request #91466 · python/cpython

Conversation

@gpshead

@gpshead gpshead commented Apr 12, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fix an uninitialized bool in exception print context.

struct exception_print_context.need_close was uninitialized.

Found by oss-fuzz in a test case running under the undefined behavior sanitizer.

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=46618
https://oss-fuzz.com/testcase-detail/6217746058182656

Python/pythonrun.c:1241:28: runtime error: load of value 253, which is not a valid value for type 'bool'
    #0 0xbf2203 in print_chained cpython3/Python/pythonrun.c:1241:28
    #1 0xbea4bb in print_exception_cause_and_context cpython3/Python/pythonrun.c:1320:19
    #2 0xbea4bb in print_exception_recursive cpython3/Python/pythonrun.c:1470:13
    #3 0xbe9e39 in _PyErr_Display cpython3/Python/pythonrun.c:1517:9

Pretty obvious what the ommission was upon code inspection.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ghost

ghost commented Apr 12, 2022

Copy link
Copy Markdown

Commit authors are required to sign the Contributor License Agreement.
CLA not signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting core review label Apr 12, 2022
@gpshead
gpshead requested a review from iritkatriel April 12, 2022 01:56
@gpshead

gpshead commented Apr 12, 2022

Copy link
Copy Markdown
Member Author

Commit authors are required to sign the Contributor License Agreement.

The new CLA checker is broken and won't accept my current commits or even my attempt to re-sign the CLA via the bot here because of the way my arbitrary unverified text string git "email" field is structured in many of my local git config files. I'll keep this PR open as an example until that can be resolved.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel
iritkatriel approved these changes Apr 12, 2022
View reviewed changes

@iritkatriel iritkatriel left a comment

Copy link
Copy Markdown
Member

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.

This is initialised to false in line 1379, and the value is only used further down in the same function, so I don't think there's an actual bug (phew).

Yes, let's initialise it here too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Apr 12, 2022
@gpshead gpshead self-assigned this Apr 13, 2022
gpshead added 2 commits April 13, 2022 00:46
@gpshead
Fix an uninitialized bool in exception print context.
40c65a3
`struct exception_print_context.need_close` was uninitialized.

Found by oss-fuzz in a test case running under the undefined behavior sanitizer.

https://oss-fuzz.com/testcase-detail/6217746058182656

```
Python/pythonrun.c:1241:28: runtime error: load of value 253, which is not a valid value for type 'bool'
    #0 0xbf2203 in print_chained cpython3/Python/pythonrun.c:1241:28
    #1 0xbea4bb in print_exception_cause_and_context cpython3/Python/pythonrun.c:1320:19
    #2 0xbea4bb in print_exception_recursive cpython3/Python/pythonrun.c:1470:13
    #3 0xbe9e39 in _PyErr_Display cpython3/Python/pythonrun.c:1517:9
```

Pretty obvious what the ommission was upon code inspection.
@gpshead
Add a NEWS entry.
a012f40
@gpshead
gpshead force-pushed the bpo-45292-uninitialized_need_close branch from dc7f776 to a012f40 Compare April 13, 2022 00:47
@gpshead gpshead closed this Apr 13, 2022
@gpshead gpshead reopened this Apr 13, 2022
@gpshead gpshead added CLA signed and removed CLA signed labels Apr 13, 2022
@gpshead
update news wording.
6a19b93
also see if a new commit re-triggers the CLA checker.
@gpshead
gpshead marked this pull request as ready for review April 14, 2022 18:22
@gpshead

gpshead commented Apr 14, 2022

Copy link
Copy Markdown
Member Author

This is a real bug, the codepath in the traceback listed above used the value without it being initialized. Thus a sanitizer finding it. I don't think it had noticable behavioral impact though.

iritkatriel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gpshead
gpshead merged commit 861974b into python:main Apr 14, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 14, 2022
@gpshead
gpshead deleted the bpo-45292-uninitialized_need_close branch April 14, 2022 18:26
@illia-v illia-v mentioned this pull request Aug 5, 2023
Set up CIFuzz to run fuzz targets continuously #107652
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gpshead gpshead

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@gpshead @iritkatriel @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.