From: Edgar Khachatryan <khachatryan.edgar@student.rau.am>
To: linux-sparse@vger.kernel.org
Subject: Issue with Setting Up Sparse
Date: Wed, 12 Mar 2025 18:04:02 +0400 [thread overview]
Message-ID: <CAN1=rvLAcxNqWzRR3EjtNgqk2A3T92iREEYTJdRog3OekK4=NA@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1670 bytes --]
My name is Edgar Khachatryan, and I am a student currently working on a
project that involves static analysis using Sparse. I have encountered an
issue where running Sparse with the command "sparse file.c" does not detect
simple memory issues such as memory leaks, double frees, or use-after-free
errors in a single file.
I have attempted to install Sparse versions 0.6.3 and 0.6.4 on different
Ubuntu releases (20.04, 22.04, and 24.04) with LLVM versions 11 and 12.
However, none of these combinations have worked as expected.
Following the installation instructions provided in the documentation, I
ran "make" and "make install" in the Sparse directory, but I was unable to
find further details regarding dependencies or required versions for proper
setup and functioning. As a result, I am reaching out to ask for
clarification on the following:
1) Are there specific dependencies or versions of libraries (e.g., libxml,
sqlite3, gtk3, etc.) that need to be installed to ensure Sparse functions
correctly?
2) Is there any additional documentation available beyond what was
provided? It would be very helpful to have more detailed instructions or
guidelines for setting up Sparse in different environments.
I also have the command-line output text that details the issues I’ve
encountered and The C source file I used as input. I would be happy to
share it with you if it would help resolve the problem.
Thank you in advance for your time and assistance. I look forward to your
response and any guidance you can provide to help resolve this issue.
Best regards,
Edgar Khachatryan,
Russian-Armenian University, Yerevan, Armenia
[-- Attachment #1.2: Type: text/html, Size: 1770 bytes --]
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 845 bytes --]
#include <stdio.h>
#include <stdlib.h>
void memory_leak() {
int *ptr = (int *)malloc(sizeof(int) * 10); // Memory allocated but never freed
if (!ptr) {
printf("Memory allocation failed\n");
return;
}
ptr[0] = 42; // Some usage
}
void double_free() {
int *ptr = (int *)malloc(sizeof(int) * 10);
if (!ptr) {
printf("Memory allocation failed\n");
return;
}
free(ptr); // First free
free(ptr); // Double free (undefined behavior)
}
void use_after_free() {
int *ptr = (int *)malloc(sizeof(int) * 10);
if (!ptr) {
printf("Memory allocation failed\n");
return;
}
free(ptr); // Freeing memory
ptr[0] = 42; // Use after free (undefined behavior)
}
int main() {
memory_leak();
double_free();
use_after_free();
return 0;
}
[-- Attachment #3: cmd_out --]
[-- Type: application/octet-stream, Size: 4304 bytes --]
next reply other threads:[~2025-03-12 14:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 14:04 Edgar Khachatryan [this message]
2025-03-12 15:11 ` Issue with Setting Up Sparse Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN1=rvLAcxNqWzRR3EjtNgqk2A3T92iREEYTJdRog3OekK4=NA@mail.gmail.com' \
--to=khachatryan.edgar@student.rau.am \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).