If you try to access the surface attribute of a PixelArray after you closed it, then pygame segfaults. Obviously you shouldn't grab the surface from a closed PixelArray, but it shouldn't segfault either.
MRE
import pygame
import pygame.pixelarray
screen = pygame.display.set_mode((500, 500))
surf = pygame.Surface((50, 50))
surf.fill("red")
def do_stuff():
pixels = pygame.pixelarray.PixelArray(surf)
pixels.close()
screen.blit(pixels.surface, (0, 0))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill("black")
print("crashes now")
do_stuff()
pygame.display.flip()
(Windows 11, Python 3.11.1, pygame 2.1.3dev8)
(Windows 11, Python 3.11.1, pygame 2.1.4dev1)