mit-pdos / xv6-riscv

Xv6 for RISC-V
Other
6.6k stars 2.38k forks source link

error: infinite recursion detected in function `runcmd` #125

Closed chinggg closed 1 year ago

chinggg commented 2 years ago

I find this error when make qemu using GCC 11, though it can be solved by removing -Werror in CFLAGS.

riscv64-linux-gnu-gcc -Wall -Werror -O -fno-omit-frame-pointer -ggdb -MD -mcmodel=medany -ffreestanding -fno-common -nostdlib -mno-relax -I. -fno-stack-protector -fno-pie -no-pie   -c -o user/sh.o user/sh.c
user/sh.c: In function 'runcmd':
user/sh.c:58:1: error: infinite recursion detected [-Werror=infinite-recursion]
   58 | runcmd(struct cmd *cmd)
      | ^~~~~~
user/sh.c:89:5: note: recursive call
   89 |     runcmd(rcmd->cmd);
      |     ^~~~~~~~~~~~~~~~~
user/sh.c:109:7: note: recursive call
  109 |       runcmd(pcmd->left);
      |       ^~~~~~~~~~~~~~~~~~
user/sh.c:116:7: note: recursive call
  116 |       runcmd(pcmd->right);
      |       ^~~~~~~~~~~~~~~~~~~
user/sh.c:95:7: note: recursive call
   95 |       runcmd(lcmd->left);
      |       ^~~~~~~~~~~~~~~~~~
user/sh.c:97:5: note: recursive call
   97 |     runcmd(lcmd->right);
      |     ^~~~~~~~~~~~~~~~~~~
user/sh.c:127:7: note: recursive call
  127 |       runcmd(bcmd->cmd);
      |       ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [<builtin>: user/sh.o] Error 1
zhuiYeah commented 1 year ago

怎么切换到gcc11

Earthaa commented 1 year ago

According to my expeience, you can solve this by adding __attribute__((noreturn)) before line 56 in usr/sh.c file

praneshp1org commented 1 year ago

this can be solved by adding __attribute__((noreturn)) just above line 56 in sh.c the infinite recursion is then resolved