LD_PRELOAD causes stack smashing error in gpg

devnoname120 devnoname120 at gmail.com
Sat Apr 18 18:53:39 CEST 2026


For some reason gpg doesn’t seem to like when a RegEx is compiled in the constructor of a preloaded library. I haven’t seen this happen in other software, any ideas what could be causing this?

Minimum repo:

File `/tmp/repo.c`:

```c
#define _GNU_SOURCE
#include <regex.h>

__attribute__((constructor)) static void init(void) {
 regex_t regex;
 regcomp(&regex, "", 0);
}
```

Shell:

```sh
gcc -shared -fPIC -o /tmp/repro.so /tmp/repro.c
export LD_PRELOAD=/tmp/repro.so
gpg --list-keys
```

Output:

```
*** stack smashing detected ***: terminated
Aborted
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20260418/201f04d1/attachment.html>


More information about the Gnupg-devel mailing list