Warnings from GCC `-fanalyzer`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
The warnings identify c/segment.c in contract_segment_table, c/vfasl.c in S_vfasl, and c/prim5.c in s_process. Read those functions and reproduce the GCC 13.2 -fanalyzer run on Chez Scheme as built by Racket; the report offers to provide more control flow if needed. Done means assessing and addressing the reported null dereference, uninitialized value, and file descriptor leak, with the analyzer no longer reporting actionable problems.
Written by the indexing model from the issue text.
Description
GCC has a relatively-new static analysis pass that can warn about various problems. I ran it (using GCC v13.2) on Chez Scheme as built by Racket. Below are the first few warnings it generated, at verbosity level 0. If it's helpful I can provide more of the control flow that the analysis thinks can lead to the problem. If these problems seem worth fixing then I'll include the rest.
../ChezScheme/c/segment.c: In function ‘contract_segment_table’:
../ChezScheme/c/segment.c:565:15: warning: dereference of NULL ‘t2i’ [CWE-476] [-Wanalyzer-null-dereference]
565 | if ((t2i->refcount -= 1) == 0) {
| ~~~^~~~~~~~~~
‘S_free_chunk’: event 1
|
| 452 | contract_segment_table(chunk->base, chunk->base + chunk->segs);
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) calling ‘contract_segment_table’ from ‘S_free_chunk’
|
+--> ‘contract_segment_table’: events 2-4
|
| 553 | t2i = S_segment_info[SEGMENT_T3_IDX(base)];
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (3) ‘t2i’ is NULL
|......
| 565 | if ((t2i->refcount -= 1) == 0) {
| | ~~~~~~~~~~~~~
| | |
| | (4) dereference of NULL ‘t2i’
| 566 | S_freemem((void *)t2i, sizeof(t2table), 0);
| 567 | S_segment_info[SEGMENT_T3_IDX(base)] = NULL;
| | ^
| | |
| | (2) ‘0’ is NULL
../ChezScheme/c/vfasl.c: In function ‘S_vfasl’:
../ChezScheme/c/vfasl.c:163:17: warning: use of uninitialized value ‘vspaces[s]’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
163 | if (!vspaces[s])
| ~~~~~~~^~~
‘S_vfasl_to’: event 1
|
| 465 | return S_vfasl(bv, NULL, 0, Sbytevector_length(bv));
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) calling ‘S_vfasl’ from ‘S_vfasl_to’
|
+--> ‘S_vfasl’: events 2-3
|
| 94 | ptr vspaces[vspaces_count];
| | ^~~~~~~
| | |
| | (2) region created on stack here
|......
| 163 | if (!vspaces[s])
| | ~~~~~~~~~~
| | |
| | (3) use of uninitialized value ‘vspaces[s]’ here
|
../ChezScheme/c/prim5.c: In function ‘s_process’:
../ChezScheme/c/prim5.c:899:22: warning: leak of file descriptor ‘dup(tofds[0])’ [CWE-775] [-Wanalyzer-fd-leak]
899 | CLOSE(0); if (dup(tofds[0]) != 0) _exit(1);
| ^
‘s_process’: events 1-4
|
| 879 | if (pipe(tofds)) S_error("process","cannot open pipes");
| | ^~~~~~~~~~~
| | |
| | (1) when ‘pipe’ succeeds
| 880 | if (pipe(fromfds)) {
| | ~~~~~~~~~~~~~
| | |
| | (2) when ‘pipe’ succeeds
|......
| 899 | CLOSE(0); if (dup(tofds[0]) != 0) _exit(1);
| | ~~~~~~~~~~~~~~
| | ||
| | |(3) opened here
| | (4) ‘dup(tofds[0])’ leaks here; was opened at (3)
|
- Dominant language
- Scheme
- Stars
- 7.4k
- Forks
- 1k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 19
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cisco/ChezScheme
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cisco/ChezScheme#1110 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
cisco/ChezScheme#1111 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
cisco/ChezScheme#1101 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
cisco/ChezScheme#1078 · 1 comment ·
Maintainers usually reply within 1 day
-
RFC: solution to clangd not finding "scheme.h"Possibly taken @reginaldalfret claimed this 20 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
cisco/ChezScheme#1073 · 1 comment ·
Maintainers usually reply within 1 day
All issues in cisco/ChezScheme
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
YahiaAngelo/vphone-linux#70 ·
Maintainers usually reply within 1 day
-
package-request
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ScoopInstaller/Versions#3143 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
SanderMertens/flecs#2443 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ehmpathy/rhachet-roles-ehmpathy#1443 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day