NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
49.06k stars 5.65k forks source link

Flawed Application.isInitialized #6663

Closed astrelsky closed 3 days ago

astrelsky commented 5 days ago

Describe the bug Application.isInitialized returns true before Application initialization is complete. Furthermore, correcting this breaks everything, even the build because Application.checkAppInitialized is used to ensure the Application is "initialized" during initialization.

To Reproduce Steps to reproduce the behavior:

  1. Change https://github.com/NationalSecurityAgency/ghidra/blob/5ab72bf4f254773b12c3c9566d14c42e5eb2495f/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Application.java#L109-L112 to the following to correct it
    Application app = new Application(layout, configuration);
    app.initialize();
    configuration.initializeApplication();
    Application.app = app;
    firstCreationThrowable = new AssertException("First call to initialize Application...");
  2. Watch all hell break loose.

Expected behavior The documented behavior is is the expected behavior https://github.com/NationalSecurityAgency/ghidra/blob/5ab72bf4f254773b12c3c9566d14c42e5eb2495f/Ghidra/Framework/Generic/src/main/java/ghidra/framework/Application.java#L120-L127

Additional context I can just hack around it and use Reflection to check Application.firstCreationThrowable for now.

ryanmkurtz commented 3 days ago

Making the changes to this got internally rejected. The official guidance is to not use multithreading on this class.

astrelsky commented 3 days ago

Making the changes to this got internally rejected. The official guidance is to not use multithreading on this class.

No problem. I didn't think it was worth fixing, it just didn't behave as documented.