Author amaury.forgeotdarc
Recipients amaury.forgeotdarc
Date 2008-06-19.10:06:45
SpamBayes Score 0.280307
Marked as misclassified No
Message-id <>
I found this problem when adding "print" statements to multi-threaded
code. When applying the attached diff to a py3k installation, the output
on screen always contains some garbage.

The following code is an extract of fileio_write (in Modules/_fileio.c),
but the same behavior appears everywhere:

	if (!PyArg_ParseTuple(args, "s#", &ptr, &n))
		return NULL;

	errno = 0;
	n = write(self->fd, ptr, n);

io.BufferedWriter calls this function with a bytearray.
In this case, the GIL is released when holding a pointer to the
bytearray data.
But another thread may mutate the bytearray in between, the pointer
becomes stale and can lead to segfaults or funny results.
Date User Action Args
2008-06-19 10:06:55amaury.forgeotdarcsetspambayes_score: 0.280307 -> 0.280307
recipients: + amaury.forgeotdarc
2008-06-19 10:06:54amaury.forgeotdarcsetspambayes_score: 0.280307 -> 0.280307
messageid: <>
2008-06-19 10:06:53amaury.forgeotdarclinkissue3139 messages
2008-06-19 10:06:52amaury.forgeotdarccreate