ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

Converting a namespace into a class causes a low-level decopiler error

Open madebr opened this issue 2 years ago • 3 comments

Describe the bug Turning a namespace into a class causes low-level errors.

  Low-level Error: Unable to resolve type: Radio

To Reproduce Steps to reproduce the behavior:

  1. Analyze this file: LEGO1.DLL
  2. Go to 0x1002c8e0
  3. Create a funtion (press f in listing)
  4. change calling convention to __thiscall
  5. Rename to Radio::GetClassName
  6. Click in Symbol Tree on Namespaces -> R -> Radio
  7. Right click and choose 'Convert to Class'

Expected behavior A class Radio is created, and the this parameter of the just-tagged function becomes Radio *.

Screenshots No screenshot for you, but the text in the decompile window is:

 Low-level Error: Unable to resolve type: Radio

Attachments If applicable, please attach any files that caused problems or log files generated by the software.

Environment (please complete the following information):

  • OS: Fedora 38
  • Java Version: OpenJDK 20.0.1
  • Ghidra Version: 10.3.1
  • Ghidra Origin: official GitHub distro

Additional context That's all folks

madebr avatar Jun 22 '23 11:06 madebr

Additionally, I see Bad structure definition errors in functions where these "re-namespaced" functions are used. I believe this is the origin: https://github.com/NationalSecurityAgency/ghidra/blob/5719632656e71757f507fe9ab89510e90e96a5ca/Ghidra/Features/Decompiler/src/decompile/cpp/grammar.y#L1047

madebr avatar Jun 22 '23 22:06 madebr

Have you created the structure Radio?

Wall-AF avatar Jun 23 '23 07:06 Wall-AF

@Wall-AF I haven't.

When I make sure a struct named Radio exists when turning the Namespace into a Class, then everything is fine. But once the namespace is converted into a class, creating a struct does not fix the error anymore.

madebr avatar Jun 23 '23 10:06 madebr

This is related to #5403

ghidra1 avatar Jun 27 '23 19:06 ghidra1