pygame Double-free or curruption?

pygame Double-free or curruption?

Postby spamynator_1 » Mon Jul 29, 2013 7:10 pm

Im throwing to gether a start menu type of system for a game in python/pygame and im creating a loop within a loop that the inner loop is the start screen, and when you press enter you exit that loop and start the actual contents of the first one.

Code: Select all
import sys, pygame, pygame.mixer#imports necesary libraries
from pygame.locals import *

pygame.init()#starts engine

size = width, height = 640,480#starts window

screen = pygame.display.set_mode(size)

startpage = pygame.image.load("startpage.png")#loads menu image

pressenter = pygame.image.load("pressenter.png")#loads animated 'press enter queue'

menusound = pygame.mixer.Sound("startsound.wav")#loads menu music

menusound.play#starts menu music

red = 255,0,0#defines colors for future use
orange = 255,127,0
yellow = 255,255,0
green = 0,255,0
blue = 0,0,255
indigo = 75,0,130
violet = 143,0,255

x = 0#variables
y = 400
CHODE = 0
one = 0
while CHODE < 1:
    if one == 1:
        buttonnoise = pygame.mixer.Sound("buttonnoise.wav")
        buttonnew = pygame.image.load("buttonnew.png")
        buttoncontinue = pygame.image.load("buttoncontinue.png")
        screen.blit(startpage, (0,0))
        screen.blit(buttonnew, (200,200))
        screen.blit(buttoncontinue, (320,200))
        pygame.display.flip()

    while one < 1:#if you press enter it will start the second screen which is above.
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                sys.exit()
            elif event.type == KEYDOWN and event.key == K_RETURN:
                one = one + 1
 
        screen.blit(startpage, (0,0))
        screen.blit(pressenter,(x,y))
        pygame.display.flip()
        x = x+0.05



yet again im new to this so any help would be appreciated.
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: pygame Double-free or curruption?

Postby Mekire » Tue Jul 30, 2013 12:13 am

I would recommend something more along the lines of this structure (you may need to learn functions and classes first if you haven't already).
Code: Select all
import sys
import os
import pygame as pg


SCREEN_SIZE = SCREEN_WIDTH,SCREEN_HEIGHT = (640,480)

RED = (255,0,0)
ORANGE = (255,127,0)
YELLOW = (255,255,0)
GREEN = (0,255,0)
BLUE = (0,0,255)
INDIGO = (75,0,130)
VIOLET = (143,0,255)


class Control(object):
    def __init__(self):
        self.screen = pg.display.get_surface()
        self.done = False
        self.state = "START"
        self.clock = pg.time.Clock()
        self.fps = 60
        self.enter_coords = [0,400]
        self.keys = pg.key.get_pressed()

    def event_loop(self):
        for event in pg.event.get():
            self.keys = pg.key.get_pressed()
            if event.type == pg.QUIT or self.keys[pg.K_ESCAPE]:
                self.done = True
            elif event.type == pg.KEYDOWN:
                if event.key == pg.K_RETURN and self.state == "START":
                    self.state = "MENU"

    def main_loop(self):
        while not self.done:
            self.event_loop()
            self.update()
            pg.display.update()
            self.clock.tick(self.fps)

    def update(self):
        if self.state == "START":
            self.screen.blit(START_PAGE,(0,0))
            self.screen.blit(PRESS_ENTER,self.enter_coords)
            self.enter_coords[0] = (self.enter_coords[0]+2)
        elif self.state == "MENU":
            self.screen.blit(START_PAGE,(0,0))
            self.screen.blit(BUTTON_NEW,(200,200))
            self.screen.blit(BUTTON_CONTINUE,(320,200))


if __name__ == "__main__":
    os.environ["SDL_VIDEO_CENTERED"] = '1'
    pg.init()
    pg.display.set_mode(SCREEN_SIZE)

    #Resources would generally be loaded and placed in a dict in another module.
    START_PAGE = pg.image.load("startpage.png").convert()
    PRESS_ENTER = pg.image.load("pressenter.png").convert()
    BUTTON_NEW = pg.image.load("buttonnew.png").convert()
    BUTTON_CONTINUE = pg.image.load("buttoncontinue.png").convert()
    MENU_SOUND = pg.mixer.Sound("startsound.wav")
    BUTTON_NOISE = pg.mixer.Sound("buttonnoise.wav")
    MENU_SOUND.play(-1)

    run_it = Control()
    run_it.main_loop()
    pg.quit()
    sys.exit()

When your program becomes more complex the states will actually be their own separate classes. What specifically are you having issues with?

-Mek
Last edited by Mekire on Tue Jul 30, 2013 12:59 am, edited 2 times in total.
User avatar
Mekire
 
Posts: 1015
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygame Double-free or curruption?

Postby spamynator_1 » Tue Jul 30, 2013 12:27 am

well i dont really understand classes. but even the version you sent me returns,

Code: Select all
*** Error in `python': double free or corruption (!prev): 0x0000000000d02590 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7cef8)[0x7f91f8e04ef8]
/lib64/libc.so.6(fclose+0x14d)[0x7f91f8df38ad]
/lib64/libSDL-1.2.so.0(+0xfc59)[0x7f91f21c7c59]
/lib64/libSDL_mixer-1.2.so.0(Mix_LoadWAV_RW+0xe6)[0x7f91ed367d96]
/usr/lib64/python2.7/site-packages/pygame/mixer.so(+0x341e)[0x7f91ed15b41e]
/lib64/libpython2.7.so.1.0(+0x9d69f)[0x7f91f9b1d69f]
/lib64/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f91f9ac9dd3]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x25fc)[0x7f91f9b5b6dc]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x7ed)[0x7f91f9b5ec7d]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x32)[0x7f91f9b5ed82]
/lib64/libpython2.7.so.1.0(+0xf78af)[0x7f91f9b778af]
/lib64/libpython2.7.so.1.0(PyRun_FileExFlags+0x7e)[0x7f91f9b789ce]
/lib64/libpython2.7.so.1.0(PyRun_SimpleFileExFlags+0xd9)[0x7f91f9b79b39]
/lib64/libpython2.7.so.1.0(Py_Main+0xc7f)[0x7f91f9b8a66f]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f91f8da9b75]
python[0x400721]
======= Memory map: ========
00400000-00401000 r-xp 00000000 fd:00 65980                              /usr/bin/python2.7
00600000-00601000 r--p 00000000 fd:00 65980                              /usr/bin/python2.7
00601000-00602000 rw-p 00001000 fd:00 65980                              /usr/bin/python2.7
00b01000-011c6000 rw-p 00000000 00:00 0                                  [heap]
7f91d8000000-7f91d8021000 rw-p 00000000 00:00 0
7f91d8021000-7f91dc000000 ---p 00000000 00:00 0
7f91de1be000-7f91de2eb000 rw-p 00000000 00:00 0
7f91de418000-7f91de544000 rw-s 00000000 00:04 1703940                    /SYSV00000000 (deleted)
7f91de548000-7f91de588000 r-xp 00000000 fd:00 49604                      /usr/lib64/libmikmod.so.3.0.0
7f91de588000-7f91de787000 ---p 00040000 fd:00 49604                      /usr/lib64/libmikmod.so.3.0.0
7f91de787000-7f91de788000 r--p 0003f000 fd:00 49604                      /usr/lib64/libmikmod.so.3.0.0
7f91de788000-7f91de78a000 rw-p 00040000 fd:00 49604                      /usr/lib64/libmikmod.so.3.0.0
7f91de78a000-7f91de78c000 rw-p 00000000 00:00 0
7f91de78f000-7f91de790000 ---p 00000000 00:00 0
7f91de790000-7f91def90000 rw-p 00000000 00:00 0                          [stack:2869]
7f91def90000-7f91e2f91000 rw-s 00000000 00:10 34850                      /dev/shm/pulse-shm-3271115559
7f91e2f98000-7f91e2f9c000 r-xp 00000000 fd:00 60266                      /usr/lib64/libattr.so.1.1.0
7f91e2f9c000-7f91e319b000 ---p 00004000 fd:00 60266                      /usr/lib64/libattr.so.1.1.0
7f91e319b000-7f91e319c000 r--p 00003000 fd:00 60266                      /usr/lib64/libattr.so.1.1.0
7f91e319c000-7f91e319d000 rw-p 00004000 fd:00 60266                      /usr/lib64/libattr.so.1.1.0
7f91e31a0000-7f91e31b6000 r-xp 00000000 fd:00 59868                      /usr/lib64/libresolv-2.17.so
7f91e31b6000-7f91e33b6000 ---p 00016000 fd:00 59868                      /usr/lib64/libresolv-2.17.so
7f91e33b6000-7f91e33b7000 r--p 00016000 fd:00 59868                      /usr/lib64/libresolv-2.17.so
7f91e33b7000-7f91e33b8000 rw-p 00017000 fd:00 59868                      /usr/lib64/libresolv-2.17.so
7f91e33b8000-7f91e33ba000 rw-p 00000000 00:00 0
7f91e33c0000-7f91e33c6000 r-xp 00000000 fd:00 60745                      /usr/lib64/libogg.so.0.8.0
7f91e33c6000-7f91e35c5000 ---p 00006000 fd:00 60745                      /usr/lib64/libogg.so.0.8.0
7f91e35c5000-7f91e35c6000 r--p 00005000 fd:00 60745                      /usr/lib64/libogg.so.0.8.0
7f91e35c6000-7f91e35c7000 rw-p 00006000 fd:00 60745                      /usr/lib64/libogg.so.0.8.0
7f91e35c8000-7f91e35f4000 r-xp 00000000 fd:00 60798                      /usr/lib64/libvorbis.so.0.4.6
7f91e35f4000-7f91e37f4000 ---p 0002c000 fd:00 60798                      /usr/lib64/libvorbis.so.0.4.6
7f91e37f4000-7f91e37f5000 r--p 0002c000 fd:00 60798                      /usr/lib64/libvorbis.so.0.4.6
7f91e37f5000-7f91e37f6000 rw-p 0002d000 fd:00 60798                      /usr/lib64/libvorbis.so.0.4.6
7f91e37f8000-7f91e3aab000 r-xp 00000000 fd:00 60800                      /usr/lib64/libvorbisenc.so.2.0.9
7f91e3aab000-7f91e3caa000 ---p 002b3000 fd:00 60800                      /usr/lib64/libvorbisenc.so.2.0.9
7f91e3caa000-7f91e3cc6000 r--p 002b2000 fd:00 60800                      /usr/lib64/libvorbisenc.so.2.0.9
7f91e3cc6000-7f91e3cc7000 rw-p 002ce000 fd:00 60800                      /usr/lib64/libvorbisenc.so.2.0.9
7f91e3cc8000-7f91e3d0b000 r-xp 00000000 fd:00 61319                      /usr/lib64/libFLAC.so.8.3.0
7f91e3d0b000-7f91e3f0a000 ---p 00043000 fd:00 61319                      /usr/lib64/libFLAC.so.8.3.0
7f91e3f0a000-7f91e3f0b000 r--p 00042000 fd:00 61319                      /usr/lib64/libFLAC.so.8.3.0
7f91e3f0b000-7f91e3f0c000 rw-p 00043000 fd:00 61319                      /usr/lib64/libFLAC.so.8.3.0
7f91e3f10000-7f91e3f1b000 r-xp 00000000 fd:00 61505                      /usr/lib64/libgsm.so.1.0.12
7f91e3f1b000-7f91e411a000 ---p 0000b000 fd:00 61505                      /usr/lib64/libgsm.so.1.0.12
7f91e411a000-7f91e411b000 r--p 0000a000 fd:00 61505                      /usr/lib64/libgsm.so.1.0.12
7f91e411b000-7f91e411c000 rw-p 0000b000 fd:00 61505                      /usr/lib64/libgsm.so.1.0.12
7f91e4120000-7f91e4136000 r-xp 00000000 fd:00 59850                      /usr/lib64/libnsl-2.17.so
7f91e4136000-7f91e4335000 ---p 00016000 fd:00 59850                      /usr/lib64/libnsl-2.17.so
7f91e4335000-7f91e4336000 r--p 00015000 fd:00 59850                      /usr/lib64/libnsl-2.17.so
7f91e4336000-7f91e4337000 rw-p 00016000 fd:00 59850                      /usr/lib64/libnsl-2.17.so
7f91e4337000-7f91e4339000 rw-p 00000000 00:00 0
7f91e4340000-7f91e434f000 r-xp 00000000 fd:00 61217                      /usr/lib64/libXi.so.6.1.0
7f91e434f000-7f91e454e000 ---p 0000f000 fd:00 61217                      /usr/lib64/libXi.so.6.1.0
7f91e454e000-7f91e454f000 r--p 0000e000 fd:00 61217                      /usr/lib64/libXi.so.6.1.0
7f91e454f000-7f91e4550000 rw-p 0000f000 fd:00 61217                      /usr/lib64/libXi.so.6.1.0
7f91e4550000-7f91e4554000 r-xp 00000000 fd:00 60317                      /usr/lib64/libuuid.so.1.3.0
7f91e4554000-7f91e4753000 ---p 00004000 fd:00 60317                      /usr/lib64/libuuid.so.1.3.0
7f91e4753000-7f91e4754000 r--p 00003000 fd:00 60317                      /usr/lib64/libuuid.so.1.3.0
7f91e4754000-7f91e4755000 rw-p 00004000 fd:00 60317                      /usr/lib64/libuuid.so.1.3.0
7f91e4758000-7f91e4761000 r-xp 00000000 fd:00 60763                      /usr/lib64/libjson-c.so.2.0.1
7f91e4761000-7f91e4961000 ---p 00009000 fd:00 60763                      /usr/lib64/libjson-c.so.2.0.1
7f91e4961000-7f91e4962000 r--p 00009000 fd:00 60763                      /usr/lib64/libjson-c.so.2.0.1
7f91e4962000-7f91e4963000 rw-p 0000a000 fd:00 60763                      /usr/lib64/libjson-c.so.2.0.1
7f91e4968000-7f91e496f000 r-xp 00000000 fd:00 59870                      /usr/lib64/librt-2.17.so
7f91e496f000-7f91e4b6e000 ---p 00007000 fd:00 59870                      /usr/lib64/librt-2.17.so
7f91e4b6e000-7f91e4b6f000 r--p 00006000 fd:00 59870                      /usr/lib64/librt-2.17.so
7f91e4b6f000-7f91e4b70000 rw-p 00007000 fd:00 59870                      /usr/lib64/librt-2.17.so
7f91e4b70000-7f91e4b74000 r-xp 00000000 fd:00 60269                      /usr/lib64/libcap.so.2.22
7f91e4b74000-7f91e4d73000 ---p 00004000 fd:00 60269                      /usr/lib64/libcap.so.2.22
7f91e4d73000-7f91e4d74000 r--p 00003000 fd:00 60269                      /usr/lib64/libcap.so.2.22
7f91e4d74000-7f91e4d75000 rw-p 00004000 fd:00 60269                      /usr/lib64/libcap.so.2.22
7f91e4d78000-7f91e4dbd000 r-xp 00000000 fd:00 60295                      /usr/lib64/libdbus-1.so.3.7.2
7f91e4dbd000-7f91e4fbc000 ---p 00045000 fd:00 60295                      /usr/lib64/libdbus-1.so.3.7.2
7f91e4fbc000-7f91e4fbd000 r--p 00044000 fd:00 60295                      /usr/lib64/libdbus-1.so.3.7.2
7f91e4fbd000-7f91e4fbe000 rw-p 00045000 fd:00 60295                      /usr/lib64/libdbus-1.so.3.7.2
7f91e4fc0000-7f91e4fc5000 r-xp 00000000 fd:00 61161                      /usr/lib64/libasyncns.so.0.3.1
7f91e4fc5000-7f91e51c4000 ---p 00005000 fd:00 61161                      /usr/lib64/libasyncns.so.0.3.1
7f91e51c4000-7f91e51c5000 r--p 00004000 fd:00 61161                      /usr/lib64/libasyncns.so.0.3.1
7f91e51c5000-7f91e51c6000 rw-p 00005000 fd:00 61161                      /usr/lib64/libasyncns.so.0.3.1
7f91e51c8000-7f91e5220000 r-xp 00000000 fd:00 61507                      /usr/lib64/libsndfile.so.1.0.25
7f91e5220000-7f91e5420000 ---p 00058000 fd:00 61507                      /usr/lib64/libsndfile.so.1.0.25
7f91e5420000-7f91e5422000 r--p 00058000 fd:00 61507                      /usr/lib64/libsndfile.so.1.0.25
7f91e5422000-7f91e5423000 rw-p 0005a000 fd:00 61507                      /usr/lib64/libsndfile.so.1.0.25
7f91e5423000-7f91e5427000 rw-p 00000000 00:00 0
7f91e5428000-7f91e5431000 r-xp 00000000 fd:00 60449                      /usr/lib64/libwrap.so.0.7.6
7f91e5431000-7f91e5630000 ---p 00009000 fd:00 60449                      /usr/lib64/libwrap.so.0.7.6
7f91e5630000-7f91e5631000 r--p 00008000 fd:00 60449                      /usr/lib64/libwrap.so.0.7.6
7f91e5631000-7f91e5632000 rw-p 00009000 fd:00 60449                      /usr/lib64/libwrap.so.0.7.6
7f91e5632000-7f91e5633000 rw-p 00000000 00:00 0
7f91e5638000-7f91e563d000 r-xp 00000000 fd:00 61225                      /usr/lib64/libXtst.so.6.1.0
7f91e563d000-7f91e583c000 ---p 00005000 fd:00 61225                      /usr/lib64/libXtst.so.6.1.0
7f91e583c000-7f91e583d000 r--p 00004000 fd:00 61225                      /usr/lib64/libXtst.so.6.1.0
7f91e583d000-7f91e583e000 rw-p 00005000 fd:00 61225                      /usr/lib64/libXtst.so.6.1.0
7f91e5840000-7f91e5847000 r-xp 00000000 fd:00 60443                      /usr/lib64/libSM.so.6.0.1
7f91e5847000-7f91e5a46000 ---p 00007000 fd:00 60443                      /usr/lib64/libSM.so.6.0.1
7f91e5a46000-7f91e5a47000 r--p 00006000 fd:00 60443                      /usr/lib64/libSM.so.6.0.1
7f91e5a47000-7f91e5a48000 rw-p 00007000 fd:00 60443                      /usr/lib64/libSM.so.6.0.1
7f91e5a48000-7f91e5a5f000 r-xp 00000000 fd:00 60439                      /usr/lib64/libICE.so.6.3.0
7f91e5a5f000-7f91e5c5e000 ---p 00017000 fd:00 60439                      /usr/lib64/libICE.so.6.3.0
7f91e5c5e000-7f91e5c5f000 r--p 00016000 fd:00 60439                      /usr/lib64/libICE.so.6.3.0
7f91e5c5f000-7f91e5c60000 rw-p 00017000 fd:00 60439                      /usr/lib64/libICE.so.6.3.0
7f91e5c60000-7f91e5c64000 rw-p 00000000 00:00 0
7f91e5c68000-7f91e5c69000 r-xp 00000000 fd:00 61211                      /usr/lib64/libX11-xcb.so.1.0.0
7f91e5c69000-7f91e5e68000 ---p 00001000 fd:00 61211                      /usr/lib64/libX11-xcb.so.1.0.0
7f91e5e68000-7f91e5e69000 r--p 00000000 fd:00 61211                      /usr/lib64/libX11-xcb.so.1.0.0
7f91e5e69000-7f91e5e6a000 rw-p 00001000 fd:00 61211                      /usr/lib64/libX11-xcb.so.1.0.0
7f91e5e70000-7f91e5ed6000 r-xp 00000000 fd:00 61516                      /usr/lib64/pulseaudio/libpulsecommon-3.0.so
7f91e5ed6000-7f91e60d5000 ---p 00066000 fd:00 61516                      /usr/lib64/pulseaudio/libpulsecommon-3.0.so
7f91e60d5000-7f91e60d6000 r--p 00065000 fd:00 61516                      /usr/lib64/pulseaudio/libpulsecommon-3.0.so
7f91e60d6000-7f91e60d8000 rw-p 00066000 fd:00 61516                      /usr/lib64/pulseaudio/libpulsecommon-3.0.so
7f91e60d8000-7f91e60d9000 r-xp 00000000 fd:00 60765                      /usr/lib64/libjson.so.0.1.0
7f91e60d9000-7f91e62d8000 ---p 00001000 fd:00 60765                      /usr/lib64/libjson.so.0.1.0
7f91e62d8000-7f91e62d9000 r--p 00000000 fd:00 60765                      /usr/lib64/libjson.so.0.1.0
7f91e62d9000-7f91e62da000 rw-p 00001000 fd:00 60765                      /usr/lib64/libjson.so.0.1.0
7f91e62e0000-7f91e6328000 r-xp 00000000 fd:00 61513                      /usr/lib64/libpulse.so.0.15.3
7f91e6328000-7f91e6528000 ---p 00048000 fd:00 61513                      /usr/lib64/libpulse.so.0.15.3
7f91e6528000-7f91e6529000 r--p 00048000 fd:00 61513                      /usr/lib64/libpulse.so.0.15.3
7f91e6529000-7f91e652a000 rw-p 00049000 fd:00 61513                      /usr/lib64/libpulse.so.0.15.3
7f91e6530000-7f91e6533000 r-xp 00000000 fd:00 61511                      /usr/lib64/libpulse-simple.so.0.0.3
7f91e6533000-7f91e6733000 ---p 00003000 fd:00 61511                      /usr/lib64/libpulse-simple.so.0.0.3
7f91e6733000-7f91e6734000 r--p 00003000 fd:00 61511                      /usr/lib64/libpulse-simple.so.0.0.3
7f91e6734000-7f91e6735000 rw-p 00004000 fd:00 61511                      /usr/lib64/libpulse-simple.so.0.0.3
7f91e6738000-7f91e673d000 r-xp 00000000 fd:00 61219                      /usr/lib64/libXfixes.so.3.1.0
7f91e673d000-7f91e693c000 ---p 00005000 fd:00 61219                      /usr/lib64/libXfixes.so.3.1.0
7f91e693c000-7f91e693d000 r--p 00004000 fd:00 61219                      /usr/lib64/libXfixes.so.3.1.0
7f91e693d000-7f91e693e000 rw-p 00005000 fd:00 61219                      /usr/lib64/libXfixes.so.3.1.0
7f91e6940000-7f91e6949000 r-xp 00000000 fd:00 61238                      /usr/lib64/libXcursor.so.1.0.2
7f91e6949000-7f91e6b49000 ---p 00009000 fd:00 61238                      /usr/lib64/libXcursor.so.1.0.2
7f91e6b49000-7f91e6b4a000 r--p 00009000 fd:00 61238                      /usr/lib64/libXcursor.so.1.0.2
7f91e6b4a000-7f91e6b4b000 rw-p 0000a000 fd:00 61238                      /usr/lib64/libXcursor.so.1.0.2
7f91e6b50000-7f91e6b59000 r-xp 00000000 fd:00 61229                      /usr/lib64/libXrandr.so.2.2.0
7f91e6b59000-7f91e6d58000 ---p 00009000 fd:00 61229                      /usr/lib64/libXrandr.so.2.2.0
7f91e6d58000-7f91e6d59000 r--p 00008000 fd:00 61229                      /usr/lib64/libXrandr.so.2.2.0
7f91e6d59000-7f91e6d5a000 rw-p 00009000 fd:00 61229                      /usr/lib64/libXrandr.so.2.2.0
7f91e6d60000-7f91e6d69000 r-xp 00000000 fd:00 61227                      /usr/lib64/libXrender.so.1.3.0
7f91e6d69000-7f91e6f68000 ---p 00009000 fd:00 61227                      /usr/lib64/libXrender.so.1.3.0
7f91e6f68000-7f91e6f69000 r--p 00008000 fd:00 61227                      /usr/lib64/libXrender.so.1.3.0
7f91e6f69000-7f91e6f6a000 rw-p 00009000 fd:00 61227                      /usr/lib64/libXrender.so.1.3.0
7f91e6f70000-7f91e6f81000 r-xp 00000000 fd:00 61215                      /usr/lib64/libXext.so.6.4.0
7f91e6f81000-7f91e7180000 ---p 00011000 fd:00 61215                      /usr/lib64/libXext.so.6.4.0
7f91e7180000-7f91e7181000 r--p 00010000 fd:00 61215                      /usr/lib64/libXext.so.6.4.0
7f91e7181000-7f91e7182000 rw-p 00011000 fd:00 61215                      /usr/lib64/libXext.so.6.4.0
7f91e7187000-7f91e7188000 ---p 00000000 00:00 0
7f91e7188000-7f91e7988000 rw-p 00000000 00:00 0                          [stack:2867]
7f91e7988000-7f91e798b000 r-xp 00000000 fd:00 149405                     /usr/lib64/python2.7/site-packages/pygame/fastevent.so
7f91e798b000-7f91e7b8a000 ---p 00003000 fd:00 149405                     /usr/lib64/python2.7/site-packages/pygame/fastevent.so
7f91e7b8a000-7f91e7b8b000 r--p 00002000 fd:00 149405                     /usr/lib64/python2.7/site-packages/pygame/fastevent.so
7f91e7b8b000-7f91e7b8c000 rw-p 00003000 fd:00 149405                     /usr/lib64/python2.7/site-packages/pygame/fastevent.so
7f91e7b90000-7f91e7b92000 r-xp 00000000 fd:00 149230                     /usr/lib64/python2.7/site-packages/pygame/_numericsndarray.so
7f91e7b92000-7f91e7d91000 ---p 00002000 fd:00 149230                     /usr/lib64/python2.7/site-packages/pygame/_numericsndarray.soAborted (core dumped)
[liveuser@localhost Downloads]$
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: pygame Double-free or curruption?

Postby Mekire » Tue Jul 30, 2013 1:01 am

Noticed I forgot the parenthesis in the playing sound call (as I didn't have any files to test it with):
Code: Select all
MENU_SOUND.play(-1)

This is probably not the cause of your glitch though. Really no clue. Is there an exception? What is it?

-Mek

Edit:
It seems like your program is trying to find the numpy module (which it shouldn't need). Again no clue, but you could try installing numpy and see if it changes anything.
User avatar
Mekire
 
Posts: 1015
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygame Double-free or curruption?

Postby spamynator_1 » Tue Jul 30, 2013 1:56 am

numpy is already installed
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: pygame Double-free or curruption?

Postby Mekire » Tue Jul 30, 2013 2:05 am

Again I need more information. Is there an actual exception being raised? If so what is it? Are you capable of running any pygame programs or do they only fail if they have sound?

-Mek
User avatar
Mekire
 
Posts: 1015
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygame Double-free or curruption?

Postby spamynator_1 » Tue Jul 30, 2013 2:09 am

that is about correct. this pygame works flawlessly until you call upon the sound.
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: pygame Double-free or curruption?

Postby Mekire » Tue Jul 30, 2013 2:18 am

Operating system? Version of python/pygame?

You can try adding:
Code: Select all
pg.mixer.init()
right after:
Code: Select all
pg.init()
but as it technically shouldn't be necessary I doubt it will help.

-Mek

Edit: You still haven't told me if there was an exception (or what it was if there was).
User avatar
Mekire
 
Posts: 1015
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygame Double-free or curruption?

Postby spamynator_1 » Tue Jul 30, 2013 2:58 am

what do you mean by exception



and im using fedora 19 live running on vmbox.

the python/pygame versions are 2.7 and newest pygame release?
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: pygame Double-free or curruption?

Postby Mekire » Tue Jul 30, 2013 3:04 am

For example if I indented the first line of my program by mistake I would get this:
Code: Select all
>>>
  File "C:\Users\Owner\Desktop\spammy\test.py", line 1
    import sys
   ^
IndentationError: unexpected indent

IndentationError is the exception name.

-Mek
User avatar
Mekire
 
Posts: 1015
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygame Double-free or curruption?

Postby spamynator_1 » Tue Jul 30, 2013 4:02 am

nope all it gives me is

*** Error in `python': double free or corruption (!prev): 0x0000000000d02590 ***
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: pygame Double-free or curruption?

Postby Mekire » Tue Jul 30, 2013 4:54 am

Afraid I really can't help you, other than telling you that the code in my previous post does work (assuming the graphic and sound resource files exist). My only suggestion would be to uninstall pygame and then attempt to install it again, but I have no clue if that would help.

-Mek
User avatar
Mekire
 
Posts: 1015
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygame Double-free or curruption?

Postby spamynator_1 » Tue Jul 30, 2013 5:51 am

Could you take my code i submitted and and attempt to run it on your machine, if it works i know its the machines problem
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am

Re: pygame Double-free or curruption?

Postby Mekire » Tue Jul 30, 2013 6:01 am

Your program works fine on my machine. You forgot to call pygame.quit() on exit, and you never actually told the music to play (the aforementioned forgotten parenthesis), but neither of these things are fatal. My rewrite was just emphasizing proper structuring.

-Mek
User avatar
Mekire
 
Posts: 1015
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: pygame Double-free or curruption?

Postby spamynator_1 » Tue Jul 30, 2013 6:04 am

alright thank you, im going to try getting a real linux machine running and hopefully that helps.
spamynator_1
 
Posts: 63
Joined: Sun Mar 03, 2013 12:45 am


Return to Game Development

Who is online

Users browsing this forum: Google [Bot] and 1 guest