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

[Bug][C] Invalid DDG on single variable if-statements (Identifier) #5115

Open
mahaloz opened this issue Nov 19, 2024 · 0 comments
Open

[Bug][C] Invalid DDG on single variable if-statements (Identifier) #5115

mahaloz opened this issue Nov 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mahaloz
Copy link

mahaloz commented Nov 19, 2024

Describe the bug
Single variable special if-statements don't have the correct data dependency edges and location in the DDG.

I used the following code:

int main(int argc) {
    if (argc) {
        puts("hello world");
    }
    return 0;
}

Note the special syntax on if(argc), which is equal to if(argc!=0). In a normal DDG, the if argc line should be dependent on argc.

Instead, I get the following graph:
image

if (argc) is shown to have no predecessors aside from the start, which is not correct. If you change the above to be argc!=0, the DDG is correct.

I believe this bug is related to or is a regression of #2833.

To Reproduce
Put the code above into a C file, then import it.
Run the following line:

cpg.method("main").dotDdg.l

You should get the same dot graph shown above.

Expected behavior
The correct graph looks like the following:
image

It shows that if(argc) depends on argc.

Desktop (please complete the following information):

  • MacOS
  • Joern v4.0.150
@mahaloz mahaloz added the bug Something isn't working label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant