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

Invalid Memory Access on windows #35

Closed
me6262 opened this issue Feb 6, 2024 · 10 comments
Closed

Invalid Memory Access on windows #35

me6262 opened this issue Feb 6, 2024 · 10 comments

Comments

@me6262
Copy link

me6262 commented Feb 6, 2024

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
Copy link
Owner

bailuk commented Feb 6, 2024

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
Copy link
Author

me6262 commented Feb 6, 2024

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
Copy link
Owner

bailuk commented Feb 6, 2024

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

@me6262
Copy link
Author

me6262 commented Feb 6, 2024

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
Copy link
Author

me6262 commented Feb 6, 2024

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

@me6262
Copy link
Author

me6262 commented Feb 6, 2024

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
Copy link
Author

me6262 commented Feb 6, 2024

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

@bailuk
Copy link
Owner

bailuk commented Feb 7, 2024

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:

  • When app.run(argc, argv) crashes this means it crashes within the applications eventloop. This could be any callback for example. Like app.onActivate
  • If a crashdump file gets generated (ending with .log) it could contain some hints like what API call triggered this invalid memory access
  • With an IDE like VS Code or IntelliJ you can step trough your code with the debugger. Just add a break point in the first line of onActivate.
  • Only call GTK API from the main thread. But as far as I see your project is single threaded anyway.

@me6262
Copy link
Author

me6262 commented Feb 7, 2024

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
Copy link
Author

me6262 commented Feb 7, 2024

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

@me6262 me6262 closed this as completed Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants