Skip to content
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

File dialog opening can cause a crash, at least on Windows #72

Open
apocalyptech opened this issue Feb 16, 2024 · 1 comment
Open

File dialog opening can cause a crash, at least on Windows #72

apocalyptech opened this issue Feb 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@apocalyptech
Copy link
Contributor

apocalyptech commented Feb 16, 2024

System Info
Operating System:
Windows (unsure of exact version)

Describe the bug
Opening a file dialog, under some circumstances (such as File -> Open) can lead to a crash with a relatively-unhelpful traceback like so:

2024-02-16 15:37:03 blcmm.Startup$MyExceptionHandler.logError(Startup.java:388) -> class java.lang.InternalError: Could not bind shell folder to interface
    org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions$NewObjectWithObjectArrayArgFunctionPointer.invoke(JNIFunctions.java)
    org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.ThrowNew(JNIFunctions.java:889)
    [email protected]/sun.awt.shell.Win32ShellFolder2.initSpecial(Native Method)
    [email protected]/sun.awt.shell.Win32ShellFolder2$1.call(Win32ShellFolder2.java:297)
    [email protected]/sun.awt.shell.Win32ShellFolder2$1.call(Win32ShellFolder2.java:292)
    [email protected]/sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:630)
    [email protected]/sun.awt.shell.ShellFolder.invoke(ShellFolder.java:540)
    [email protected]/sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:292)
    [email protected]/sun.awt.shell.Win32ShellFolderManager2.getNetwork(Win32ShellFolderManager2.java:222)
    [email protected]/sun.awt.shell.Win32ShellFolder2.getFileSystemPath(Win32ShellFolder2.java:631)
    [email protected]/sun.awt.shell.Win32ShellFolder2$10.call(Win32ShellFolder2.java:839)
    [email protected]/sun.awt.shell.Win32ShellFolder2$10.call(Win32ShellFolder2.java:830)
    [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    [email protected]/sun.awt.shell.Win32ShellFolderManager2$ComInvoker$1.run(Win32ShellFolderManager2.java:599)
    [email protected]/java.lang.Thread.run(Thread.java:833)
    org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:838)
    org.graalvm.nativeimage.builder/com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:210)

It seems likely to somehow have something to do with network accessibility. Also in the user's logfile above was this line:

2024-02-16 15:37:01 blcmm.gui.MainGUI$7.doInBackground(MainGUI.java:543) -> class java.net.SocketException: Permission denied: connect

Some random searching around has yielded a couple of hits for this, both seemingly relating to network permissions, though both are pretty old. Here's a JDK bug from way back in the early 2000s talking about a Windows NT machine: https://bugs.openjdk.org/browse/JDK-4879395 -- And here's a StackOverflow post: https://stackoverflow.com/questions/17644390/what-causes-an-internalerror-to-be-thrown-by-sun-awt-shell-win32shellfolder2-ini (note the "Edit 2" specifically, which calls out a Win32ShellFolder2.NETWORK argument).

Also from the reporting user (in Discord):

BCMM worked beforehand, then I ran a few network tweaks to get Windows File Sharing working over LAN, and that's around the time that BCMM would throw this error.

So it does seem awfully likely that JFileChooser must have some problems when certain network attempts are made, which can result in a crash. It's rather vexing because I do intend OpenBLCMM to be fully functional without any network. The only intended network call is to check for a new version, which should fail gracefully (and can be toggled off by the user).

This happened for the user both on the EXE version (still Liberica NIK's Java 17), and on Pure Java on (I believe) Java 8.

So anyway, I'll have to see if I can reproduce this in a VM and then see what can be done about it. If I can't fix JFileChooser (which, honestly, seems like a pretty likely case), perhaps I could at least fall back to a more basic file-chooser dialog instead? The SO post mentions trying FileDialog instead... We'll have to see.

@apocalyptech apocalyptech added the bug Something isn't working label Feb 16, 2024
@apocalyptech
Copy link
Contributor Author

From the reporting user, btw, here's what was done on the PC which seems to have resulted in this file-dialog behavior:

File-Sharing.ps1

# Start Required Services
Start-Service -DisplayName "SSDP Discovery"
Start-Service -DisplayName "UPnP Device Host"
Start-Service -DisplayName "Function Discovery Provider Host"
Start-Service -DisplayName "Function Discovery Resource Publication"

# Control Panel\All Control Panel Items\Network and Sharing Centre > Advanced Sharing Settings > Private and Public > Network Discovery [Enabled]
Set-NetFirewallRule -DisplayGroup "Network Discovery" -Profile "Any" -Enabled "True"

# Control Panel\All Control Panel Items\Network and Sharing Centre > Advanced Sharing Settings > Private and Public > Network Discovery > Automatic Setup of Network Connected Devices [Enabled]
New-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Name "AutoSetup" -PropertyType "DWORD" -Value "1" -Force | Out-Null

# Control Panel\All Control Panel Items\Network and Sharing Centre > Advanced Sharing Settings > Private and Public > File and Printer Sharing [Enabled]
Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Enabled "True" -Profile "Any"

# Control Panel\All Control Panel Items\Network and Sharing Centre > Advanced Sharing Settings > All Networks > Public Folder Sharing [Enable]
how to do this?

# Control Panel\All Control Panel Items\Network and Sharing Centre > WiFi Status > Properties > Client for Microsoft Networks
Get-NetAdapterBinding -Name "WiFi" | Set-NetAdapterBinding -ComponentID "ms_server" -Enabled $True

# Folder > Right Click [Properties] > Sharing Tab [Enable]
New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Drive\shellex\PropertySheetHandlers\Sharing" -Name "(Default)" -Value "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}"
New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Directory\shellex\PropertySheetHandlers\Sharing" -Name "(Default)" -Value "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}"
Remove-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}"

# Folder > Right Click [Properties] > Sharing Tab > Network File and Folder Sharing > Share Button [Enable]
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SharingWizardOn" -Value 1

windows features > enable > smb stuff



$wifiInterfaceIndex = Get-NetConnectionProfile | Where-Object { $_.InterfaceAlias -eq "WiFi" } | Select-Object -ExpandProperty "InterfaceIndex"

Hide Account Profile from Login Screen.ps1

$regPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
$specialAccountsKey = "SpecialAccounts"
$userListKey = "UserList"
$userName = "USERNAME_SELECT"

New-Item -Path "$regPath" -Name "$specialAccountsKey" -Force
New-Item -Path "$regPath\$specialAccountsKey" -Name "$userListKey" -Force
New-ItemProperty -Path "$regPath\$specialAccountsKey\$userListKey" -Name "$userName" -Value 0 -PropertyType DWORD -Force

# Enable network in file explorer left pane
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder" -Name "Attributes" -Value "b0040064"

# Disable network file pane
Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder" -Name "Attributes" -Value "b0940064"

net share start.bat

@echo off
REM List of services required for Windows 10 file sharing
set services=FDResPub SSDPSRV upnphost LanmanServer Browser

REM Start each service
for %%s in (%services%) do (
    sc start %%s
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant