deephaven-core icon indicating copy to clipboard operation
deephaven-core copied to clipboard

OS X snprintf() output has been truncated, py embedded server

Open devinrsmith opened this issue 2 years ago • 7 comments

@malhotrashivam was getting an error trying to run the python embedded server:

$ python -i thescript.py
...
Assertion failed: (count <= len && "snprintf() output has been truncated"), function LOAD_ERROR, file dispatch.c, line 74.

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

thescript.py:

from deephaven_server import Server

s = Server(jvm_args=["-DAuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler"])
s.start()

After a lot of debugging, found out the error is happening somewhere in or around io.deephaven.process.SystemInfoOshi#forCurrentProcess for OS X, oshi.hardware.platform.mac.MacComputerSystem. We tried to step through breakpoints to pin it down, but the specifics eluded us. I suspect there is some deep static initialization or memoization logic that is breaking down.

To workaround for now if you run into this, you can set the system property: process.info.system-info.enabled=false

devinrsmith avatar Jul 18 '23 20:07 devinrsmith

This was happening on an M2 mac with

$ sw_vers
ProductName:		macOS
ProductVersion:		13.4.1
ProductVersionExtra:	(c)
BuildVersion:		22F770820d
$ java -version
openjdk version "11.0.19" 2023-04-18 LTS
OpenJDK Runtime Environment Zulu11.64+19-CA (build 11.0.19+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.64+19-CA (build 11.0.19+7-LTS, mixed mode)
$ python --version
Python 3.8.17

malhotrashivam avatar Jul 18 '23 20:07 malhotrashivam

Hit this again today with @bmingles, the same workaround got us past it.

niloc132 avatar Jan 09 '24 16:01 niloc132

I spent most of the last week trying to figure this out. Specifically, I set out to answer the following question: "Is there any combination of JDK version / JDK ditstribution / Python version for which this problem does not arise?"

Unfortunately, I still do not have a clear answer.

I tried all combinations of Python 3.8 - 3.12, JDK 11, 17, 21, and zulu, oracle, temurin, and openJDK distribution. These were installed via pyenv and sdkman respectively, except for the openJDK distributions, which were installed via Homebrew. In all of these cases, I got the error described here.

I wrapped all of these tests up into a set of scripts that anyone can run (if you're reading this and are interested in this problem, please try them): https://github.com/alexpeters1208/test-dh-mac.

This seems like a pretty definitive "doesn't work at all", but not so.

@jmao-denver and I spent some time trying to get to the bottom of it, as this error does not crop up for him. I set my Python version and JDK version to be identical to his (3.9 and zulu 17, if I recall), and I still got the error, while he did not. There is a potentially important difference in how I installed my Python and JDK (pyenv and sdkman) vs how he installed his (Homebrew across the board), so I tried homebrew-installed Python 3.10 with homebrew-installed zulu JDK 17. Still, no dice. Our OS versions and XCode versions were different, so I upgraded my OS and Xcode. Nothing changed. I don't exactly recall all of his versions where things were working (@jmao-denver Maybe you could paste all the relevant versioning info here?)

In addition to Jianfeng, @chipkent @elijahpetty @nbauernfeind seem to be able to get the embedded server running on Apple silicon without this error, and without the workaround flag. I got detailed version info from Chip and Elijah, but did not learn much more from this info. There are not obvious version combinations they have that I have not tried.

Jianfeng's last suggestion was to try to upgrade JNA. He is on 5.13, I am on 5.9. However, at least Elijah, Chip, and Nate have JNA 5.9, so I am not sure that this could be a smoking gun. I still have not performed this upgrade test myself.

alexpeters1208 avatar Jun 03 '24 15:06 alexpeters1208

I have tried the tests in @alexpeters1208 's repo with some minor changes. Most of them passed with a few failures, some of which I tried again manually and all passed.

jmao-denver avatar Jun 03 '24 15:06 jmao-denver

I have tried the tests in @alexpeters1208 's repo with some minor changes. Most of them passed with a few failures, some of which I tried again manually and all passed.

This seems to be strong evidence suggesting that this problem is independent of. JDK distro / JDK version / Python version.

alexpeters1208 avatar Jun 03 '24 16:06 alexpeters1208

Just to add to the conversation here. This is the environment that does work without disabling process info for me.

Processor: Apple M2 Max macOS: Sonoma 14.5

Python 3.12.3 (v3.12.3:f6650f9ad7, Apr 9 2024, 08:18:47) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin

openjdk 21.0.2 2024-01-16 OpenJDK Runtime Environment Homebrew (build 21.0.2) OpenJDK 64-Bit Server VM Homebrew (build 21.0.2, mixed mode, sharing)

I'd like to note that the Temurin (jdk-11 at least, maybe all of them) does not work on linux. It fails trying to class-load io.deephaven.gui.color.Color.

nbauernfeind avatar Jun 04 '24 15:06 nbauernfeind

I got this error on an M1 when using pyenv targetting 3.12.0 + some other versions. I did not get the issue when using my homebrew install of 3.12.4

bmingles avatar Jul 23 '24 18:07 bmingles