1

Closed

Race condition with LoadLayerContext

description

The file is attached. Followed the instructions, so the Paint.Net showed the PSD file on disk, but after selecting it got "There was an unspecified error while opening this file".

file attachments

Closed Apr 20, 2012 at 4:59 AM by taoyue
Fixed in revision 846d235a84c1.

comments

taoyue wrote Apr 20, 2012 at 4:48 AM

Finally! I've managed to reproduce the failure. Only occurs about 10% of the time, at random.

The cause is a race condition while loading layers. List<> is not thread-safe, but is being called without first being locked. As a result, Layers can be lost when the List resizes itself. This particular file has 225 layers with dimensions of 24 x 24 each. Because the layers are so small, the LoadLayersContext tasks are completing so quickly that they have a chance of racing with the outer for loop.

Thanks for reporting the bug! Nondeterministic bugs are the hardest sort to track down.