Open Alexander-Hoppe opened 10 months ago
How can I debug this?
You can run the test suite with logging enabled: python tools\test.py --log
. See the ReadMe's in the tools
and tests
folders for more details.
Thanks for this and for this great software in general. Due to time constraints, I ended up running it on a different client (where it works). I am sorry to not have been able to get to the root of this. But I am sure that your debugging instructions will help someone else in the future.
2023-11 Kumulatives Update für .NET Framework 3.5, 4.8 und 4.8.1 für Windows 10 Version 22H2 für x64 ((KB5032339)) [Details](http://support.microsoft.com/kb/5032339)
We noticed that on one machine, MPh-py stopped working after the above update. This may be unrelated.
(mph) PS C:\Users\ga38haq\Downloads\MPh-main\MPh-main> python tools/test.py --log
Running test group "meta".
Passed in 0 s.
Running test group "config".
[00:00.332] Loading configuration from "C:\Users\ga38haq\Downloads\MPh-main\MPh-main\tests\MPh.ini".
Passed in 0 s.
Running test group "discovery".
[00:00.216] Searching system for available Comsol back-ends.
[00:00.216] Searching Windows Registry for Comsol executables.
[00:00.216] Checking registry node "SOFTWARE\Comsol\COMSOL60".
[00:00.216] Checking installation folder "C:\Program Files\COMSOL\COMSOL60\Multiphysics".
[00:00.216] Found Comsol executable "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.exe".
[00:00.216] Looking for Comsol executable on system search path.
[00:00.216] Running shell command "where comsol".
[00:00.417] Command exited with an error.
[00:00.417] Checking executable "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.exe".
[00:00.417] Found Java bridge configuration "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.ini".
[00:00.417] System architecture is "win64".
[00:00.417] Java VM at relative path "..\..\java\win64\jre\bin\server\jvm.dll".
[00:00.417] Root folder is "C:\Program Files\COMSOL\COMSOL60\Multiphysics".
[00:01.018] Reported version information is "COMSOL Multiphysics 6.0.0.405".
[00:01.018] Assigned name "6.0" to this installation.
Passed in 1 s.
Running test group "server".
[00:00.316] Searching system for available Comsol back-ends.
[00:00.316] Searching Windows Registry for Comsol executables.
[00:00.316] Checking registry node "SOFTWARE\Comsol\COMSOL60".
[00:00.316] Checking installation folder "C:\Program Files\COMSOL\COMSOL60\Multiphysics".
[00:00.316] Found Comsol executable "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.exe".
[00:00.316] Looking for Comsol executable on system search path.
[00:00.316] Running shell command "where comsol".
[00:00.517] Command exited with an error.
[00:00.517] Checking executable "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.exe".
[00:00.517] Found Java bridge configuration "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.ini".
[00:00.517] System architecture is "win64".
[00:00.517] Java VM at relative path "..\..\java\win64\jre\bin\server\jvm.dll".
[00:00.517] Root folder is "C:\Program Files\COMSOL\COMSOL60\Multiphysics".
[00:00.849] Reported version information is "COMSOL Multiphysics 6.0.0.405".
[00:00.849] Assigned name "6.0" to this installation.
[00:00.849] Starting external server process.
[00:01.150] Starting server failed: COMSOL Multiphysics 6.0.0.405
[00:01.150] Starting external server process.
[00:01.150] Server restricted to 1 processor core.
[00:09.450] Server listening on port 2035.
[00:09.450] Telling the server on port 2035 to shut down.
[00:20.810] Server on port 2035 has stopped.
Passed in 21 s.
Running test group "session".
[00:00.317] Starting local Comsol session.
[00:00.317] Searching system for available Comsol back-ends.
[00:00.317] Searching Windows Registry for Comsol executables.
[00:00.317] Checking registry node "SOFTWARE\Comsol\COMSOL60".
[00:00.317] Checking installation folder "C:\Program Files\COMSOL\COMSOL60\Multiphysics".
[00:00.317] Found Comsol executable "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.exe".
[00:00.332] Looking for Comsol executable on system search path.
[00:00.332] Running shell command "where comsol".
[00:00.517] Command exited with an error.
[00:00.517] Checking executable "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.exe".
[00:00.517] Found Java bridge configuration "C:\Program Files\COMSOL\COMSOL60\Multiphysics\bin\win64\comsol.ini".
[00:00.517] System architecture is "win64".
[00:00.517] Java VM at relative path "..\..\java\win64\jre\bin\server\jvm.dll".
[00:00.517] Root folder is "C:\Program Files\COMSOL\COMSOL60\Multiphysics".
[00:00.856] Reported version information is "COMSOL Multiphysics 6.0.0.405".
[00:00.856] Assigned name "6.0" to this installation.
[00:00.856] Starting external server process.
[00:00.856] Server restricted to 1 processor core.
[00:08.380] Server listening on port 65390.
[00:08.380] JPype version is 1.4.1.
[00:08.380] Starting Java virtual machine.
[00:08.380] JVM arguments: ['C:\\Program Files\\COMSOL\\COMSOL60\\Multiphysics\\java\\win64\\jre\\bin\\server\\jvm.dll']
Failed after 10 s.
So maybe the JVM is not starting up as intended?
Seems like it. And apparently it crashes out of the Python session completely.
You should be able to reproduce the crash in an interactive Python prompt. I just get the Python prompt back when I do this:
❯ python
Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jpype
>>> jpype.startJVM('C:\\Program Files\\COMSOL\\COMSOL60\\Multiphysics\\java\\win64\\jre\\bin\\server\\jvm.dll')
>>>
But the crash is due to JPype or Java, not MPh, so there's nothing I can do about it. Don't think the Windows update is a problem per se. If anything, this is a conflict with DLLs on your system that Java is trying to load, and fails. Along the lines of #49, though not exactly that as it's been fixed.
This here looks like "can't fix".
Running these commands in the interactive prompt shows me the same behavior as for you. I am still in the interactive prompt after execution of jpype.startJVM
and it does not crash in this case.
(mph) PS C:\Users\ga38haq> python
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jpype
>>> jpype.startJVM('C:\\Program Files\\COMSOL\\COMSOL60\\Multiphysics\\java\\win64\\jre\\bin\\server\\jvm.dll')
>>>
Out of curiosity, when I then try to start mph, the following happens:
>>> import mph
>>> mph.start()
Only one client can be instantiated at a time.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ga38haq\AppData\Local\miniconda3\envs\mph\Lib\site-packages\mph\session.py", line 101, in start
client = Client(cores=cores, version=version)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ga38haq\AppData\Local\miniconda3\envs\mph\Lib\site-packages\mph\client.py", line 151, in __init__
raise NotImplementedError(error)
NotImplementedError: Only one client can be instantiated at a time.
>>>
That makes sense if you were still in the same Python session. Were you?
JPype seemed to crash in your test because you'd otherwise expect the log to continue like so:
...
[00:00.856] Assigned name "6.0" to this installation.
[00:00.856] Starting external server process.
[00:00.856] Server restricted to 1 processor core.
[00:08.380] Server listening on port 65390.
[00:08.380] JPype version is 1.4.1.
[00:08.380] Starting Java virtual machine.
[00:08.380] JVM arguments: ['C:\\Program Files\\COMSOL\\COMSOL60\\Multiphysics\\java\\win64\\jre\\bin\\server\\jvm.dll']
[00:xx.xxx] Java virtual machine has started.
[00:xx.xxx] Connecting to server "localhost" at port 65390.
[00:xx.xxx] Disconnecting from server.
[00:xx.xxx] Exiting the Java virtual machine.
Passed in xx s.
I don't see why it doesn't crash when you do that manually. Maybe try also loading the Comsol Java classes. Something like:
import jpype
jpype.startJVM(
'C:/Program Files/COMSOL/COMSOL60/Multiphysics/java/win64/jre/bin/server/jvm.dll',
classpath='C:/Program Files/COMSOL/COMSOL60/Multiphysics/apiplugins/*'
)
print('Success.')
I say "something like" because I have Comsol installed in a different location, so edited in the path you have it at.
The above is the only code that MPh runs between the last log message you saw in your test run and the next log message which it never got to: https://github.com/MPh-py/MPh/blob/e24c9cccd45af9f26081ae7f1204df0830814157/mph/client.py#L181-L186
That makes sense if you were still in the same Python session. Were you?
Yes, it was the same Python session.
Maybe try also loading the Comsol Java classes. Something like:
import jpype jpype.startJVM( 'C:/Program Files/COMSOL/COMSOL60/Multiphysics/java/win64/jre/bin/server/jvm.dll', classpath='C:/Program Files/COMSOL/COMSOL60/Multiphysics/apiplugins/*' )
Running
(mph) PS C:\Users\ga38haq> python
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jpype
>>> jpype.startJVM(
... 'C:/Program Files/COMSOL/COMSOL60/Multiphysics/java/win64/jre/bin/server/jvm.dll',
... classpath='C:/Program Files/COMSOL/COMSOL60/Multiphysics/apiplugins/*'
... )
(mph) PS C:\Users\ga38haq>
exits without error and throws me back into my shell. The classpath
argument seems to have made the difference. My apiplugins
folder contains some com.comsol.*.jar
and org.eclipse.*
files.
Well, I see no reason why this happens and have no idea how to fix that. It's almost certainly a bug in JPype, rather than Java, but would be difficult to debug, even if reproducible, and if there was someone with the technical expertise (which I don't have) and access to Comsol.
For what it's worth, I see "2023-11 Cumulative Update for Windows 11 Version 22H2 for x64-based Systems (KB5032190)" in my update history. It's not the exact same update, since it's for Windows 11, but fixes the same issues. I don't have access to a Windows 10 system with Comsol installed.
I don't know why a Windows update would make Java crash when classes are loaded. Comsol's Java classes do have external dependencies, i.e. dynamically linked system libraries, but problems there usually lead to a java.lang.UnsatisfiedLinkError
exception, not a crash of the Java virtual machine.
I'll leave this issue open, since it's unresolved, and so people can comment here if they have something relevant to add.
I encountered a crash in dynamic loader over a missing dependency (in that case ggogle protobuf missing). I am not sure why a missing dependency is causing a crash where it was causing a proper exception previously. My assumption is there has been a change of behavious in the JVM which is now yielding an exception at an unexpected point leading to the failure. Fixing the dependency problem solved the issue, but I have not had time to find the crash source.
Setup
Windows 10 10.0.19045 Build 19045
conda create -n mphtest
conda activate mphtest
pip install MPh
Running without installed COMSOL
(mphtest) D:\\mydir\\> python
>>> import mph
>>> mph.start()
Results in
RuntimeError: Could not locate any Comsol installation
Running with fresh Comsol 6.0 installation
Fresh install of COMSOL 6.0
(mphtest) D:\\mydir\\> python
>>> import mph
>>> mph.start()
Windows hourglass symbol next to pointer shows up after 1 to 2 seconds, then python has exited without error and I am back in the shell
(mphtest) D:\\mydir\\>
Question
COMSOL GUI runs fine.
How can I debug this?