Red Hat Bugzilla – Bug 25442
non-static data causes segfault in syslog
Last modified: 2016-11-24 10:04:26 EST
This may be a gcc problem; I'm not smart enough to tell . . .
Compiling/running a C program with 4 non-static global character pointers
segfault in any call to syslog. See the example code in "Additional
Information." If the
data is static, the segfault does not occur.
Steps to Reproduce:
1. Compile the example program below.
2. Run it.
Actual Results: Segfault
Expected Results: It shouldn't segfault
char *job, *host, *user, *time;
int main (int argc, const char *argv)
syslog (LOG_ERR, "error message");
This is fault on your side, you should not define time as global variable when
you call a function which calls time() because then libc calls resolves
time to your variable (that's how ELF symbol resolution works).