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

Potential uninitialized value read without initialization #349

Closed
henrybear327 opened this issue Feb 7, 2024 · 2 comments
Closed

Potential uninitialized value read without initialization #349

henrybear327 opened this issue Feb 7, 2024 · 2 comments
Assignees

Comments

@henrybear327
Copy link
Collaborator

Running infer on the codebase, we would get the following report

src/elf.c:194: error: Uninitialized Value
`node.right_red` is read without initialization during the call to `map_insert()`.
  192.     /* initialize the symbol table */
  193.     map_clear(e->symbols);
  194.     map_insert(e->symbols, &(int){0}, &(char *){NULL});
              ^
  195.
  196.     /* get the string table */

Found 1 issue
    Issue Type(ISSUED_TYPE_ID): # 
    Uninitialized Value(PULSE_UNINITIALIZED_VALUE): 1
@henrybear327 henrybear327 self-assigned this Feb 7, 2024
henrybear327 added a commit to henrybear327/rv32emu that referenced this issue Feb 26, 2024
The struct member right_red is used in several functions, such as 
rb_node_set_right(). It has been reported by infer and LLVM static 
analyzer that right_red isn't initialized before used.

By tracing the node initialization function calls (starting from 
map_create_node), it can be seen that rb_node_set_right is the function
where right_red is attempted to be initialized, but we are indeed 
performing &1 on an uninitialized value. 

In this commit, a change to using calloc guarantees the struct members 
will be zeroed out during allocation, which in terms serves as 
initialization.
@henrybear327
Copy link
Collaborator Author

Root cause is discussed in PR #362

jserv added a commit that referenced this issue Feb 26, 2024
Fix reading uninitialized variable (#349)
@jserv
Copy link
Contributor

jserv commented Feb 26, 2024

Close by commit af24e0c

@jserv jserv closed this as completed Feb 26, 2024
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

No branches or pull requests

2 participants