Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 4.4.4 fails to build with clang: incomplete definition of the 'struct next' type #809

Open
ehaupt opened this issue Jun 12, 2023 · 11 comments
Assignees
Labels

Comments

@ehaupt
Copy link

ehaupt commented Jun 12, 2023

Describe the bug
Version 4.4.4 fails to build with clang (previous version 4.4.3 builds fine):

Compiler version:

$ clang --version
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
Target: x86_64-unknown-freebsd13.2
Thread model: posix
InstalledDir: /usr/bin

In 'mod.c', a fatal error occurs due to an incomplete definition of the 'struct next' type, resulting in a build failure.

cc -DHAVE_CONFIG_H -I. -I../../src    -I./.. -I./../.. -I/usr/local/include -D_U_="__attribute__((unused))" -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing   -Wno-variadic-macros -Wfatal-errors  -I/usr/lib -I/usr/include -MT libfragroute_a-fragroute.o -MD -MP -MF .deps/libfragroute_a-fragroute.Tpo -c -o libfragroute_a-fragroute.o `test -f 'fragroute.c' || echo './'`fragroute.c
mv -f .deps/libfragroute_a-fragroute.Tpo .deps/libfragroute_a-fragroute.Po
cc -DHAVE_CONFIG_H -I. -I../../src    -I./.. -I./../.. -I/usr/local/include -D_U_="__attribute__((unused))" -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing   -Wno-variadic-macros -Wfatal-errors  -I/usr/lib -I/usr/include -MT libfragroute_a-bget.o -MD -MP -MF .deps/libfragroute_a-bget.Tpo -c -o libfragroute_a-bget.o `test -f 'bget.c' || echo './'`bget.c
mv -f .deps/libfragroute_a-bget.Tpo .deps/libfragroute_a-bget.Po
cc -DHAVE_CONFIG_H -I. -I../../src    -I./.. -I./../.. -I/usr/local/include -D_U_="__attribute__((unused))" -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing   -Wno-variadic-macros -Wfatal-errors  -I/usr/lib -I/usr/include -MT libfragroute_a-mod.o -MD -MP -MF .deps/libfragroute_a-mod.Tpo -c -o libfragroute_a-mod.o `test -f 'mod.c' || echo './'`mod.c
mod.c:180:5: fatal error: incomplete definition of type 'struct next'
    TAILQ_FOREACH_REVERSE(rule, &rules, next, head)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/queue.h:750:15: note: expanded from macro 'TAILQ_FOREACH_REVERSE'
        for ((var) = TAILQ_LAST((head), headname);                      \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/queue.h:824:44: note: expanded from macro 'TAILQ_LAST'
        (*(((struct headname *)((head)->tqh_last))->tqh_last))
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
mod.c:180:41: note: forward declaration of 'struct next'
    TAILQ_FOREACH_REVERSE(rule, &rules, next, head)
                                        ^

Full build log: tcpreplay-4.4.4.log

To Reproduce

  1. Download a FreeBSD vagrant image
  2. Try to compile 4.4.4

System (please complete the following information):

  • OS: FreeBSD
  • OS version: 13.1-RELEASE-p7
  • Tcpreplay Version: 4.4.4
@fklassen
Copy link
Member

I tried with clang-13 and clang-17 on Debian Linux. No failure. Do you see this fail on 4.4.3?

@ehaupt
Copy link
Author

ehaupt commented Jun 12, 2023

4.4.3 builds fine.

@fklassen
Copy link
Member

OK, I'll build up a FreeBSD VM to test on.

@fklassen fklassen self-assigned this Jun 12, 2023
@fklassen fklassen added the bug label Jun 12, 2023
@ehaupt
Copy link
Author

ehaupt commented Jun 13, 2023

OK, I'll build up a FreeBSD VM to test on.

Quick setup to have all deps:

Vagrant.configure("2") do |config|
  config.vm.box = "freebsd/FreeBSD-13.2-RELEASE"
  config.vm.box_version = "2023.04.07"

  config.vm.provision "shell", inline: <<-SHELL
    sed -i'' -e 's|quarterly|latest|' /etc/pkg/FreeBSD.conf
    pkg install -y bash git
    portsnap --interactive fetch extract
    sh -c '(cd /usr/ports/net-mgmt/tcpreplay; make missing | xargs pkg install -y)'
  SHELL
end

@ehaupt
Copy link
Author

ehaupt commented Jun 16, 2023

Just to verify, I attempted compiling with a different compiler (gcc 12.2.0), but it failed as well.

See tcpreplay-4.4.4_gcc_freebsd_13_1.log

The title of the issue should probably be changed to:

[Bug] 4.4.4 fails to build on FreeBSD: incomplete definition of the 'struct next' type

@ehaupt
Copy link
Author

ehaupt commented Aug 29, 2023

According to repology, no other *BSD has updated to 4.4.4 so this bug likely exists on those platforms as well.

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Mar 24, 2024
Issues with the latest release ramain unresolved for > 6 months:

appneta/tcpreplay#809

Back to the unmaintained pool.
@VVD
Copy link

VVD commented Jul 15, 2024

Maybe this is the patch:

--- src/fragroute/mod.c.orig	2024-05-02 00:04:53 UTC
+++ src/fragroute/mod.c
@@ -8,11 +8,11 @@
  */

 #include "mod.h"
+#include "lib/queue.h"
 #include "defines.h"
 #include "config.h"
 #include "common.h"
 #include "argv.h"
-#include "lib/queue.h"
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
--- src/fragroute/pkt.h.orig	2024-05-02 00:04:56 UTC
+++ src/fragroute/pkt.h
@@ -8,9 +8,9 @@

 #pragma once

+#include "lib/queue.h"
 #include "defines.h"
 #include "config.h"
-#include "lib/queue.h"
 #include <sys/time.h>

 #ifdef HAVE_LIBDNET

I want to say it work for me: without patch I have same error, but with patch build without errors.

@fklassen
Copy link
Member

Somehow this got missed for 4.5.1. I'll target for next minor release.

@ehaupt
Copy link
Author

ehaupt commented Jul 16, 2024

On FreeBSD, this issue is mitigated by applying the following patch:

--- lib/queue.h.orig	2024-03-24 16:55:28 UTC
+++ lib/queue.h
@@ -36,8 +36,8 @@
  *	@(#)queue.h	8.5 (Berkeley) 8/20/94
  */

-#ifndef	_SYS_QUEUE_H_
-#define	_SYS_QUEUE_H_
+#ifndef	_QUEUE_H_
+#define	_QUEUE_H_

 /*
  * This file defines five types of data structures: singly-linked lists,
@@ -508,4 +508,4 @@ struct {								\
		(elm2)->field.cqe_prev->field.cqe_next = (elm2);	\
 } while (0)

-#endif /* !_SYS_QUEUE_H_ */
+#endif /* !_QUEUE_H_ */

@VVD
Copy link

VVD commented Jul 16, 2024

@ehaupt
Copy link
Author

ehaupt commented Jul 16, 2024

@ehaupt, check this PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280260

I'll respond in bugzilla.

netgate-git-updates pushed a commit to pfsense/FreeBSD-ports that referenced this issue Jul 16, 2024
…dified

Also:
 - replace patch for fix build (upstream issue:
appneta/tcpreplay#809);
 - remake patches with makepatch;
 - remove GNU_CONFIGURE_MANPREFIX.

Version 4.5.1 contains many bug fixes:
https://github.com/appneta/tcpreplay/releases/tag/v4.5.1

PR:		280260
Approved by:	ehaupt (maintainer)
MFH:		2024Q3
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 16, 2024
…dified

Also:
 - replace patch for fix build (upstream issue:
appneta/tcpreplay#809);
 - remake patches with makepatch;
 - remove GNU_CONFIGURE_MANPREFIX.

Version 4.5.1 contains many bug fixes:
https://github.com/appneta/tcpreplay/releases/tag/v4.5.1

PR:		280260
Approved by:	ehaupt (maintainer)
MFH:		2024Q3

(cherry picked from commit e2455c7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants