1
Vote

The BarcodeDrawFactory is not thread-safe

description

At least one of the specific barcode draw factories are not thread safe. The static constructor performs non-synchronized operations that may cause exceptions to be thrown while building the map of glyphs.

Example for producing exception:
var largeString = "0123456789";
Func<string, BarcodeMetrics, Image> f = BarcodeDrawFactory.Code25InterleavedWithoutChecksum.Draw;
Parallel.ForEach(Enumerable.Range(0, 10), i =>
{
    for(var x = 0; x < 1000000; x++) {}
    
    f(largeString, new BarcodeMetrics1d(2, 30));
});

comments

thzinc wrote Jul 17, 2015 at 8:45 PM

I've submitted a patch to fix this issue.