shakedown.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A community for live music fans with roots in the jam scene. Shakedown Social is run by a team of volunteers (led by @clifff and @sethadam1) and funded by donations.

Administered by:

Server stats:

269
active users

#clang

1 post1 participant0 posts today

What do OpenBSD people use for static analysis of C code?

Valgrind was available for a while but it seems to have been removed now

Apparently there is something called the "Clang Static Analyzer", but I'm not sure how to actually use it (it seems you have to compile your program with specific Clang flags?)

I know there are countless other bugs in my code, but its nice to see "no leaks detected" when I do some stupid shit with void pointers :)

#openbsd#c#gcc

I need help. First the question: On #FreeBSD, with all ports built with #LibreSSL, can I somehow use the #clang #thread #sanitizer on a binary actually using LibreSSL and get sane output?

What I now observe debugging #swad:

- A version built with #OpenSSL (from base) doesn't crash. At least I tried very hard, really stressing it with #jmeter, to no avail. Built with LibreSSL, it does crash.
- Less relevant: the OpenSSL version also performs slightly better, but needs almost twice the RAM
- The thread sanitizer finds nothing to complain when built with OpenSSL
- It complains a lot with LibreSSL, but the reports look "fishy", e.g. it seems to intercept some OpenSSL API functions (like SHA384_Final)
- It even complains when running with a single-thread event loop.
- I use a single SSL_CTX per listening socket, creating SSL objects from it per connection ... also with multithreading; according to a few sources, this should be supported and safe.
- I can't imagine doing that on a *single* thread could break with LibreSSL, I mean, this would make SSL_CTX pretty much pointless
- I *could* imagine sharing the SSL_CTX with multiple threads to create their SSL objects from *might* not be safe with LibreSSL, but no idea how to verify as long as the thread sanitizer gives me "delusional" output 😳

c/c++ devs of fediverse, what does your debugging workflow look like? I've used gdb manually a bit but it's quite laborious to set up each session. I need to be able to do step-through debugging with variable inspection.

[VS]Code and studio are very good for step through debugging once they're set up, but I'd rather avoid them altogether if possible, especially since you have to jump through a series of flaming hoops to get c debugging working in the non-telemetry open source version of code.

Any/all suggestions appreciated, other than 'use rust' #programming #clang #cpp

All I want is just a collection of #binutils, #GCC, #llvm+#clang, #glibc and #musl that are "free standing" / relocatable, which I can pack into a #squashfs image to carry around to my various development machines.

You'd think that for something as fundamental as compiler infrastructure with over 60 years of knowledge, the whole bootstrapping and bringup process would have been super streamlined, or at least mostly pain free by now.

Yeah, about that. IYKYK

Continued thread

I had a couple of pretty fun days in the #SaltMine. On Friday, I set up a #Jenkins server so that one of my projects can support Jenkins as well as #Gitlab. I always love learning new packages. Yesterday, I spent a lot of time in the #clang compiler's source code trying to figure out some problems with their static analysis, either their static analysis or my understanding of it.

TIL: C array subscript operators are handled in such a way that `letters[i]` is equivalent to `*(letters + i)` and because addition is commutative, that expression is identical to `*(i + letters)`, which means that `i[letters]` is the same as `letters[i]`.

```
#include <stdio.h>
#include <stddef.h>

int main() {
char letters[3] = "abc";
size_t i = 2;
printf("letters: %p\n", (void *)&letters);
printf("i[letters] (%p): %c\n", (void*)&(i[letters]), i[letters]);
printf("letters[i] (%p): %c\n", (void*)&(letters[i]), letters[i]);
return 0;
}
```

Which outputs:
```
letters: 0x7ffc68ec7bb9
i[letters] (0x7ffc68ec7bbb): c
letters[i] (0x7ffc68ec7bbb): c
```

Mind blown... :neofox_floof_explode:
#til #clang #pointers #programming