abrt / satyr

Automatic problem management with anonymous reports
GNU General Public License v2.0
19 stars 23 forks source link

Fix test suit core_stacktrace fail using clang #341

Closed MANGOPIE3 closed 7 months ago

MANGOPIE3 commented 1 year ago

Hi, I find core_stacktrace failed when I used clang to compile satyr and make check. The log is

[   37s] mv testsuite.tmp testsuite
[   37s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/satyr-0.42/tests'
[   37s] make  check-TESTS check-local
[   37s] make[2]: Entering directory '/home/abuild/rpmbuild/BUILD/satyr-0.42/tests'
[   37s] make[3]: Entering directory '/home/abuild/rpmbuild/BUILD/satyr-0.42/tests'
[   37s] PASS: abrt
[   37s] PASS: cluster
[   37s] PASS: core_frame
[   39s] ../test-driver: line 112: 1266360 Aborted                 (core dumped) "$@" >> "$log_file" 2>&1
[   39s] FAIL: core_stacktrace
[   39s] PASS: core_thread
[   39s] PASS: gdb_frame
[   39s] PASS: gdb_stacktrace
[   39s] PASS: gdb_thread
[   39s] PASS: gdb_sharedlib
[   39s] PASS: java_frame
[   39s] PASS: java_stacktrace
[   40s] PASS: java_thread
[   40s] PASS: js_frame
[   40s] PASS: js_platform
[   40s] PASS: js_stacktrace
[   40s] PASS: koops_frame
[   40s] PASS: koops_stacktrace
[   40s] PASS: metrics
[   40s] PASS: normalize
[   41s] PASS: operating_system
[   41s] PASS: report
[   41s] PASS: rpm
[   41s] PASS: ruby_frame
[   41s] PASS: ruby_stacktrace
[   41s] PASS: utils
[   41s] ============================================================================
[   41s] Testsuite summary for satyr 0.42
[   41s] ============================================================================
[   41s] # TOTAL: 25
[   41s] # PASS:  24
[   41s] # SKIP:  0
[   41s] # XFAIL: 0
[   41s] # FAIL:  1
[   41s] # XPASS: 0
[   41s] # ERROR: 0
[   41s] ============================================================================
[   41s] See tests/test-suite.log
[   41s] Please report to crash-catcher@fedorahosted.org
[   41s] ============================================================================

I searched the log and find a warning:

[   24s] dump_core.c:18:16: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
[   24s] __attribute__((optimize((0))))
[   24s]                ^~~~~~~~~~~~~
[   24s] 1 warning generated.
static char const *prefix = "/tmp/satyr.core";

__attribute__((optimize((0))))
int
dump_core(int    depth,
          char **name)
{
    pid_t pid;
    char *pid_string;
    pid_t fork_pid;
    int status;

Then I read up the related code, found that we need compile the dump_core function with no optimization(O0), but it seems the clang doesnot support the __attribute__((optimize((0)))). I search the how to use per-function optimization attributes with clang I find the __attribute__((optnone) works well. I cannot find the attribute that gcc and clang all support, thus I try to use predefined macros__clang__ to distinguish between clang and gcc, like this:

static char const *prefix = "/tmp/satyr.core";

#if __clang__
__attribute__((optnone))  
#else
__attribute__((optimize((0))))
#endif
int
dump_core(int    depth,
          char **name)

My pr is #340, any advice is welcome!

msrb commented 7 months ago

Thank you, merged ;)