Seg fault when loading .blend file inside script

I want to report a bug and also maybe get a little help or advice. I am new to Blender and to graphics, so I apologize ahead of time for any foolishness on my part.

I am running Blender 2.58 on Linux.

My goal is to control Blender in an automated way via another piece of software which would specify the locations and poses of various 3-d characters and then tell Blender to render an image of the scene from a particular viewpoint. My plan is use the other software to prepare the python script which would indicate the desired locations and poses and then execute Blender via the command line in order render the image, without using the Blender GUI.

I was thinking I would upload a “default” .blend file within the python script and then apply the appropriate translations, rotations, etc. to get the desired configuration of the characters before rendering. However, I am still stuck trying to figure out how to load up the .blend file within the python script.

I’m starting out with a very simple test. I launch Blender in the usual way, without any arguments, which launches the GUI. Then I immediately save to a “.blend” file, ‘home/joe/untitled.blend’. I then create a 2-line Python script,, as follows:import bpy

If I run

./blender -b -P -o ‘/home/joe/testJPEG’ -x 1 -F JPEG -f 1

I get:

AL lib: pulseaudio.c:331: PulseAudio returned minreq > tlength/2; expect break up
found bundled python: /home/joe/blender/blender-2.58a-linux-glibc27-x86_64/2.58/python
read blend: /home/joe/untitled.blend
Segmentation fault

If, instead, I create with the following contents:import bpy


… then everything works great. I didn’t bother to delete the default cube in the script, so my cylinder is within the cube, but I can see the top of the cylinder from the top of the cube in the image that is created.

I realize it is likely that I am doing something very dumb here, so this may not be a very important bug, but I figure a segfault is a segfault.

If I run gdb on blender with the command line args that give the segfault, it indicates that it crashes within object_camera_mode() with RE_SetCamera().

Also, if I launch blender with the GUI and I run bpy.ops.wm.open_mainfile(filepath="/home/joe/untitled.blend") from the Python console, then it works.

I’m guessing that there is some additional setup or context I have to provide within the Python script which has already been set up when running from the console from the GUI.

Thanks in advance for any help, and sorry if I’m doing something unnatural or nonsensical. Any advice on how to accomplish what I want to do will be much appreciated.