question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

C Parser fail to parse a simple function

See original GitHub issue

Describe the bug The C Parser crash without a clear error on why on a simple case.

To Reproduce Steps to reproduce the behavior:

  1. Create a C file
  2. Put the below content into it
unsigned long HandleToULong(void *h){}
  1. Parse it with the C Parser
  2. The C Parser generate an error

Expected behavior Should not produce any errors.

Environment (please complete the following information):

  • OS: Windows
  • Java Version: java 17.0.2 2022-01-18 LTS
  • Ghidra Version: ghidra_10.1.5_PUBLIC
  • Ghidra Origin: official GitHub distro

Additional context When using a void return type or removing the parameter the C Parser works again

Console output:

INFO  parse C:\Users\XXX\a.c (CParserPlugin)
WARN  db.NoTransactionException: Transaction has not been started (CParser) db.NoTransactionException: Transaction has not been started
        at db.DBHandle.checkTransaction(DBHandle.java:396)
        at db.Table.putRecord(Table.java:938)
        at ghidra.program.database.data.CategoryDBAdapterV0.createCategory(CategoryDBAdapterV0.java:87)
        at ghidra.program.database.data.DataTypeManagerDB.createCategoryDB(DataTypeManagerDB.java:738)
        at ghidra.program.database.data.CategoryDB.createCategory(CategoryDB.java:311)
        at ghidra.program.database.data.DataTypeManagerDB.createCategory(DataTypeManagerDB.java:1945)
        at ghidra.program.database.data.DataTypeManagerDB.createCategory(DataTypeManagerDB.java:1943)
        at ghidra.program.database.data.DataTypeDB.doSetCategoryPath(DataTypeDB.java:350)
        at ghidra.program.database.data.DataTypeDB.setCategoryPath(DataTypeDB.java:336)
        at ghidra.app.util.cparser.C.CParser.addDef(CParser.java:294)
        at ghidra.app.util.cparser.C.CParser.FunctionDefinition(CParser.java:892)
        at ghidra.app.util.cparser.C.CParser.ExternalDeclaration(CParser.java:762)
        at ghidra.app.util.cparser.C.CParser.TranslationUnit(CParser.java:750)
        at ghidra.app.util.cparser.C.CParser.parse(CParser.java:630)
        at ghidra.app.plugin.core.cparser.CParserPlugin.parse(CParserPlugin.java:384)
        at ghidra.app.plugin.core.cparser.CParserTask.run(CParserTask.java:70)
        at ghidra.util.task.Task.monitoredRun(Task.java:134)
        at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

C Parser:  Problem Parsing.
          in C:\Users\XXX\a.c near line 1
         Last Valid Datatype: HandleToULong
         Check around CParserPlugin.out around line: 3

INFO  Parse Errors: C Parser:  Problem Parsing.
          in C:\Users\XXX\a.c near line 1
         Last Valid Datatype: HandleToULong
         Check around CParserPlugin.out around line: 3
 (CParserTask$3)
ERROR Failed to dispose PackedDatabase - it may still be in use!
C:\Users\XXX\Desktop\directx2.gdt (PackedDatabase) java.lang.Exception
        at ghidra.framework.store.db.PackedDatabase.dispose(PackedDatabase.java:331)
        at ghidra.program.model.data.FileDataTypeManager.close(FileDataTypeManager.java:233)
        at ghidra.app.plugin.core.cparser.CParserTask.run(CParserTask.java:140)
        at ghidra.util.task.Task.monitoredRun(Task.java:134)
        at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Hinaracommented, Aug 2, 2022

And this is valid C by the way https://stackoverflow.com/a/9936090 It create undefined behaviour at runtime but still valid.

0reactions
ryanmkurtzcommented, Oct 14, 2022

Fixed by e42c1f1f3263e192d5d9042c14f1f25413931aa0

Read more comments on GitHub >

github_iconTop Results From Across the Web

unknown parse error when testing function - Stack Overflow
It looks like you are using a C compiler set to an old C standard. Prior to C99 you could not put executable...
Read more >
Functional Parsing in C++20 - YouTube
Is C ++20 a language that supports a functional style of programming?Can we write modern C++ code in a pure functional style that...
Read more >
c-parser.c - Apple Open Source
If NESTED is true, we are inside a function or parsing old-style parameter declarations; any functions encountered are nested functions and declaration ...
Read more >
Function Parser for C++ v4.2 : Documentation
This C++ library offers a class which can be used to parse and evaluate a mathematical function from a string (which might be...
Read more >
Function Parser for C++ v4.5.1 - Warp
If a delimiter character is specified with this function, then if it's encountered at the outermost parsing level by the Parse() function, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found