bailuk / java-gtk

GTK bindings for Java
MIT License
108 stars 8 forks source link

Invalid Memory Access on windows #35

Closed me6262 closed 9 months ago

me6262 commented 9 months ago

whenever i use various Adw related classes in my main method, such as running App.run() just like the example, when running on windows, the program immediately crashes, citing an "Invalid memory access" error. the same thing happens when i use Adw.init().

i am on 0.5.0

the libraries were downloaded from msys2 and added to PATH

bailuk commented 9 months ago

I've tested both Adwaita samples on Windows 10 with 0.5.0 and both worked.

Therefore I need more information to be able to reproduce this

me6262 commented 9 months ago

when i get home today i will try and run the demo apps as well as my program on 0.4.0

also, my repo is me6262/JavaAutoBuilder

bailuk commented 9 months ago

Your code has some issues. I've made some changes and added some comments (These are only suggestions and are not tested): https://github.com/me6262/JavaAutoBuilder/compare/master...bailuk:JavaAutoBuilder:master

me6262 commented 9 months ago

ohhhhh, conflicting imports could definitely do it. i suppose when doing c interop, a lot of things can create nonsense memory related errors. i am in the process of testing the changes on linux, i will test on windows later today since I don't have it on my laptop.

thanks a lot for all the help too. this is really going beyond the call of duty

me6262 commented 9 months ago

also, in the code, you say that the style manager could cause crashes. in what situations? stuff like missing resources?

me6262 commented 9 months ago

just tested your forked code, the error doesn't change. it crashes with "Invalid memory access" on line 141, which is where app.run(argc, argv) is called. from my preliminary research on the topic of this kind of error with jna is when something (usually on windows) uses a different sized object than *nix systems, like with certain types of strings and stuff. however, this is the limit of my knowledge

me6262 commented 9 months ago

also, all iterations of this code has worked perfectly on linux

bailuk commented 9 months ago

It crashes on my Linux system when calling StyleManager.getDefault().colorScheme = ColorScheme.FORCE_DARK in onActivate. I don't know why. Maybe it is related to #22 or maybe it triggers another issue when all widgets are getting updated. Your code runs great on Windows against both 0.4.0 and 0.5.0 tough.

The issue is most likely an API violation somewhere in your code.

Some ideas for debugging:

me6262 commented 9 months ago

if the code works perfectly for you on windows, what gtk related libraries do you have installed? it seems like the deciding factor could be system configuration.

i will test all of the debugging stuff later, but at this point, i am just left to theory craft until i can actually try it later.

from my research it looks like a package that seems fairly necessary that i may have overlooked is gsettings-desktop-schemas

me6262 commented 9 months ago

a handful of months ago, i went through the lengthy process of copying all of the necessary dlls and all other necessary resources from msys2 into some random zip file so that it could be used by me to test out packaging. if i put the updated code in that, everything works flawlessly. i suppose some gtk/libadwaita related files that come from some packages are missing in my system installation(this is a new install of msys2), although i haven't pinned down exactly what is missing, but for context, the only thing i installed was libadwaita, gtk4, libadwaita icon theme, and whatever was considered a required dependency. i suppose that i should close this issue as it is not an issue with the library seeing as i have gotten it to work