Hi all,

I believe I have found a bug in DataPostbox.release(). (I'm using git master, currently 43089ed.)

According to the javadoc comments, Releaseable.release() can be called multiple times. However, DataPostbox.release() can only be called once. If it is called a second time, it blocks forever waiting for the output thread (which no longer exists) to release.

I noticed this because the pbf reader can call release() twice, triggering the lockup. To recreate, you can run the following:

    osmosis --read-pbf /dev/null --buffer --write-null

The two calls to DataPostbox.release() have the following stack traces:

java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1266)
at org.openstreetmap.osmosis.core.store.DataPostbox.release(DataPostbox.java:335) at org.openstreetmap.osmosis.core.buffer.v0_6.EntityBuffer.release(EntityBuffer.java:64) at crosby.binary.osmosis.OsmosisBinaryParser.complete(OsmosisBinaryParser.java:36) at crosby.binary.file.BlockInputStream.process(BlockInputStream.java:37)
        at crosby.binary.osmosis.OsmosisReader.run(OsmosisReader.java:45)
        at java.lang.Thread.run(Thread.java:679)
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1266)
at org.openstreetmap.osmosis.core.store.DataPostbox.release(DataPostbox.java:335) at org.openstreetmap.osmosis.core.buffer.v0_6.EntityBuffer.release(EntityBuffer.java:64)
        at crosby.binary.osmosis.OsmosisReader.run(OsmosisReader.java:50)
        at java.lang.Thread.run(Thread.java:679)

Deleting line 36 of pbf/src/main/java/crosby/binary/osmosis/OsmosisBinaryParser.java will cause DataPostbox.release() to be called only once, but that just avoids the bug.

I believe a proper fix to DataPostbox.release() will require a minor redesign of the DataPostbox lifetime management code. I'm not familiar enough with the code to feel comfortable making such a change. I can take a crack at it, but I'm hoping an expert has the time to take a look.

Thanks,
Richard

_______________________________________________
osmosis-dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/osmosis-dev

Reply via email to