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-111178: Generate correct signature for most self converters by erlend-aasland · Pull Request #128447 · python/cpython

Conversation

@erlend-aasland

@erlend-aasland erlend-aasland commented Jan 3, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • Issue: UBSan: Calling a function through pointer to incorrect function type is undefined behavior #111178

Sorry, something went wrong.

Uh oh!

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

All reactions
@erlend-aasland
pythongh-111178: Generate correct signature for self converters
5610098
@erlend-aasland
erlend-aasland requested a review from picnixz January 3, 2025 13:29
@bedevere-app bedevere-app Bot mentioned this pull request Jan 3, 2025
UBSan: Calling a function through pointer to incorrect function type is undefined behavior #111178
Closed
@erlend-aasland
Amend clinic tests
7daeccd
@erlend-aasland erlend-aasland added the skip news label Jan 3, 2025
@erlend-aasland

This comment was marked as resolved.

Sign in to view
@erlend-aasland
Fixup Objects/ and Python/ files
dada02d
@erlend-aasland

erlend-aasland commented Jan 3, 2025

Copy link
Copy Markdown
Contributor Author

WDYT, @picnixz?

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz

picnixz commented Jan 3, 2025

Copy link
Copy Markdown
Member

I think this is what I had in mind. I'm no more on my dev session but I'll pick your branch, create a branch with all my known UBSan fixes branches and then I'll need to manually address the remaining ones.

AFAICT, no new _impl functions were added so performances shouldn't be affected I think? (it's only pointer casts for the compiler). I'll review more in details tomorrow but thank you for the work!

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jan 3, 2025

Copy link
Copy Markdown
Contributor Author

Yeah, this PR only makes sure we're using PyObject pointers in the PyMethodDef "entries". No new [clinic input] sections, no new _impl functions. Performance should not be affected.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jan 3, 2025

Copy link
Copy Markdown
Contributor Author

I'll leave this in draft so we don't create a review rush.

picnixz 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.

erlend-aasland added 3 commits January 5, 2025 22:37
@erlend-aasland
Pull in main and resolve conflicts
8d3794d
@erlend-aasland
Pull in main and resolve conflicts
c2b3046
@erlend-aasland
Pull in main
5d8d5fc
@erlend-aasland

erlend-aasland commented Jan 19, 2025

Copy link
Copy Markdown
Contributor Author

Friendly ping, @picnixz!

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz

picnixz commented Jan 20, 2025

Copy link
Copy Markdown
Member

Sorry for the late reply. I checked what I still need to do for other UBSan failures and there are quite a lot of places to fix. Here's what I can suggest: we first merge your PR and then we continue fixing the rest of UBSan failures. I wanted to delay this PR until the other failures are patched but there just too many errors in the clang output that it's hard to know where to start.

So, I think we can first fix those now and then continue the work normally. I'll also tag @vstinner, @encukou and @ZeroIntensity who worked with me on that matter to hear their thoughts.

erlend-aasland 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.

encukou
encukou approved these changes Jan 20, 2025
View reviewed changes

@encukou encukou 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.

+1, let's not delay this step.

Sorry, something went wrong.

Uh oh!

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

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added the awaiting merge label Jan 20, 2025
@picnixz

picnixz commented Jan 20, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Not sure if this is meant to be covered by this PR but:

static PyObject *
list_append(PyListObject *self, PyObject *object)
{
    PyObject *return_value = NULL;

    Py_BEGIN_CRITICAL_SECTION(self);
    return_value = list_append_impl((PyListObject *)self, object);
    Py_END_CRITICAL_SECTION();

    return return_value;
}

has not been changed. list_append (in listobject.c.h) should accept a PyObject *. Same for list_remove and others.

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz

picnixz commented Jan 20, 2025

Copy link
Copy Markdown
Member

Also, the subsequent casts:

#define PY_LIST_CLEAR_METHODDEF    \
    {"clear", (PyCFunction)py_list_clear, METH_NOARGS, py_list_clear__doc__},

for

static PyObject *
py_list_clear(PyObject *self, PyObject *Py_UNUSED(ignored))
{
    PyObject *return_value = NULL;

    Py_BEGIN_CRITICAL_SECTION(self);
    return_value = py_list_clear_impl((PyListObject *)self);
    Py_END_CRITICAL_SECTION();

    return return_value;
}

are not needed but I don't know if it's possible to only remove the cast for the "fixed" methods or not.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jan 20, 2025

Copy link
Copy Markdown
Contributor Author

Correct, @picnixz, I don't think this is a complete solution. But these kinds of changes have a huge impact. It is pretty easy to validate this change, for example, but if we bake in another Argument Clinic change, it will be harder to validate the generated output. IMO, it is better to address this in a follow-up PR.

encukou 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.

@erlend-aasland
erlend-aasland marked this pull request as ready for review January 20, 2025 11:38
@erlend-aasland
erlend-aasland requested review from a team, abalkin, berkerpeksag, corona10, ericsnowcurrently, gpshead, pganssle and rhettinger as code owners January 20, 2025 11:38
@erlend-aasland
erlend-aasland requested review from 1st1, asvetlov, kumaraditya303, markshannon, serhiy-storchaka, tiran and willingc as code owners January 20, 2025 11:38
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting merge labels Jan 20, 2025
@erlend-aasland
erlend-aasland merged commit 537296c into python:main Jan 20, 2025
@erlend-aasland
erlend-aasland deleted the ubsan/clinic-self-converters branch January 20, 2025 11:40
@bedevere-app bedevere-app Bot removed the awaiting core review label Jan 20, 2025
@erlend-aasland erlend-aasland changed the title gh-111178: Generate correct signature for self converters gh-111178: Generate correct signature for most self converters Jan 20, 2025
@picnixz

picnixz commented Jan 20, 2025

Copy link
Copy Markdown
Member

, it will be harder to validate the generated output. IMO, it is better to address this in a follow-up PR.

Sure! I just wanted to be sure that you knew about this. But yes, otherwise I validate the current change (sorry for not having said it explicitly).

erlend-aasland 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.

@picnixz

picnixz commented Jan 20, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

@erlend-aasland We're having some CI failures now but I think it's because main wasn't merged recently and clinic not regen.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jan 20, 2025

Copy link
Copy Markdown
Contributor Author

Hm, yeah I guess we should've synced it before merging.

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz

picnixz commented Jan 20, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Do you want to make a patch? (I can also do it if you don't have the time now)

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Jan 20, 2025

Copy link
Copy Markdown
Contributor Author

Yes, I'm creating an amendment now. Compiling ... 🤖 🤖 🤖

picnixz 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.

erlend-aasland added a commit to erlend-aasland/cpython that referenced this pull request Jan 20, 2025
@erlend-aasland
pythongh-111178: Regen clinic and fix exceptions.c post pythongh-128447
0241133
@erlend-aasland

erlend-aasland commented Jan 20, 2025

Copy link
Copy Markdown
Contributor Author

Amendment up: #129060.

picnixz reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland erlend-aasland mentioned this pull request Jan 20, 2025
gh-111178: Regen clinic and fix exceptions.c post gh-128447 #129060
Merged
@vstinner

vstinner commented Jan 20, 2025

Copy link
Copy Markdown
Member

Nice enhancement, thanks.

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

erlend-aasland added a commit that referenced this pull request Jan 20, 2025
@erlend-aasland
gh-111178: Regen clinic and fix exceptions.c post gh-128447 (#129060)
da0f47c
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 21, 2025
@erlend-aasland @srinivasreddy
pythongh-111178: Generate correct signature for most self converters (p…
36ff53f
…ython#128447)
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 21, 2025
@erlend-aasland @srinivasreddy
pythongh-111178: Regen clinic and fix exceptions.c post pythongh-128447…
3e76a17
… (python#129060)
@vstinner vstinner mentioned this pull request Feb 28, 2025
gh-111178: Change Argument Clinic signature for METH_O #130682
Merged
@picnixz picnixz mentioned this pull request Mar 3, 2025
gh-111178: fix UBSan failures in Modules/_ssl.c #130719
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou approved these changes
@picnixz picnixz Awaiting requested review from picnixz picnixz is a code owner
@corona10 corona10 Awaiting requested review from corona10
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag
@gpshead gpshead Awaiting requested review from gpshead gpshead is a code owner
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@abalkin abalkin Awaiting requested review from abalkin
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently
@tiran tiran Awaiting requested review from tiran
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@1st1 1st1 Awaiting requested review from 1st1
@asvetlov asvetlov Awaiting requested review from asvetlov
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303
@willingc willingc Awaiting requested review from willingc

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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.

4 participants

@erlend-aasland @picnixz @vstinner @encukou
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.