-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Threading (?) causing glibc/low level crashes #155
Comments
for now, I have created a private fork of this repo and removed all Thread based functionality (scan thread, reader thread); now the same infinite loop never crashes the program |
FWIW, with hid4java:0.8.0 I also did get a fatal error/crash on Windows 10 at least once now, hs err attached
|
with the threadless version I cannot reproduce this anymore; there must be some thread safety concerns that are violated by the current implementation I would be fairly cautious interacting with libhidapi.so and even with JNA in anything but a single-threaded or at least serialized fashion... |
Here's a reference for hidapi not being thread-safe:
|
Platform
Knowing the platform greatly narrows down the potential causes of the problem.
linux-arm32/64
, Raspberry Pi 3/4, amd64arm32,
bookworm` arm64=aarch64, Ubuntu 24.04hid4java
version0.8.0
To Reproduce
Steps to reproduce the behavior:
Write a trivial program
let it run for a while on the specified platforms.
Expected behavior
Runs without issues forever.
Screenshots and logs
I observed three crash modes so far (note I have a littlescript running the app and logging some stuff, but the basic program is as above):
all of them often appear within a few minutes of running that loop, however, sometimes they don't appear for a long time or only after I plugged in some devices and read/wrote some data to them...
or, on Ubuntu 24.04
Additional information
I have not observed any of these failure modes on amd64 Windows 10, the loop seems to run forever there as it should.
However, on Linux it's definitely broken on every platform I tested.
It seems a lot of such issues can be caused by talking to native code from multiple java threads:
https://stackoverflow.com/questions/22491797/java-double-free-or-corruption
https://stackoverflow.com/questions/49628615/understanding-corrupted-size-vs-prev-size-glibc-error
I don't quite understand why hid4java needs any threads in the first place
at least for my usecase, all I would need are synchronous enumeration, synchronous read & write (with timeout), all of which are synchronous calls in hidapi
fwiw I have attached the hs_err log files
hs_err_pid2754.log
hs_err_pid12909.log
The text was updated successfully, but these errors were encountered: