Compiling sheepy with fil-c
fil-c is a memory safe implementation of the C programming language.
I'm wondering if I can:
- compile libsheepy with
fil-c - compile sheepy with
fil-c - compile sheepy programs with
fil-c
I used fil-c version 0.673:
filc-0.673
About Sheepy: Sheepy (gemini)
In the build scripts and sheepy, I replaced gcc with PATH.../filc-0.673-linux-x86_64/build/bin/filcc.
Libsheepy
After removing everything related to printf.h och execinfo.h, it compiles with these commands:
./clean.sh
./build.sh
Sheepy
First I compiled sheepy with this command:
./compileSheepy.sh ../../libsheepy/release ../../libsheepy/release
There was a clang issue concerning the finish label, I changed the code to remove the error:
sheepy.c:1730:5: error: cannot jump from this goto statement to its label
1730 | goto finish;
Compiling a sheepy program
Spm is a sheepy program:
export LIBSHEEPY=PATH../libsheepy/release
./sheepy -c spm.c
[-] sheepy 25-10-29 16:09:30: Probably trying to free a smallString on stack: lx sp: lx
fil-c does some tricks with pointers, so I recompiled libsheepy to disable the check when freeing objects on the stack:
modified: libsheepy/src/libsheepyObject.h
#define NFreeStackCheck 0
spm compiled correctly but it doesn't completly work, some functions don't work for example ./spm top...
I created a test program with a memory leak:
#! /usr/bin/env sheepy
/* or direct path to sheepy: #! /usr/local/bin/sheepy */
/* Libsheepy documentation: https://spartatek.se/libsheepy/ */
#include "libsheepyObject.h"
int argc; char **argv;
/* enable/disable logging */
/* #undef pLog */
/* #define pLog(...) */
int main(int ARGC, char** ARGV) {
argc = ARGC; argv = ARGV;
initLibsheepy(ARGV[0]);
setLogMode(LOG_VERBOSE);
//pError0(openProgLogFile());
//setLogSymbols(LOG_UTF8);
//disableLibsheepyErrorLogs;
//logI("C template");
char *c = malloc(1024);
}
// vim: set expandtab ts=2 sw=2:
Running valgrind on this test program shows no memory leak:
./sheepy -c test.c
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./test
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./test
==3972527== Memcheck, a memory error detector
==3972527== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==3972527== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==3972527== Command: ./test
==3972527==
==3972527==
==3972527== HEAP SUMMARY:
==3972527== in use at exit: 0 bytes in 0 blocks
==3972527== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==3972527==
==3972527== All heap blocks were freed -- no leaks are possible
==3972527==
==3972527== For lists of detected and suppressed errors, rerun with: -s
==3972527== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Then I tested reading a json and printing it:
createAllocateSmallJson(q);
readFileG(q, "file.json");
logVarG(q);
It works fine.