Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; '__name__': 0.07; 'bug.': 0.07; 'suppose': 0.07; 'calculates': 0.09; 'threads,': 0.09; 'bug': 0.10; 'cc:addr:python-list': 0.10; 'def': 0.10; 'thread': 0.11; '(the': 0.15; 'file,': 0.15; "'__main__':": 0.16; 'blocks': 0.16; 'disk.': 0.16; 'intermittent': 0.16; 'passes,': 0.16; 'reproduce': 0.16; 'run(self):': 0.16; 'sorts': 0.16; 'subject:failed': 0.16; 'threading': 0.16; 'threads': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'fix': 0.17; 'import': 0.21; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'idea': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'bugs': 0.27; 'guess': 0.27; 'start,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'rest': 0.28; 'run': 0.28; "d'aprano": 0.29; 'really,': 0.29; 'steven': 0.29; 'starts': 0.29; 'class': 0.29; 'expect': 0.31; 'code': 0.31; 'gets': 0.32; 'file': 0.32; 'could': 0.32; 'right?': 0.33; 'problem': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'remote': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'there': 0.35; 'add': 0.36; 'really': 0.36; 'but': 0.36; 'depends': 0.36; 'anything': 0.36; 'should': 0.36; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'there,': 0.38; 'where': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'matter': 0.61; 'details': 0.63; 'find.': 0.84; 'happening?': 0.84; 'shares': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=zgZOv42og0wY0+o0M/2WRMJap1Hlw1f9OmqIllO65WI=; b=Dv3omEtk9O1nQq89z5hd3E6385OtifycEn9VF5GCkC6X1ggJqTmAKx/do8jTUYy7iD qnO+M6WdkPlxoasmNrQutyL0+Ac2Ii21Dg3YHMv8i6RSw48J09LfLflmZw+YdQd3yuD7 EzSyWMB+tXTqzAeOvQ3OtXXjFsE/DL3+lP3pdMYRLvOfovAU9LZAJYFi6JmQeWKgTs8f WDAOqPtRZqGaURGcqYtrXWWTqVDp/xt7XrEC3jY6JTBrL2iC0eWG+nDZ/UNoLZhvXn5j Wc5JIc53UfCWURGRaaosYoDl8k8S2ecZ7+L3Wci5btIhnU6goGBhARbmsGGTc2GuZ0Et Zgig== MIME-Version: 1.0 In-Reply-To: <501956a7$0$29978$c3e8da3$5496439d@news.astraweb.com> References: <50190ED6.1040100@shopzeus.com> <501956a7$0$29978$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 2 Aug 2012 10:26:51 +0100 Subject: Re: CRC-checksum failed in gzip From: andrea crotti To: "Steven D'Aprano" Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343899619 news.xs4all.nl 6889 [2001:888:2000:d::a6]:52173 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:26389 2012/8/1 Steven D'Aprano : > > When you start using threads, you have to expect these sorts of > intermittent bugs unless you are very careful. > > My guess is that you have a bug where two threads read from the same file > at the same time. Since each read shares state (the position of the file > pointer), you're going to get corruption. Because it depends on timing > details of which threads do what at exactly which microsecond, the effect > might as well be random. > > Example: suppose the file contains three blocks A B and C, and a > checksum. Thread 8 starts reading the file, and gets block A and B. Then > thread 2 starts reading it as well, and gets half of block C. Thread 8 > gets the rest of block C, calculates the checksum, and it doesn't match. > > I recommend that you run a file system check on the remote disk. If it > passes, you can eliminate file system corruption. Also, run some network > diagnostics, to eliminate corruption introduced in the network layer. But > I expect that you won't find anything there, and the problem is a simple > thread bug. Simple, but really, really hard to find. > > Good luck. One last thing I would like to do before I add this fix is to actually be able to reproduce this behaviour, and I thought I could just do the following: import gzip import threading class OpenAndRead(threading.Thread): def run(self): fz = gzip.open('out2.txt.gz') fz.read() fz.close() if __name__ == '__main__': for i in range(100): OpenAndRead().start() But no matter how many threads I start, I can't reproduce the CRC error, any idea how I can try to help it happening? The code in run should be shared by all the threads since there are no locks, right?