Editra 0.7.20 crashes on Linux when edting code using Pygame

Report Bugs Here

Editra 0.7.20 crashes on Linux when edting code using Pygame

Postby fberger » Mon Feb 04, 2013 11:46 am

Hi,

since the last couple of versions I am getting random crashes when editing Python source code files utilizing Pygame.

Code: Select all
$ editra -dd


gave me:

Code: Select all
...
[12:40:52][ed_txt][info] Write - Complete: [[path omitted by me]].py - Time: 0
[12:40:52][codebrowser][info] Syncing tree for position 278
[12:40:52][codebrowser][info] Syncing tree for position 278
[12:40:54][codebrowser][info] Syncing tree for position 37
[12:40:55][codebrowser][info] Syncing tree for position 37
[12:40:56][codebrowser][info] Syncing tree for position 38
[12:40:56][codebrowser][info] Syncing tree for position 38
[12:40:57][codebrowser][info] Syncing tree for position 39
[12:40:57][codebrowser][info] Syncing tree for position 39
[12:40:58][codebrowser][info] Syncing tree for position 47
[12:40:59][codebrowser][info] Syncing tree for position 33
[12:41:01][codebrowser][info] Syncing tree for position 37
[12:41:02][codebrowser][info] Syncing tree for position 38
[12:41:03][codebrowser][info] Syncing tree for position 39
[12:41:06][pycomp][info] parseassignment: CHANGE_DIRECTION = collections.deque
[12:41:06][pycomp][info] parseassignment: DIRECTIONS = collections.deque
[12:41:06][pycomp][info] parseassignment: self.texture = self.image
[12:41:06][pycomp][info] parseassignment: self.rect = self.image.get_rect
[12:41:06][pycomp][info] parseassignment: self.rect.topleft = position
[12:41:06][pycomp][info] parseassignment: self.body = body
[12:41:06][pycomp][info] parseassignment: pos = self.body.position
[12:41:06][pycomp][info] parseassignment: self.rect.left = int
[12:41:06][pycomp][info] parseassignment: self.rect.top = 600
[12:41:06][pycomp][info] parseassignment: angle = math.degrees
[12:41:06][pycomp][info] parseassignment: self.image = pygame.transform.rotate
[12:41:06][pycomp][info] parseassignment: pressed_keys = pygame.key.get_pressed
[12:41:06][pycomp][info] parseassignment: self.texture = self.image
[12:41:06][pycomp][info] parseassignment: self.rect = self.image.get_rect
[12:41:06][pycomp][info] parseassignment: self.jump_positions = collections.deque
[12:41:06][pycomp][info] parseassignment: self.body = body
[12:41:06][pycomp][info] parseassignment: pos = self.body.position
[12:41:06][pycomp][info] parseassignment: self.rect.left = int
[12:41:06][pycomp][info] parseassignment: self.rect.top = 600
[12:41:06][pycomp][info] parseassignment: self.image = image
[12:41:06][pycomp][info] parseassignment: self.rect = self.image.get_rect
[12:41:06][pycomp][info] parseassignment: self.rect.top = random.randint
[12:41:06][pycomp][info] parseassignment: self.rect.left = random.randint
[12:41:06][pycomp][info] parseassignment: self.direction = ()
[12:41:06][pycomp][err] parseassignment bad token:
[12:41:06][pycomp][info] parseassignment: self.direction = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: mpos = pygame.mouse.get_pos
[12:41:06][pycomp][info] parseassignment: x_dist = mpos
[12:41:06][pycomp][info] parseassignment: y_dist = mpos
[12:41:06][pycomp][info] parseassignment: dist = int
[12:41:06][pycomp][info] parseassignment: self.direction = ()
[12:41:06][pycomp][info] parseassignment: self.rect.left = - 10
[12:41:06][pycomp][info] parseassignment: self.rect.left = 810
[12:41:06][pycomp][info] parseassignment: self.rect.top = - 10
[12:41:06][pycomp][info] parseassignment: self.rect.top = 610
[12:41:06][pycomp][info] parseassignment: body_def = Box2D.b2BodyDef
[12:41:06][pycomp][info] parseassignment: body_def.position = ()
[12:41:06][pycomp][info] parseassignment: body = world.CreateBody
[12:41:06][pycomp][info] parseassignment: shape_def = Box2D.b2PolygonDef
[12:41:06][pycomp][info] parseassignment: shape_def.density = 1
[12:41:06][pycomp][info] parseassignment: shape_def.friction = 0.3
[12:41:06][pycomp][info] parseassignment: shape = body.CreateShape
[12:41:06][pycomp][info] parseassignment: display = pygame.display.set_mode
[12:41:06][pycomp][info] parseassignment: background = pygame.image.load
[12:41:06][pycomp][info] parseassignment: background = background.convert
[12:41:06][pycomp][info] parseassignment: stone_surface = pygame.image.load
[12:41:06][pycomp][info] parseassignment: stone_surface = stone_surface.convert_alpha
[12:41:06][pycomp][info] parseassignment: particle_surface = pygame.image.load
[12:41:06][pycomp][info] parseassignment: particle_surface = particle_surface.convert_alpha
[12:41:06][pycomp][info] parseassignment: stones = pygame.sprite.Group
[12:41:06][pycomp][info] parseassignment: particles = pygame.sprite.Group
[12:41:06][pycomp][info] parseassignment: font = pygame.font.SysFont
[12:41:06][pycomp][info] parseassignment: timer_func = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: timer_func = time.clock
[12:41:06][pycomp][info] parseassignment: timer_func = time.time
[12:41:06][pycomp][info] parseassignment: timestamp = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: update_time = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: render_time = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: event_time = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: idle_time = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: other_time = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: frame_time = _PyCmplNoType()
[12:41:06][pycomp][info] parseassignment: accumulator = 0.0
[12:41:06][pycomp][info] parseassignment: timestep = 1.0
[12:41:06][pycomp][info] parseassignment: exit_flag = False
[12:41:06][pycomp][info] parseassignment: positions = []
[12:41:06][pycomp][info] parseassignment: particle_flag = False
[12:41:06][pycomp][info] parseassignment: more_particles = True
[12:41:06][pycomp][info] parseassignment: timings = []
[12:41:06][pycomp][info] parseassignment: world_aabb = Box2D.b2AABB
[12:41:06][pycomp][info] parseassignment: world_aabb.lowerBound = ()
[12:41:06][pycomp][info] parseassignment: world_aabb.upperBound = ()
[12:41:06][pycomp][info] parseassignment: gravity = Box2D.b2Vec2
[12:41:06][pycomp][info] parseassignment: do_sleep = True
[12:41:06][pycomp][info] parseassignment: world = Box2D.b2World
[12:41:06][pycomp][info] parseassignment: ground_body_def = Box2D.b2BodyDef
[12:41:06][pycomp][info] parseassignment: ground_body_def.position = ()
[12:41:06][pycomp][info] parseassignment: ground_body = world.CreateBody
[12:41:06][pycomp][info] parseassignment: ground_shape_def = Box2D.b2PolygonDef
[12:41:06][pycomp][info] parseassignment: pyramid_stones = pygame.sprite.Group
[12:41:06][pycomp][info] parseassignment: body_def = Box2D.b2BodyDef
[12:41:06][pycomp][info] parseassignment: body_def.position = ()
[12:41:06][pycomp][info] parseassignment: body = world.CreateBody
[12:41:06][pycomp][info] parseassignment: shape_def = Box2D.b2CircleDef
[12:41:06][pycomp][info] parseassignment: shape_def.radius = 0.16
[12:41:06][pycomp][info] parseassignment: shape_def.density = 1
[12:41:06][pycomp][info] parseassignment: shape_def.friction = 0.8
[12:41:06][pycomp][info] parseassignment: shape = body.CreateShape
[12:41:06][pycomp][info] parseassignment: avatar = Avatar
[12:41:06][pycomp][info] parseassignment: avatar.rect.topleft = ()
[12:41:06][pycomp][info] parseassignment: music = pygame.mixer.Sound
[12:41:06][pycomp][info] parseassignment: timestamp = timer_func
[12:41:06][pycomp][info] parseassignment: x = random.randint
[12:41:06][pycomp][info] parseassignment: more_particles = False
[12:41:06][pycomp][info] parseassignment: more_particles = True
[12:41:06][pycomp][info] parseassignment: other_time = timer_func
[12:41:06][pycomp][info] parseassignment: timestamp = timer_func
[12:41:06][pycomp][info] parseassignment: max_runs = 4
[12:41:06][pycomp][info] parseassignment: update_time = timer_func
[12:41:06][pycomp][info] parseassignment: timestamp = timer_func
[12:41:06][pycomp][info] parseassignment: render_time = timer_func
[12:41:06][pycomp][info] parseassignment: timestamp = timer_func
[12:41:06][pycomp][info] parseassignment: event_type_list = []
[12:41:06][pycomp][info] parseassignment: exit_flag = True
[12:41:06][pycomp][info] parseassignment: exit_flag = True
[12:41:06][pycomp][info] parseassignment: particle_flag = False
[12:41:06][pycomp][info] parseassignment: particle_flag = True
[12:41:06][pycomp][info] parseassignment: event_time = timer_func
[12:41:06][pycomp][info] parseassignment: timestamp = timer_func
[12:41:06][pycomp][info] parseassignment: frame_time = 0
[12:41:06][pycomp][info] parseassignment: idle_time = timer_func
[12:41:06][pycomp][info] parseassignment: fp = file
[12:41:06][pycomp][info] parseassignment: csv_str = "{0:.3f},{1:.2f},{2:.2f},{3:.2f},{4:.2f},{5:.2f},{6:.2f},{7:.2f},{8}\n"
[12:41:06][pycomp][err] Pyparser.parse: <class 'tokenize.TokenError'>, ('EOF in multi-line statement', (912, 0))
Fatal Python error: (pygame parachute) Segmentation Fault


It seems to happen when typing certain code constructs. I happily provide more information, please tell me what is needed.

Cheers,

-fberger
fberger
User
 
Posts: 27
Joined: Mon Jul 05, 2010 9:53 am
Location: Germany

Re: Editra 0.7.20 crashes on Linux when edting code using Py

Postby cody » Mon Feb 04, 2013 3:58 pm

Hi,

Looks to be possibly caused by the code completion. Can you confirm if turning off the autocompletion causes the issue to go away?

Then if it does can you locate the line that has the following statement on it

Code: Select all
csv_str = "{0:.3f},{1:.2f},{2:.2f},{3:.2f},{4:.2f},{5:.2f},{6:.2f},{7:.2f},{8}\n"


If possible could you then post the next couple of code statements that come after the above line?

Alternatively if its possible to put together a minimal example code file that causes the problem it will help with debugging.

thanks
User avatar
cody
Site Admin
 
Posts: 1315
Joined: Mon Oct 09, 2006 2:49 am
Location: United States

Re: Editra 0.7.20 crashes on Linux when edting code using Py

Postby fberger » Mon Feb 04, 2013 4:20 pm

cody wrote:Can you confirm if turning off the autocompletion causes the issue to go away?


Looks like it does. Played around at critical pieces. nothing has crashed so far after turning it off.

cody wrote:If possible could you then post the next couple of code statements that come after the above line?


Here's the snippet:

Code: Select all
    print("Attempting to write CSV file")

    fp = open("timing-log.csv", "wt")

    fp.write("timestamp,other_time,update_time,render_time,event_time,idle_time,frame_time,accumulator,particles\n")

    csv_str = "{0:.3f},{1:.2f},{2:.2f},{3:.2f},{4:.2f},{5:.2f},{6:.2f},{7:.2f},{8}\n"

    for time_tuple in timings:

        fp.write(csv_str.format(time_tuple[0],
                                time_tuple[1] * 1000.0,
                                time_tuple[2] * 1000.0,
                                time_tuple[3] * 1000.0,
                                time_tuple[4] * 1000.0,
                                time_tuple[5] * 1000.0,
                                time_tuple[6] * 1000.0,
                                time_tuple[7],
                                time_tuple[8]))

    fp.close()

    print("Timing log written to 'timing-log.csv'.")


Hope that helps. In the meantime I can do without code completion, thanks for the hint.

-fberger
fberger
User
 
Posts: 27
Joined: Mon Jul 05, 2010 9:53 am
Location: Germany

Re: Editra 0.7.20 crashes on Linux when edting code using Py

Postby cody » Mon Feb 04, 2013 4:28 pm

Thanks for the quick confirmation.

I know that on Linux there can be issues with the autocomp under certain cases when an imported module uses some 3rd party packages such as pygtk. There are some protections against these crashes built in but hard to stop them all especially when its a segfault...
User avatar
cody
Site Admin
 
Posts: 1315
Joined: Mon Oct 09, 2006 2:49 am
Location: United States

Re: Editra 0.7.20 crashes on Linux when edting code using Py

Postby fberger » Mon Feb 04, 2013 6:40 pm

In that case it's obviously Pygame and PyBox2D (which is a very hack-y lib).

Is that a result of dynamic code inspection? I.e. it seems that Editra actually imports all the modules that it does code completion for.

Cheers,

-fberger
fberger
User
 
Posts: 27
Joined: Mon Jul 05, 2010 9:53 am
Location: Germany

Re: Editra 0.7.20 crashes on Linux when edting code using Py

Postby cody » Mon Feb 04, 2013 7:51 pm

Yes, the code inspection is done through dynamic introspection. Really about the only way to to it very well in python. It has been a long term task to redesign the autocompleter to run in its own process so that it couldn't bring Editra down or pollute the internal namespace. Issues with the current design however have been far enough inbetween that I haven't felt much urgency to rework it. The issue is likely that since Editra is a GTK application on Linux that importing another module that uses gtk internals is causing some conflict at runtime. Which is a problem that this can happen, much effort is put towards minimizing this risk in how the completions are done.

Basically how the current autocompletion support for Python works:

1) The code is parsed
2) parsed code is used to generate a clone of the code that has had all its execution statements removed (i.e. the () removed from code that is in a scope that would be executed by compiling the code (global scope, ect...)).
3) The generated code is then compiled and executed in its own environment. (note somethings are global to the current python instance will still be shared between the generated code and the running Editra instance.).
4) The resulting 'module' is inspected to get the __dict__ from the object in question for the current caret context
5) Results are displayed to user
6) In memory cleanup of the generated code/module is performed


Ideally I would like to spawn this off into a worker process that is running its own instance of Python to both separate Editra from the possible side effects as well as be able to provide better completions as when using a binary version of Editra the autocompletions will only be able to provide help for modules that are baked into the Editra executable which has its own private python and is not using one that may be installed on the system which may have additional 3rd party libraries installed with it.
User avatar
cody
Site Admin
 
Posts: 1315
Joined: Mon Oct 09, 2006 2:49 am
Location: United States


Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron