The code for .asBuffer on any pointer is not threadsafe. In the base java class, both position and limit are mangled to call an underlying call and then reset.
This results in intermittent crashes if the expectation is that .asBuffer is threadsafe and the documentation does not state that it is not (or I missed it).
A workaround is to lock the ptr or duplicate it before calling asbuffer. AT the very least it would be extremely helpful if methods that are not threadsafe are in fact documented as being that way and a list of methods that aren't threadsafe in once place would be great.
I personally think the inclusion of the position pointer on the pointer.java object is a mistake and in fact the inclusion of any non-constant member variables that can change during the pointer's lifetime should be re-evaluated so that we can write code that does not crash intermittently in hard-to-debug and reproduce situations.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4