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

set_at now take a long long for y instead of int #2962

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

oddbookworm
Copy link
Member

Fixes #2961
@ankith26 figured out that it was an int overflow when multiplying surf->pitch by y

@oddbookworm oddbookworm added draw pygame.draw bugfix PR that fixes bug labels Jun 30, 2024
@oddbookworm oddbookworm requested a review from a team as a code owner June 30, 2024 16:52
def test_line_draw_large_surf_regression(self):
"""Regression test for https://github.com/pygame-community/pygame-ce/issues/2961"""
try:
surface = pygame.Surface((14457, 37200))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the addition of this test. It makes the assumption that the host has enough memory.

A better solution would be a RAM check with pygame.system.get_total_ram, and then running this test if the RAM is above some threshold, but I'm not a fan of this either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't particularly like it either, but I felt it would be better to have some way to test that it hasn't regressed in the future. I couldn't think of any solution other than "make a gigantic surface" that CI won't have the memory for. I did try to make the surface as small as I could and still cause the segfault without the changes from this branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A follow-up of my message, yes I think it's not the method to follow to add the test.

@bilhox
Copy link
Contributor

bilhox commented Jul 27, 2024

I don't like how the problem is solved, we aren't clamping the line in the clip rect so we have to check if each pixel of the line one by one are outside the clip rect. IMO, the best way to solve this problem is to delimit with new coordinates which part of the line is going to be drawn.

@ankith26 ankith26 marked this pull request as draft August 14, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR that fixes bug draw pygame.draw
Projects
None yet
Development

Successfully merging this pull request may close these issues.

segfault when we use large coordinates in pygame.draw.line
3 participants