Bug 30401 - s390x specific: invalid application of ‘sizeof’ to incomplete type ‘struct stack_frame’
Summary: s390x specific: invalid application of ‘sizeof’ to incomplete type ‘struct st...
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-28 12:33 UTC by Martin Cermak
Modified: 2023-10-12 17:59 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch that allows the reproducer to work on both newer s390 rhel9 and older rhel8 kernel (957 bytes, patch)
2023-10-12 03:45 UTC, William Cohen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Cermak 2023-04-28 12:33:54 UTC
Recent 5.14.0-302.el9.s390x latest upstream stap 386aba5769bcba3e1149c277f36baab50bbbbb0c shows:

9 s390x # stap -e 'probe process("/bin/bash").function("main") { printf("%x\n", int_arg(1)) }'
WARNING: cannot find module /usr/bin/bash debuginfo: No DWARF information found [man warning::debuginfo]
Missing separate debuginfos, use: debuginfo-install bash-5.1.8-6.el9_1.s390x 
/tmp/staplihN2Y/stap_7f17fea67823b1d8d78574779801cb03_8083_src.c: In function ‘function___global__stp_get_kernel_stack_param__overload_0’:
/tmp/staplihN2Y/stap_7f17fea67823b1d8d78574779801cb03_8083_src.c:1033:58: error: invalid application of ‘sizeof’ to incomplete type ‘struct stack_frame’
 1033 |         addr = (_stp_kernel_stack_pointer(regs) + sizeof(struct stack_frame)
      |                                                          ^~~~~~
/tmp/staplihN2Y/stap_7f17fea67823b1d8d78574779801cb03_8083_src.c: At top level:
cc1: note: unrecognized command-line option ‘-Wno-infinite-recursion’ may have been intended to silence earlier diagnostics
make[1]: *** [scripts/Makefile.build:297: /tmp/staplihN2Y/stap_7f17fea67823b1d8d78574779801cb03_8083_src.o] Error 1
make: *** [Makefile:1923: /tmp/staplihN2Y] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compilation failed.  [man error::pass4]
9 s390x #
Comment 1 William Cohen 2023-10-06 21:03:16 UTC
I investigationed why this is failing on rhel9 s390.  The struct stack_frame was moved arch/s390/include/asm/processor.h to arch/s390/include/asm/stackframe.h by kernel
git commit 78c98f9074135d3dab4e39544e0a537f92388fce

Author: Martin Schwidefsky <schwidefsky@de.ibm.com>  2019-01-28 02:33:08
Committer: Martin Schwidefsky <schwidefsky@de.ibm.com>  2019-05-02 07:54:11
Parent: 1c705ad5efae9c712e763a47fbcc95b87b7347d2 (s390/opcodes: add missing instructions to the disassembler)
Child:  ec7bf4789d95a0053bac0dfa36fbefd8cc584eea (s390/ftrace: use HAVE_FUNCTION_GRAPH_RET_ADDR_PTR)
Branches: master, remotes/origin/master, remotes/origin/mmu_gather-race-fix, remotes/origin/tty-splice, remotes/origin/x86-rep-insns, remotes/origin/x86-uaccess-cleanup, wcohen/gcc9
Follows: v5.1-rc2
Precedes: v5.2-rc1

    s390/unwind: introduce stack unwind API
    
    Rework the dump_trace() stack unwinder interface to support different
    unwinding algorithms. The new interface looks like this:
    
    	struct unwind_state state;
    	unwind_for_each_frame(&state, task, regs, start_stack)
    		do_something(state.sp, state.ip, state.reliable);
    
    The unwind_bc.c file contains the implementation for the classic
    back-chain unwinder.
    
    One positive side effect of the new code is it now handles ftraced
    functions gracefully. It prints the real name of the return function
    instead of 'return_to_handler'.
    
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

I am looking around to see there is a common include that ends up pulling in the definition of struct stack_frame. The patch above adds "#include <asm/stacktrace.h>" a number of files.  Might need to resort to a STAPCONF to add the include where needed.
Comment 2 William Cohen 2023-10-12 03:45:10 UTC
Created attachment 15164 [details]
Patch that allows the reproducer to work on both newer s390 rhel9 and older rhel8 kernel

This is a propoosed patch to address this issue.  It has been tested on rhel8 and rhel9 s390 kernels to make sure that it doesn't break things for older kernels.
Comment 3 William Cohen 2023-10-12 17:59:04 UTC
The patch to address this issue has been added to the systemtap upstream git repository with commit 3ecf49eee2ab7e7.