From owner-svn-ports-head@freebsd.org Fri Feb 26 19:31:05 2021 Return-Path: <owner-svn-ports-head@freebsd.org> Delivered-To: svn-ports-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D1CC954C694; Fri, 26 Feb 2021 19:31:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DnKWs5cXYz4mbQ; Fri, 26 Feb 2021 19:31:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B21841051E; Fri, 26 Feb 2021 19:31:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 11QJV5WL097290; Fri, 26 Feb 2021 19:31:05 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 11QJV4Z5097286; Fri, 26 Feb 2021 19:31:04 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202102261931.11QJV4Z5097286@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin <jhb@FreeBSD.org> Date: Fri, 26 Feb 2021 19:31:04 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r566632 - in head/devel/glib20: . files X-SVN-Group: ports-head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head/devel/glib20: . files X-SVN-Commit-Revision: 566632 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the ports tree for head <svn-ports-head.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-ports-head>, <mailto:svn-ports-head-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-ports-head/> List-Post: <mailto:svn-ports-head@freebsd.org> List-Help: <mailto:svn-ports-head-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-ports-head>, <mailto:svn-ports-head-request@freebsd.org?subject=subscribe> X-List-Received-Date: Fri, 26 Feb 2021 19:31:05 -0000 Author: jhb (src,doc committer) Date: Fri Feb 26 19:31:04 2021 New Revision: 566632 URL: https://svnweb.freebsd.org/changeset/ports/566632 Log: Use kinfo_getfile() to implement fdwalk(). Previously, the kern.file sysctl (which queries the global file table) was queried and the results saved in an on-stack buffer. With a sufficiently active system the sysctl's output could overflow the stack's available space. Instead, switch to kinfo_getfile() from libutil. This uses a sysctl which queries only the open files for the current process, and it uses heap space instead of the stack to store the sysctl output. PR: 253602 Submitted by: ps (build glue patches) Reported by: ps Reviewed by: bapt MFH: 2021Q1 Differential Revision: https://reviews.freebsd.org/D28904 Added: head/devel/glib20/files/patch-glib_meson.build (contents, props changed) head/devel/glib20/files/patch-meson.build (contents, props changed) Modified: head/devel/glib20/Makefile head/devel/glib20/files/patch-glib_gspawn.c Modified: head/devel/glib20/Makefile ============================================================================== --- head/devel/glib20/Makefile Fri Feb 26 19:29:50 2021 (r566631) +++ head/devel/glib20/Makefile Fri Feb 26 19:31:04 2021 (r566632) @@ -3,6 +3,7 @@ PORTNAME= glib DISTVERSION= 2.66.7 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= devel MASTER_SITES= GNOME Modified: head/devel/glib20/files/patch-glib_gspawn.c ============================================================================== --- head/devel/glib20/files/patch-glib_gspawn.c Fri Feb 26 19:29:50 2021 (r566631) +++ head/devel/glib20/files/patch-glib_gspawn.c Fri Feb 26 19:31:04 2021 (r566632) @@ -1,64 +1,45 @@ ---- glib/gspawn.c 2018-09-21 12:29:23.000000000 +0300 -+++ glib/gspawn.c 2019-07-20 18:05:15.486558000 +0300 -@@ -51,6 +51,13 @@ +--- glib/gspawn.c.orig 2020-12-17 03:47:11.474608400 -0800 ++++ glib/gspawn.c 2021-02-17 13:58:15.271434000 -0800 +@@ -51,6 +51,12 @@ #include <sys/syscall.h> /* for syscall and SYS_getdents64 */ #endif +#ifdef __FreeBSD__ -+#include <sys/param.h> -+#include <sys/sysctl.h> ++#include <sys/types.h> +#include <sys/user.h> -+#include <sys/file.h> ++#include <libutil.h> +#endif + #include "gspawn.h" #include "gspawn-private.h" #include "gthread.h" -@@ -1204,6 +1211,51 @@ +@@ -1204,6 +1210,33 @@ filename_to_fd (const char *p) } #endif +#ifdef __FreeBSD__ +static int -+fdwalk2(int (*func)(void *, int), void *udata, int *ret) { -+ size_t i, bufsz = 0; -+ struct xfile *xfbuf, *xf; -+ int uret = 0, pid_found = 0; -+ int mib[2] = { CTL_KERN, KERN_FILE }; -+ pid_t pid; ++fdwalk2(int (*func)(void *, int), void *udata, gint *ret) ++{ ++ struct kinfo_file *kf; ++ int i, cnt; + + if (NULL == func) + return EINVAL; + -+ if (sysctl (mib, nitems(mib), NULL, &bufsz, NULL, 0) == -1) -+ return (errno); -+ bufsz += 65536; -+ xfbuf = alloca (bufsz); -+ if (xfbuf == NULL) -+ return errno; -+ if (sysctl (mib, 2, xfbuf, &bufsz, NULL, 0) == -1) -+ return errno; -+ bufsz /= sizeof(struct xfile); ++ kf = kinfo_getfile(getpid(), &cnt); ++ if (kf == NULL) ++ return ENOMEM; + -+ pid = getpid(); -+ for (i = 0; i < bufsz; i++) { -+ xf = &xfbuf[i]; -+ if (pid != xf->xf_pid) { -+ if (pid_found) { -+ return 0; -+ } else { -+ continue; -+ } -+ } -+ pid_found = 1; -+ if (0 > xf->xf_fd) ++ for (i = 0; i < cnt; i++) { ++ if (0 > kf[i].kf_fd) + continue; -+ uret = func (udata, xf->xf_fd); -+ if (uret != 0) ++ *ret = func (udata, kf[i].kf_fd); ++ if (*ret != 0) + break; -+ + } + ++ free(kf); + return 0; +} +#endif @@ -66,7 +47,7 @@ /* This function is called between fork() and exec() and hence must be * async-signal-safe (see signal-safety(7)). */ static int -@@ -1228,6 +1280,12 @@ +@@ -1228,6 +1261,12 @@ safe_fdwalk (int (*cb)(void *data, int fd), void *data #if 0 && defined(HAVE_SYS_RESOURCE_H) struct rlimit rl; Added: head/devel/glib20/files/patch-glib_meson.build ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/glib20/files/patch-glib_meson.build Fri Feb 26 19:31:04 2021 (r566632) @@ -0,0 +1,11 @@ +--- glib/meson.build.orig 2021-02-18 15:31:48.638470000 -0800 ++++ glib/meson.build 2021-02-18 15:32:08.983695000 -0800 +@@ -376,7 +376,7 @@ + # intl.lib is not compatible with SAFESEH + link_args : [noseh_link_args, glib_link_flags, win32_ldflags], + include_directories : configinc, +- dependencies : pcre_deps + [thread_dep, librt] + libintl_deps + libiconv + platform_deps + gnulib_libm_dependency + [libsysprof_capture_dep], ++ dependencies : pcre_deps + [thread_dep, librt] + libintl_deps + libiconv + platform_deps + gnulib_libm_dependency + [libsysprof_capture_dep] + libutil, + c_args : glib_c_args, + objc_args : glib_c_args, + ) Added: head/devel/glib20/files/patch-meson.build ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/glib20/files/patch-meson.build Fri Feb 26 19:31:04 2021 (r566632) @@ -0,0 +1,11 @@ +--- meson.build.orig 2021-02-11 04:24:55.280943200 -0800 ++++ meson.build 2021-02-18 15:34:48.476370000 -0800 +@@ -2287,6 +2287,8 @@ + test_timeout = 60 + test_timeout_slow = 180 + ++libutil = [cc.find_library('util', required : true)] ++ + pkg = import('pkgconfig') + windows = import('windows') + subdir('glib')