List of commits:
Subject Hash Author Date (UTC)
Log leaks when program runs 5f4a8873f9d9b137445aeb2fa4058e9d0a324770 Catalin(ux) M. BOIE 2023-04-10 17:09:15
More core functions are traced; leak detector dc66bea6ff6c977d08bd4845634fd2c1bba1ed64 Catalin(ux) M. BOIE 2023-04-09 12:29:38
Added texlive-extsizes to requirements 0fdb6fb6e970f4d86a66d83343f489e2ee94537f Catalin(ux) M. BOIE 2023-03-20 05:51:43
Cosmetic 6cd025cc3724731b983e92b4851783730c4e1c43 Catalin(ux) M. BOIE 2023-03-20 05:37:01
Solved a little curl processing bug; updated doc 55c78506492a686c38a3d2833708e243f339ba0f Catalin(ux) M. BOIE 2023-03-18 06:55:28
Added nd-cert-info tool 14447ae85aa5501d542c17f31fd6ce820267846c Catalin(ux) M. BOIE 2023-03-18 06:54:42
Mostly documentation updates fadbfe517eac4b0de3783e79d9779af57791833d Catalin(ux) M. BOIE 2023-03-17 07:17:12
Another json_object_get_uint64 replaced with int64 21f272b86ed57916d0fb7cc05de20170c36cf1cb Catalin(ux) M. BOIE 2023-03-15 20:16:13
make chown optional to not get errors when building rpm 2541f217b4ee77748d03f553ce1f6576c43c7106 Catalin(ux) M. BOIE 2023-03-15 19:00:49
Wrong path to Makefile.common in Makefile 82d474d4e825fd1afaf225518512f075ca25295f Catalin(ux) M. BOIE 2023-03-15 18:16:58
DESTDIR installation fix 5b5b7917a4b26daed48f1bb6dee826533997b518 Catalin(ux) M. BOIE 2023-03-15 12:59:22
RockyLinux 8 does not have json_object_new_uint64 function ce66611027547ca6740f36efa4f9da60f47c6132 Catalin(ux) M. BOIE 2023-03-15 12:33:18
More functions added 920cc4824df01ccfc0b04450fdfa43568910cf85 Catalin(ux) M. BOIE 2023-03-15 06:17:29
Lots of changes 8c803765a4dd6d79e7f61927c47a5f1a19e3db31 Catalin(ux) M. BOIE 2023-03-13 05:51:28
Record full path of the cert for openssl 66e89d4e0eaf638859b39c791d82d233e2d0c2c2 Catalin(ux) M. BOIE 2023-03-03 18:41:57
Improve presentation 0600fd3c6e5fcb0dd152d0e680ea85a8ae89bd86 Catalin(ux) M. BOIE 2022-12-09 17:46:09
More curl tracing info 04013af7a216e6cf7f363b3895ffcebe78859a65 Catalin(ux) M. BOIE 2022-12-09 17:45:46
Added curl support c374ad15d2d5548d168084c0e8506929803e9bf0 Catalin(ux) M. BOIE 2022-11-30 11:28:48
More Latex modules were missing ff5bec2cfba2cf77e0115f89124cdeb83dfbc73d Catalin(ux) M. BOIE 2022-11-24 16:52:48
Forgot to add beamer 1080ddc6497af77b66fd57eb7b9da0abaf75cb2a Catalin(ux) M. BOIE 2022-11-24 16:39:30
Commit 5f4a8873f9d9b137445aeb2fa4058e9d0a324770 - Log leaks when program runs
Author: Catalin(ux) M. BOIE
Author date (UTC): 2023-04-10 17:09
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2023-04-10 17:09
Parent(s): dc66bea6ff6c977d08bd4845634fd2c1bba1ed64
Signer:
Signing key:
Signing status: N
Tree: aee46978c9fe248485798e1efe03f129cd81b3ab
File Lines added Lines deleted
agent/ninedogs.c 44 29
test/leak/1.c 8 0
File agent/ninedogs.c changed (mode: 100644) (index 5d8d2de..9dbb8ab)
... ... static void log_backtrace_symbols(const struct leak *q)
196 196
197 197 for (uint8_t i = 2; i < q->backtrace_len; i++) for (uint8_t i = 2; i < q->backtrace_len; i++)
198 198 xlog(1, " %s\n", r[i]); xlog(1, " %s\n", r[i]);
199 free(r); // TODO: we should mark when we are inside ninedogs, to avoid loops
199 free(r);
200 }
201
202 // TODO: add pack_backtrace function and use it!
203 static void leak_dump_one(const struct leak *q)
204 {
205 xlog(1, "allocations=%lu frees=%lu allocated=%lu\n",
206 q->allocations, q->frees, q->bytes_allocated);
207 log_backtrace_symbols(q);
208 }
209
210 static void leak_dump(void)
211 {
212 if (leak_detector == 0)
213 return;
214
215 nd_inside_inc();
216
217 xlog(1, "Dumping leaks...\n");
218 for (uint16_t i = 0; i < ND_LEAK_MAX_BT; i++) {
219 struct leak *q = &nd_leaks[i];
220
221 if (q->backtrace_len == 0)
222 continue;
223
224 if (q->allocations == q->frees)
225 continue;
226
227 if (q->bytes_allocated < 4096)
228 continue;
229
230 leak_dump_one(q);
231 }
232
233 nd_inside_dec();
200 234 } }
201 235
202 236 // tests if two backtraces match // tests if two backtraces match
 
... ... static struct leak *leak_add(size_t size)
267 301 if (!q) if (!q)
268 302 return NULL; return NULL;
269 303
304 // TODO: Make chunk configurable
305 // We want to log as soon as a 4MiB chunk is crossed
306 uint64_t prev = q->bytes_allocated >> 22;
307
270 308 q->allocations++; q->allocations++;
271 309 q->bytes_allocated += size; q->bytes_allocated += size;
310
311 uint64_t new = q->bytes_allocated >> 22;
312 if (new > prev)
313 leak_dump_one(q);
314
272 315 return q; return q;
273 316 } }
274 317
 
... ... static struct leak *leak_del(void)
289 332 return q; return q;
290 333 } }
291 334
292 static void leak_dump(void)
293 {
294 if (leak_detector == 0)
295 return;
296
297 nd_inside_inc();
298
299 xlog(1, "Dumping leaks...\n");
300 for (uint16_t i = 0; i < ND_LEAK_MAX_BT; i++) {
301 struct leak *q = &nd_leaks[i];
302
303 if (q->backtrace_len == 0)
304 continue;
305
306 if (q->allocations == q->frees)
307 continue;
308
309 if (q->bytes_allocated < 4096)
310 continue;
311
312 xlog(1, "%hu: allocations=%lu frees=%lu allocated=%lu\n",
313 i, q->allocations, q->frees, q->bytes_allocated);
314 log_backtrace_symbols(&nd_leaks[i]);
315 }
316
317 nd_inside_dec();
318 }
319
320 335 /* fd helpers */ /* fd helpers */
321 336 static struct fd_node *fd_search(const int fd) static struct fd_node *fd_search(const int fd)
322 337 { {
File test/leak/1.c changed (mode: 100644) (index 4bdcc9a..75cc491)
... ... int main(void)
29 29 f1(); f1();
30 30 f1(); f1();
31 31
32 void *b[100];
33 for (int i = 0; i < 100; i++)
34 b[i] = malloc(5 * 4096 * 4096);
35
36 // Crash
37 unsigned char *a = NULL;
38 *a = 1;
39
32 40 return 0; return 0;
33 41 } }
34 42
Date/time (UTC) Type Misc Labels
2023-04-22 15:15 build fedora-37-x86_64 worker/r1 builder/color=fff worker_elap/998s wait_time/1028931s date/2023-04-10 time/17:09
2023-04-22 15:29 build fedora-rawhide-x86_64 worker/r1 builder/color=fff worker_elap/718s wait_time/1029994s date/2023-04-10 time/17:09
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/ninedogs

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/ninedogs

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/ninedogs

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main