I'm using python 2.7.10 and pygame 1.9.1 on OS X 10.11.1
I'm getting Segmentation fault: 11
& python crashes whenever I draw anything on or fill a pygame surface (at least I think that's the cause). I have several pygame projects I've done for school that have worked on this same machine in the past, but simply crash now. I don't recall changing python or pygame versions since then, only updating OS X version.
This is a simple little program that should just display a red rectangle on a purple-ish background:
import pygame
import pygame.locals
class ExampleClass:
def __init__(self):
self.screen = pygame.display.set_mode(
(100, 100),
pygame.locals.DOUBLEBUF |
pygame.locals.SRCALPHA)
def paint(self, surface):
surface.fill((100, 50, 255)) # blue-purple-y background
pygame.draw.rect(surface, (255, 50, 100), (10, 10, 50, 25)) # red rectangle
def main_loop(self):
clock = pygame.time.Clock()
while True:
clock.tick(30)
for e in pygame.event.get():
if e.type == pygame.QUIT:
pygame.quit()
return
if e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE:
pygame.quit()
return
self.paint(self.screen)
pygame.display.flip()
example = ExampleClass()
example.main_loop()
I tried this on a windows machine & it worked completely fine, however it crashes on my mac. If you comment out self.paint(self.screen)
, the window pops up & there's no crash. I've searched around a bit and not found much. I have no idea what's causing it to do this, any help would be greatly appreciated.