From nobody Thu Dec 2 16:46:03 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CB3FE18BE9E7 for ; Thu, 2 Dec 2021 16:46:03 +0000 (UTC) (envelope-from bugzilla-noreply@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 4J4hfg374wz4f4Q for ; Thu, 2 Dec 2021 16:46:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4737920C21 for ; Thu, 2 Dec 2021 16:46:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1B2Gk3V5009666 for ; Thu, 2 Dec 2021 16:46:03 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1B2Gk3Va009665 for bugs@FreeBSD.org; Thu, 2 Dec 2021 16:46:03 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 260174] libprocstat's i386 procstat_getfiles() fails on amd64 Date: Thu, 02 Dec 2021 16:46:03 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 13.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: damjan.jov@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638463563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Vksm94FbMT/GgaADOblk422CrVJHSdd/jRBWhx52Bm4=; b=Oqlym3RQHhDM9Tq37nJwWcjH2wALKnSON819RrA8mY7Vxk2h4NKD4tYNnx2d1Z0eTUWloK lu5l/TN+5PKKfEL0Uk5mVttyYOzWismsgE00qnRBuZBkhKwe0l+oGY8YQXLrYI6EGmFRrY uYPdoiOP+cmDsTA/vVMi7otLQFMjeX4CCdlpA09aXYKLo+bthjOeV3e/pWMO7uduCBx3mG iddcss5kvdxHDMI4Ko9XptrNcaxqum17mC3V337zAdaiZa+ZDdCPTnOtPbu6n+CMzkl0pV oE7drdtf0C1eC5wi9tCnmh5gPaEWKrcLxqpqndsT8DF65hEAL/sSxpbGnrdXlQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638463563; a=rsa-sha256; cv=none; b=yg3i5CmqNFLGS7ansnQLtiMYMlP6pGvF2W732BqEAk6tYs5nNTleHDnoB6U4+x7q8VJAe3 V0Soez6BLE/VgTK+VaI3IH4IFQ3RK7t8CHcFV6FoYPoi3NDM3ycAl230TbjnxmT3iIElzV rlCC3BaTVJMNKnw/JDlpmwwCK+yuvytVy10+n4LbIQSL2HJ03Mte+YDoZ9v+Zh/9TxwoPB PKfuTGHg0LQd2eXAYMOQQMgyTtHWPFXBQvnjW1tCCtG7rUPygvpqW3SFRTlAKWKp8A5XnQ 97AVDK5FkNDb/Qiv0g1Ch2fjkLw/GGEWzFGqKlUanzAX0UX3C74Pla2QdpCQIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260174 Bug ID: 260174 Summary: libprocstat's i386 procstat_getfiles() fails on amd64 Product: Base System Version: 13.0-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: damjan.jov@gmail.com An i386 binary calling procstat_getfiles() on amd64 always gets NULL return= ed and errno=3D=3D0, even though libutil's kinfo_getfile() works. The same cod= e built as an amd64 binary works with both. I don't like procstat_getfiles() anyway, and won't be using it, at almost 1 millisecond per call it's ridiculously slow, and its linked list is less us= eful and costlier to build than kinfo_getfile()'s array. Just thought it would be good to document this issue for others that run into it. cc -m32 file.c -o proctest -lprocstat #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { struct procstat *procstat =3D NULL; unsigned int count; struct kinfo_proc *kp =3D NULL; struct filestat_list *files =3D NULL; struct filestat *fs =3D NULL; char *ret =3D NULL; printf("starting...\n"); procstat =3D procstat_open_sysctl(); if (!procstat) { fprintf(stderr, "couldn't open procstat\n"); goto end; } printf("opened procstat\n"); kp =3D procstat_getprocs( procstat, KERN_PROC_PID, getpid(), &count ); if (!kp || count !=3D 1) { fprintf(stderr, "getprocs failed\n"); goto end; } printf("got proc, now looking up files...\n"); files =3D procstat_getfiles( procstat, kp, 0 ); if (!files) { fprintf(stderr, "getfiles failed, errno %d\n", errno); goto end; } STAILQ_FOREACH( fs, files, next ) { printf("%d -> %s\n", fs->fs_fd, fs->fs_path); } end: return 0; } --=20 You are receiving this mail because: You are the assignee for the bug.=