[patch] net/sniproxy unbreak and -fno-common fix
Hello, It seems that I didn't test sniproxy deep enough after the patch removal for STAILQ_*. There are core dumps with sniproxy without the patch. Here is a diff which brings back the patch and also solves the compilation error with the -fno-common change. I need to check if it's possible to make that cleaner, but in the meantime sniproxy works again. Best Regards Index: Makefile === RCS file: /cvs/ports/net/sniproxy/Makefile,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 Makefile --- Makefile 8 Apr 2020 04:56:52 - 1.1.1.1 +++ Makefile 9 Feb 2021 14:15:17 - @@ -6,6 +6,8 @@ GH_ACCOUNT = dlundquist GH_PROJECT = sniproxy GH_TAGNAME = 0.6.0 +REVISION = 0 + CATEGORIES = net HOMEPAGE = https://github.com/dlundquist/sniproxy Index: patches/patch-src_backend_h === RCS file: patches/patch-src_backend_h diff -N patches/patch-src_backend_h --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_backend_h 9 Feb 2021 14:15:17 - @@ -0,0 +1,95 @@ +$OpenBSD: patch-src_backend_h,v 1.1.1.1 2020/04/08 04:56:52 bket Exp $ + +Index: src/backend.h +--- src/backend.h.orig src/backend.h +@@ -31,6 +31,89 @@ + #include + #include "address.h" + ++#ifndef STAILQ_INIT ++/* ++ * Singly-linked Tail queue declarations. ++ */ ++#define STAILQ_HEAD(name, type) \ ++struct name { \ ++struct type *stqh_first;/* first element */ \ ++struct type **stqh_last;/* addr of last next element */ \ ++} ++ ++#define STAILQ_HEAD_INITIALIZER(head) \ ++{ NULL, &(head).stqh_first } ++ ++#define STAILQ_ENTRY(type) \ ++struct {\ ++struct type *stqe_next; /* next element */ \ ++} ++ ++/* ++ * Singly-linked Tail queue functions. ++ */ ++#define STAILQ_INIT(head) do { \ ++(head)->stqh_first = NULL; \ ++(head)->stqh_last = &(head)->stqh_first;\ ++} while (/*CONSTCOND*/0) ++ ++#define STAILQ_INSERT_HEAD(head, elm, field) do { \ ++if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ ++(head)->stqh_last = &(elm)->field.stqe_next;\ ++(head)->stqh_first = (elm); \ ++} while (/*CONSTCOND*/0) ++ ++#define STAILQ_INSERT_TAIL(head, elm, field) do { \ ++(elm)->field.stqe_next = NULL; \ ++*(head)->stqh_last = (elm); \ ++(head)->stqh_last = &(elm)->field.stqe_next;\ ++} while (/*CONSTCOND*/0) ++ ++#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ ++if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ ++(head)->stqh_last = &(elm)->field.stqe_next;\ ++(listelm)->field.stqe_next = (elm); \ ++} while (/*CONSTCOND*/0) ++ ++#define STAILQ_REMOVE_HEAD(head, field) do {\ ++if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ ++(head)->stqh_last = &(head)->stqh_first;\ ++} while (/*CONSTCOND*/0) ++ ++#define STAILQ_REMOVE(head, elm, type, field) do { \ ++if ((head)->stqh_first == (elm)) { \ ++STAILQ_REMOVE_HEAD((head), field); \ ++} else {\ ++struct type *curelm = (head)->stqh_first; \ ++while (curelm->field.stqe_next != (elm))\ ++curelm = curelm->field.stqe_next; \ ++if ((curelm->field.stqe_next = \ ++curelm->field.stqe_next->field.stqe_next) == NULL) \ ++(head)->stqh_last = &(curelm)->field.stqe_next; \ ++} \ ++} while (/*CONSTCOND*/0) ++ ++#define STAILQ_FOREACH(var, head, field)\ ++for ((var) = ((head)->stqh_first); \ ++(var); \ ++(var) = ((var)->field.stqe_next)) ++ ++#define STAILQ_CONCAT(head1, head2) do {\ ++if (!STAILQ_EMPTY((head2))) { \ ++*(head
Re: [patch] net/sniproxy unbreak and -fno-common fix
On Tue, Feb 09, 2021 at 03:19:00PM +0100, Renaud Allard wrote: > Hello, > > It seems that I didn't test sniproxy deep enough after the patch removal for > STAILQ_*. There are core dumps with sniproxy without the patch. I think this needs deeper investigation. Could you share a backtrace or a reproducer for these crashes?
Re: [patch] net/sniproxy unbreak and -fno-common fix
On Tue, Feb 09, 2021 at 03:41:29PM +0100, Renaud Allard wrote: > > On 2/9/21 3:26 PM, Theo Buehler wrote: > > On Tue, Feb 09, 2021 at 03:19:00PM +0100, Renaud Allard wrote: > > > Hello, > > > > > > It seems that I didn't test sniproxy deep enough after the patch removal > > > for > > > STAILQ_*. There are core dumps with sniproxy without the patch. > > I think this needs deeper investigation. Could you share a backtrace or > > a reproducer for these crashes? > > > My bad, I tried to reproduce it and it seems there was a problem in my > CFLAGS which caused the issue. > > So here is the patch only for the -fno-common > > While your patch fixes the compilation, I'd suggest going with the usual change, which is also the one upstream merged: https://github.com/dlundquist/sniproxy/pull/349 I added a patch for a warning about an incorrect format string on top. Are you ok with this? Index: Makefile === RCS file: /cvs/ports/net/sniproxy/Makefile,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 Makefile --- Makefile8 Apr 2020 04:56:52 - 1.1.1.1 +++ Makefile9 Feb 2021 14:44:47 - @@ -6,6 +6,8 @@ GH_ACCOUNT =dlundquist GH_PROJECT = sniproxy GH_TAGNAME = 0.6.0 +REVISION = 0 + CATEGORIES = net HOMEPAGE = https://github.com/dlundquist/sniproxy Index: patches/patch-src_config_c === RCS file: patches/patch-src_config_c diff -N patches/patch-src_config_c --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_config_c 9 Feb 2021 14:51:40 - @@ -0,0 +1,16 @@ +$OpenBSD$ + +Fix incorrect format string + +Index: src/config.c +--- src/config.c.orig src/config.c +@@ -234,7 +234,7 @@ init_config(const char *filename, struct ev_loop *loop + err("error parsing %s at %jd near:", filename, whence); + fseek(file, -20, SEEK_CUR); + for (int i = 0; i < 5; i++) +-err(" %jd\t%s", ftell(file), fgets(line, sizeof(line), file)); ++err(" %ld\t%s", ftell(file), fgets(line, sizeof(line), file)); + + free_config(config, loop); + config = NULL; Index: patches/patch-src_http_h === RCS file: patches/patch-src_http_h diff -N patches/patch-src_http_h --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_http_h9 Feb 2021 14:50:24 - @@ -0,0 +1,15 @@ +$OpenBSD$ + +https://github.com/dlundquist/sniproxy/pull/349 + +Index: src/http.h +--- src/http.h.orig src/http.h +@@ -29,6 +29,6 @@ + #include + #include "protocol.h" + +-const struct Protocol *const http_protocol; ++extern const struct Protocol *const http_protocol; + + #endif Index: patches/patch-src_tls_h === RCS file: patches/patch-src_tls_h diff -N patches/patch-src_tls_h --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_tls_h 9 Feb 2021 14:50:30 - @@ -0,0 +1,15 @@ +$OpenBSD$ + +https://github.com/dlundquist/sniproxy/pull/349 + +Index: src/tls.h +--- src/tls.h.orig src/tls.h +@@ -28,6 +28,6 @@ + + #include "protocol.h" + +-const struct Protocol *const tls_protocol; ++extern const struct Protocol *const tls_protocol; + + #endif
Re: [patch] net/sniproxy unbreak and -fno-common fix
On 2/9/21 3:26 PM, Theo Buehler wrote: On Tue, Feb 09, 2021 at 03:19:00PM +0100, Renaud Allard wrote: Hello, It seems that I didn't test sniproxy deep enough after the patch removal for STAILQ_*. There are core dumps with sniproxy without the patch. I think this needs deeper investigation. Could you share a backtrace or a reproducer for these crashes? My bad, I tried to reproduce it and it seems there was a problem in my CFLAGS which caused the issue. So here is the patch only for the -fno-common Index: Makefile === RCS file: /cvs/ports/net/sniproxy/Makefile,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 Makefile --- Makefile 8 Apr 2020 04:56:52 - 1.1.1.1 +++ Makefile 9 Feb 2021 14:39:29 - @@ -6,6 +6,8 @@ GH_ACCOUNT = dlundquist GH_PROJECT = sniproxy GH_TAGNAME = 0.6.0 +REVISION = 0 + CATEGORIES = net HOMEPAGE = https://github.com/dlundquist/sniproxy Index: patches/patch-src_http_c === RCS file: patches/patch-src_http_c diff -N patches/patch-src_http_c --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_http_c 9 Feb 2021 14:39:29 - @@ -0,0 +1,14 @@ +$OpenBSD$ + +Index: src/http.c +--- src/http.c.orig src/http.c +@@ -45,7 +45,7 @@ static const char http_503[] = + "Connection: close\r\n\r\n" + "Backend not available"; + +-const struct Protocol *const http_protocol = &(struct Protocol){ ++static const struct Protocol *const http_protocol = &(struct Protocol){ + .name = "http", + .default_port = 80, + .parse_packet = &parse_http_header, Index: patches/patch-src_http_h === RCS file: patches/patch-src_http_h diff -N patches/patch-src_http_h --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_http_h 9 Feb 2021 14:39:29 - @@ -0,0 +1,13 @@ +$OpenBSD$ + +Index: src/http.h +--- src/http.h.orig src/http.h +@@ -29,6 +29,6 @@ + #include + #include "protocol.h" + +-const struct Protocol *const http_protocol; ++static const struct Protocol *const http_protocol; + + #endif Index: patches/patch-src_tls_c === RCS file: patches/patch-src_tls_c diff -N patches/patch-src_tls_c --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_tls_c 9 Feb 2021 14:39:29 - @@ -0,0 +1,14 @@ +$OpenBSD$ + +Index: src/tls.c +--- src/tls.c.orig src/tls.c +@@ -60,7 +60,7 @@ static const char tls_alert[] = { + 0x02, 0x28, /* Fatal, handshake failure */ + }; + +-const struct Protocol *const tls_protocol = &(struct Protocol){ ++static const struct Protocol *const tls_protocol = &(struct Protocol){ + .name = "tls", + .default_port = 443, + .parse_packet = (int (*const)(const char *, size_t, char **))&parse_tls_header, Index: patches/patch-src_tls_h === RCS file: patches/patch-src_tls_h diff -N patches/patch-src_tls_h --- /dev/null 1 Jan 1970 00:00:00 - +++ patches/patch-src_tls_h 9 Feb 2021 14:39:29 - @@ -0,0 +1,13 @@ +$OpenBSD$ + +Index: src/tls.h +--- src/tls.h.orig src/tls.h +@@ -28,6 +28,6 @@ + + #include "protocol.h" + +-const struct Protocol *const tls_protocol; ++static const struct Protocol *const tls_protocol; + + #endif smime.p7s Description: S/MIME Cryptographic Signature
Re: [patch] net/sniproxy unbreak and -fno-common fix
On 2/9/21 3:54 PM, Theo Buehler wrote: On Tue, Feb 09, 2021 at 03:41:29PM +0100, Renaud Allard wrote: On 2/9/21 3:26 PM, Theo Buehler wrote: On Tue, Feb 09, 2021 at 03:19:00PM +0100, Renaud Allard wrote: Hello, It seems that I didn't test sniproxy deep enough after the patch removal for STAILQ_*. There are core dumps with sniproxy without the patch. I think this needs deeper investigation. Could you share a backtrace or a reproducer for these crashes? My bad, I tried to reproduce it and it seems there was a problem in my CFLAGS which caused the issue. So here is the patch only for the -fno-common While your patch fixes the compilation, I'd suggest going with the usual change, which is also the one upstream merged: https://github.com/dlundquist/sniproxy/pull/349 I added a patch for a warning about an incorrect format string on top. Are you ok with this? It seems lighter indeed and merged, so I guess this is the best way. I compiled and tested with your patch and it looks fine. So, OK for me. smime.p7s Description: S/MIME Cryptographic Signature