F-Stack / f-stack

F-Stack is an user space network development kit with high performance based on DPDK, FreeBSD TCP/IP stack and coroutine API.
http://www.f-stack.org
Other
3.88k stars 901 forks source link

Compiler errors in repo. error: storing the address of local variable ‘t_barrier’ in ‘*queue.tq_queue.stqh_last’ [-Werror=dangling-pointer=] #744

Open cpp77 opened 1 year ago

cpp77 commented 1 year ago

Hi, I just cloned the repo, installed DPDK, tried to compile F-Stack but there are two compiler errors where a temporary address is being assigned to a class member. Details below.

gcc --version
gcc (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0

The errors:

/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c: In function ‘taskqueue_drain_tq_queue’:
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:381:24: error: storing the address of local variable ‘t_barrier’ in ‘*queue.tq_hint’ [-Werror=dangling-pointer=]
  381 |         queue->tq_hint = &t_barrier;
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:366:21: note: ‘t_barrier’ declared here
  366 |         struct task t_barrier;
      |                     ^~~~~~~~~
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:366:21: note: ‘queue’ declared here
In file included from /home/f-stack/lib/../freebsd/sys/_callout.h:43,
                 from /home/f-stack/lib/../freebsd/sys/callout.h:43,
                 from /home/f-stack/lib/../freebsd/sys/systm.h:46,
                 from /home/f-stack/lib/include/sys/systm.h:32,
                 from /home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:33:
In function ‘taskqueue_drain_tq_queue’,
    inlined from ‘taskqueue_drain_all’ at /home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:599:8:
/home/f-stack/lib/../freebsd/sys/queue.h:391:27: error: storing the address of local variable ‘t_barrier’ in ‘*queue.tq_queue.stqh_last’ [-Werror=dangling-pointer=]
  391 |         (head)->stqh_last = &STAILQ_NEXT((elm), field);                 \
      |                           ^
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:380:9: note: in expansion of macro ‘STAILQ_INSERT_TAIL’
  380 |         STAILQ_INSERT_TAIL(&queue->tq_queue, &t_barrier, ta_link);
      |         ^~~~~~~~~~~~~~~~~~
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c: In function ‘taskqueue_drain_all’:
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:366:21: note: ‘t_barrier’ declared here
  366 |         struct task t_barrier;
      |                     ^~~~~~~~~
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:366:21: note: ‘queue’ declared here
In function ‘taskqueue_drain_tq_queue’,
    inlined from ‘taskqueue_quiesce’ at /home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:636:9:
/home/f-stack/lib/../freebsd/sys/queue.h:391:27: error: storing the address of local variable ‘t_barrier’ in ‘*queue.tq_queue.stqh_last’ [-Werror=dangling-pointer=]
  391 |         (head)->stqh_last = &STAILQ_NEXT((elm), field);                 \
      |                           ^
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:380:9: note: in expansion of macro ‘STAILQ_INSERT_TAIL’
  380 |         STAILQ_INSERT_TAIL(&queue->tq_queue, &t_barrier, ta_link);
      |         ^~~~~~~~~~~~~~~~~~
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c: In function ‘taskqueue_quiesce’:
/home/f-stack/lib/../freebsd/kern/subr_taskqueue.c:366:21: note: ‘t_barrier’ declared here
  366 |         struct task t_barrier;
      |                     ^~~~~~~~~

The code:

image

jfb8856606 commented 1 year ago

I have no gcc (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0.

You can modify struct task t_barrier; to static struct task t_barrier; in freebsd/kern/subr_taskqueue.c:366 and rebuild it.