SegFault using deque in 2.4b3
George Yoshida
ml at dynkin.com
Thu Sep 30 13:55:01 EDT 2004
Stefan Behnel wrote:
> In Python 2.4b3, the deque is causing a segfault on two different
> machines I tested on.
>
> With deque, my program runs fine for a while (at least some tens of
> seconds up to minutes) and then suddenly segfaults.
>
> I'm sorry I can't tell exactly when, but I'm running an application that
> uses a few hundred deques where elements are appendleft()ed and pop()ed
> (simple queue). As the application is rather complex (and I didn't read
> about this error before anywhere), I guess it could be quite a bit of
> work for me to come up with a test case.
>
> Has anyone else observed this problem?
With trials and errors, I could come up with a deque program which
splits out a Segmentation Fault. (This program is attached at the
end of this mail.) With this program, I get segfault one or two
times out of three on average.
It uses a poor programming style,like appending myself or creating
unnecessary numbers of threads. Anyway it *does* generate
segfault, so I hope that's OK.
FYI, I've tested on:
Python 2.4a3 (#1, Sep 24 2004, 22:35:05)
[GCC 3.3.3 (SuSE Linux)] on linux2
On Win 2K(Python 2.4a3), it generates an Application Error.
- George
## START OF PROGRAM
import threading
import random
from collections import deque
MAX = 10**5
class Deq(threading.Thread):
def __init__(self, N):
threading.Thread.__init__(self)
self.d = deque()
self.N = N
def run(self):
for i in xrange(self.N):
n = random.random()
if n < 0.5:
self.d.appendleft(n)
elif 0.80 < n:
self.d.append(self)
elif self.d:
self.d.pop()
else:
print ".",
def main():
for i in xrange(40):
deq = Deq(random.randint(0, MAX))
deq.start()
if __name__ == '__main__':
main()
## END OF PROGRAM
More information about the Python-list
mailing list