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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix module loading order #696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

direc85
Copy link

@direc85 direc85 commented Jul 15, 2023

I'm running Manjaro Linux (Plasma). Hardinfo didn't load the benchmarks for me, so I did a little digging, and found a ticket for it already. Since the issue didn't look too difficult, I decided to give it a shot, so here goes!

Loading benchmark.so before devices.so fails, so make sure we load devices.so first:

  • Open the modules dir
  • Create empty filenames list
  • Read the directory contents (in arbitrary order) to filenames list
    • Prepend devices.so so it's always first
    • Append any other module to the list
  • Load the modules from the filenames list in order

The terminal output was similar to the linked issue below. With this PR, I'm able to see and run benchmarks using the GUI, with terminal output now looking like this:

*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:744 (module_load) *** gmodule resource for ``/usr/lib/hardinfo/modules/devices.so'' is 0x604000015310 ((null))
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:762 (module_load) *** initializing module ``devices.so''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Update PCI ID listing''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Update USB ID listing''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Update EDID vendor codes''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Update IEEE OUI vendor codes''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Update SD card manufacturer information''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Update CPU flags database''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:808 (module_load) *** registering methods for module ``devices.so''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:744 (module_load) *** gmodule resource for ``/usr/lib/hardinfo/modules/benchmark.so'' is 0x60400001e610 ((null))
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:762 (module_load) *** initializing module ``benchmark.so''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Send benchmark results''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/shell/syncmanager.c:105 (sync_manager_add_entry) *** registering syncmanager entry ''Receive benchmark results''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:808 (module_load) *** registering methods for module ``benchmark.so''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:744 (module_load) *** gmodule resource for ``/usr/lib/hardinfo/modules/computer.so'' is 0x60400001e890 ((null))
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:762 (module_load) *** initializing module ``computer.so''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:808 (module_load) *** registering methods for module ``computer.so''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:744 (module_load) *** gmodule resource for ``/usr/lib/hardinfo/modules/network.so'' is 0x60400001ed10 ((null))
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:762 (module_load) *** initializing module ``network.so''
*** /home/matti/.cache/yay/hardinfo-git/src/hardinfo/hardinfo/util.c:808 (module_load) *** registering methods for module ``network.so''

The downside of this approach is that it's only possible to have one module loaded before all the rest, and the rest will still be in arbitrary order. Module priority list (or dependency lists) would solve this but this works fine, as long as none of the other modules depend on a module other than devices.so.

Fixes #676

PS. This is my first contact with GLib, but at least the compiler is happy 馃槃

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

Successfully merging this pull request may close these issues.

Bug: Problematic Module Load Ordering
1 participant