From nobody Fri Jul 28 22:47:51 2023 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 4RCN7r1vFLz4pPyf for ; Fri, 28 Jul 2023 22:47:52 +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 4RCN7r0tHkz3DQg for ; Fri, 28 Jul 2023 22:47:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690584472; 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: in-reply-to:in-reply-to:references:references; bh=etrtnL/7+c1fMakOc9OHwuP8y44GHsbxDS2NrrHI1LQ=; b=RA3Qu0wQB3v+QVUYWhgbL4RoNQalYRE55ASV8wide5MGSn73yFfkr+lmJgT5/jN+Rf1Qld 24PqcUBQ93r8QDqtMLBWIzI6fm1MvdWuHdfGpFEgI2SQO+hmHT9YOhwiixrub9HdexCyJQ GR709LiizJd7QDsLO7R+6rExc1EE+bkpxmAZsMFlVArNsYg8uvdi/zKOy/SKIh66wSlMN6 ryB4YxnF5KjfQ1SkawFTaN36ZXJTNaEr91MD7Akuke0ZfuoD5q71kG8A/+ArGuJiKrBF3n NUQ4xaRpdtbUi85xx9WpQ6KQHEAc1M1itJk9D8T0jOk9pmPz1uGHDW3VpqlvBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690584472; a=rsa-sha256; cv=none; b=ykH9WvxCrgAduFZ3Gps20+7hNabcCaUoNud+DIl0KLck2KFzaPXeFikwMcj9KKAb/PcZO8 vidKmLjJ6fCUVWqmuZfsyTvjegOKakwVQhAqj48ZB/43hx3edc/Rrs8zGo6o34xADCRwAQ C3yHlP9JGRJA2doPy7EljSbKSUx2Q+Q7HUtsutmZvRQJ8vGUJUxU4FXrWhe2MUNGJitLHR 9MwbtZ+Jhx8yBh2qurZuBe6t25cWsdSRXrsPfDrPkRkIWH9+h+0a1zhWvJH0Q1lSJK/E0t QL2mqGSm2SQMfwP6Y4VewYMboHBg5YZWuta6mdbX+ScxBOBtk6p6pAkqgSLgyQ== 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 4RCN7q74KXz183r for ; Fri, 28 Jul 2023 22:47:51 +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 36SMlp5d060486 for ; Fri, 28 Jul 2023 22:47:51 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 36SMlpx8060484 for bugs@FreeBSD.org; Fri, 28 Jul 2023 22:47:51 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 258559] tcsh can crash in morecore() due to 32-bit arithmetic Date: Fri, 28 Jul 2023 22:47:51 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed 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 Only Me X-Bugzilla-Who: jhb@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: jhb@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc assigned_to Message-ID: In-Reply-To: References: 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 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D258559 John Baldwin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jhb@FreeBSD.org Assignee|bugs@FreeBSD.org |jhb@FreeBSD.org --- Comment #1 from John Baldwin --- Hmm, for me I don't get a crash but instead the system eventually runs out = of swap. This code is indeed buggy and fraught with peril, but it also uses sbrk() which is a deprecated interface on FreeBSD (it's not even present in newer architectures: arm64 and riscv64). [t]csh from the base system shoul= d be built with SYSMALLOC defined so that tcsh uses the malloc() from libc inste= ad of the version from tc.alloc.c. You can verify this by checking for the st= ring ",sm" in the $version variable from tcsh. For example: > echo $version tcsh 6.22.04 (Astron) 2021-04-26 (x86_64-amd-FreeBSD) options wide,nls,dl,al,kan,sm,rh,color,filec Checking in a 12.x jail I had lying around shows ",sm" in $version as well,= and the most recent change to bin/csh/config.h related to this was made in 2007: commit 59dfb2db03584859a57ab6d9519e2de147bf3c4d Author: Mark Peek Date: Wed May 16 21:22:38 2007 +0000 Work around a vendor issue that was causing the builtin malloc to be used instead of the system malloc. Submitted by: ume Notes: svn path=3D/head/; revision=3D169626 diff --git a/bin/csh/config.h b/bin/csh/config.h index c9b01ef7aa94..0971ffa3faa1 100644 --- a/bin/csh/config.h +++ b/bin/csh/config.h @@ -237,3 +237,6 @@ #ifndef NO_NLS_CATALOGS #define NLS_CATALOGS #endif + +/* Work around a vendor issue where config_f.h is #undef'ing this setting = */ +#define SYSMALLOC diff --git a/bin/csh/config_p.h b/bin/csh/config_p.h index 6de288b387e5..8c29053e3176 100644 --- a/bin/csh/config_p.h +++ b/bin/csh/config_p.h @@ -82,8 +82,6 @@ #if defined(__FreeBSD__) #define NLS_BUGS #define BSD_STYLE_COLORLS -/* we want to use the system malloc when we install as /bin/csh */ -#define SYSMALLOC /* Use LC_MESSAGES locale category to open the message catalog */ #define MCLoadBySet NL_CAT_LOCALE #define BUFSIZE 8192 So I'm surprised you would have a tcsh binary on a 13.0 system that was usi= ng the malloc() implementation from tc.alloc.c rather than the libc allocator. I do think it's true that if you checkout the raw tcsh sources from upstream and build them that it still defaults to using tc.alloc.c. If that is the = way you built tcsh then a patch to tcsh itself to adjust these lines in the upstream config_f.h would work: /* * SYSMALLOC Use the system provided version of malloc and friends. * This can be much slower and no memory statistics will be * provided. */ #if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__) || defined (__CYGWIN__) || defined(__GLIBC__) || defined(__OpenBSD__) || defined(__APPLE__) || defined (__ANDROID__) # define SYSMALLOC #else # undef SYSMALLOC #endif IMO, upstream tcsh would be better served by just always assuming SYSMALLOC= and dropping its own allocator as it is unlikely to be better than the system malloc on any contemporary OSs. --=20 You are receiving this mail because: You are the assignee for the bug.=