Coredumps (Python 1.4)

Anton Graph aglyportREMOvethispart at nospam.yahoo.com
Tue Sep 3 23:11:45 EDT 2002


PyObject *
getfeed(char *feedfilename)
{
	int p[2];
	// create a pipe dolayout would generate output into
	if( pipe(p) < 0 ) {
		raise("piping failed");
	}
	char cmd[256];
	sprintf(cmd, "%s %s %d >/tmp/spt.dolayout 2>&1",
		sptbindir("dolayout"), feedfilename, p[1]);
	// dolayout is killed on SIGPIPE delivery caused by sptdumptags
	// termination
	FILE *fp = popen(cmd, "w");
	close(p[1]);
	if(!fp) {
		raise("can't run dolayout");
	}
	PyObject *layout[2];
	layout[1] = PyFile_FromFile(fp, feedfilename, "w", fclose);
	// line buffering
	if(setvbuf(fp, 0, _IOLBF, 0)) {
		raise("can't make out_feed linebuffered");
	}
	errno = 0;
	fprintf(fp, "lblheight\n");
	fp = fdopen( p[0], "r" );

	char s[128]="";
	if(!fgets(s, sizeof(s), fp)) {
		// l_fatal?
		l_warn("there is nothing in the pipe");
	}else{
		if(verbose)
			fprintf(stderr, "lblheight is %s", s);
	}
	layout[0] = PyFile_FromFile(fp, feedfilename, "r", fclose);
	PyObject *tuple = PyTuple_New(2);
	PyTuple_SET_ITEM(tuple, 0, layout[0]);
	PyTuple_SET_ITEM(tuple, 1, layout[1]);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I coredump on this 
line ever since I linked with Electric Fence memory debugging lib. Any 
ideas why? This is with Python 1.4 on SCO. Any know issues with memory 
allocation there? I'm building 2.2 now, but it will take a while.
This code seem to work fine on Linux.

	return tuple;
}




More information about the Python-list mailing list