From owner-freebsd-current@freebsd.org Sun Jan 31 09:53:28 2021 Return-Path: Delivered-To: freebsd-current@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 78F0B4EA758 for ; Sun, 31 Jan 2021 09:53:28 +0000 (UTC) (envelope-from rozhuk.im@gmail.com) Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DT5xM3Bb6z4qMw for ; Sun, 31 Jan 2021 09:53:27 +0000 (UTC) (envelope-from rozhuk.im@gmail.com) Received: by mail-lj1-x22a.google.com with SMTP id r14so15795642ljc.2 for ; Sun, 31 Jan 2021 01:53:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:subject:message-id:mime-version :content-transfer-encoding; bh=FGgyNkNeDj5RivuKpWPM6MxSo87A1ZfvsxdsOm3Hq7I=; b=ud7lJQ89bQ1R0vTTpL8uxSyFiqJ3LkOlRN8elwOZ8ZI4uARCexXCPLhcCfkPdl0aZ7 nYoUopV9p2uRHgSyEDS8TyPif5/R97unzmWXMA4TdslrlpEO9CMq7wYgCm1as2N4Ho05 TthNyleihdbryXE9SEJqqASYVzA6atkuUjSYcugUKnrUvrlN1gkkJ2Ug5rjVrzva12wW FFbExpDzIEfk9+WVhhiw/jBw16msSu7b5bgCj6Ma1e7Og8nNOCEn61Wi3r3CQCRIZvZP qjkrFFodG5FNIZm4S/FeREi9sk5ScN/lAb/CAx+x0HeZMe1WujvECsaB/qQbF4lLcKYQ TsYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:subject:message-id:mime-version :content-transfer-encoding; bh=FGgyNkNeDj5RivuKpWPM6MxSo87A1ZfvsxdsOm3Hq7I=; b=lWuodznuD8chxEnM5t6LayE23WyOgS7XlS3ezNYnpa4QFubgNb8ADHY/UHYYZ+DVj9 xbi3GNzk20mVo2OFjrb6RIx7WeK+5KJSbzq7zAMdlrt0jehBdf7ihVPxbI58zVmyYKb/ NPsYqVFO8EjHEnLkKa/YQu2qu0CKE4iT8p2YO8SIrw6L9FgaZdk8AAccT+xYe+/G8GXO ZSxlH5uQKwPWO3v6p9yYNr0KN0tlpKs4DWLo5Ul3p6DUdAv5txgPEOR4+aCsBGLZyIKB VJLEZzjzJduSYQM36iO8EjS6d+tl3k4yAZuJqkavM1WhgI4zM6eIbkUiS1tyBqYCArZN OHeg== X-Gm-Message-State: AOAM5317nzXEHYkB+Z+r2FKMWflfGJUd2eK+tECMj5rLNR4LiFnOp1TZ nLMjwIMO+YKPV6vUSETIDbNk5gau7QM= X-Google-Smtp-Source: ABdhPJwK1pVXhRgdL5hgL3IMSSYizvxx7aAv3HkPDqD2xiDK5NRwFQVP5UPMOPSMVfD16KhDt5EAgg== X-Received: by 2002:a2e:89cb:: with SMTP id c11mr7108007ljk.98.1612086804731; Sun, 31 Jan 2021 01:53:24 -0800 (PST) Received: from rimwks.local ([2001:470:1f15:3d8:7285:c2ff:fe37:5722]) by smtp.gmail.com with ESMTPSA id p17sm3315353ljj.91.2021.01.31.01.53.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Jan 2021 01:53:24 -0800 (PST) From: Rozhuk Ivan X-Google-Original-From: Rozhuk Ivan Date: Sun, 31 Jan 2021 12:53:22 +0300 To: freebsd-current@freebsd.org Subject: tcsh hang on exit Message-ID: <20210131125322.34d6c52a@rimwks.local> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; amd64-portbld-freebsd13.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4DT5xM3Bb6z4qMw X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=ud7lJQ89; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rozhukim@gmail.com designates 2a00:1450:4864:20::22a as permitted sender) smtp.mailfrom=rozhukim@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-0.999]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::22a:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::22a:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::22a:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-current] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Jan 2021 09:53:28 -0000 Hi! http://bsd.pw/scale_slides.pdf p 28 recomends add to ~/.tcshrc: set savehist = (99999999 merge lock) I use this for a while, but some time ago found that after term close csh hangs. Term close - close xfce4-terminal by X bytton. Exit in terminal - does not trigger issue. Reproduce: Add/set in ~/.cshrc: set savehist = (99999999 merge lock) Open and close terminal with tsch shell. Run top -aSCI -m io to ensure that csh writes to disk. (13+ only) ~/.history.lock exist, csh process continue running. Truss show infinite loop: ... 78009: link("/home/rim/.rimwks.local.90dc6","/home/rim/.history.lock") ERR#17 'File exists' 78009: unlink("/home/rim/.rimwks.local.90dc6") = 0 (0x0) 78009: sigprocmask(SIG_SETMASK,{ },0x0) = 0 (0x0) 78009: nanosleep({ 0.100000000 }) = 0 (0x0) 78009: sigprocmask(SIG_BLOCK,{ SIGHUP|SIGINT|SIGQUIT|SIGTERM|SIGTSTP|SIGCHLD|SIGTTIN|SIGTTOU },{ }) = 0 (0x0) 78009: __sysctl("kern.hostname",2,0x7fffffffb8a0,0x7fffffffb348,0x0,0) = 0 (0x0) 78009: getpid() = 78009 (0x130b9) 78009: openat(AT_FDCWD,"/home/rim/.rimwks.local.b5e4e",O_WRONLY|O_FSYNC|O_CREAT|O_TRUNC|O_EXCL,00) = 0 (0x0) 78009: close(0) = 0 (0x0) 78009: link("/home/rim/.rimwks.local.b5e4e","/home/rim/.history.lock") ERR#17 'File exists' 78009: unlink("/home/rim/.rimwks.local.b5e4e") = 0 (0x0) 78009: sigprocmask(SIG_SETMASK,{ },0x0) = 0 (0x0) 78009: nanosleep({ 0.100000000 }) = 0 (0x0) 78009: sigprocmask(SIG_BLOCK,{ SIGHUP|SIGINT|SIGQUIT|SIGTERM|SIGTSTP|SIGCHLD|SIGTTIN|SIGTTOU },{ }) = 0 (0x0) 78009: __sysctl("kern.hostname",2,0x7fffffffb8a0,0x7fffffffb348,0x0,0) = 0 (0x0) 78009: getpid() = 78009 (0x130b9) 78009: openat(AT_FDCWD,"/home/rim/.rimwks.local.d0437",O_WRONLY|O_FSYNC|O_CREAT|O_TRUNC|O_EXCL,00) = 0 (0x0) 78009: close(0) = 0 (0x0) 78009: link("/home/rim/.rimwks.local.d0437","/home/rim/.history.lock") ERR#17 'File exists' 78009: unlink("/home/rim/.rimwks.local.d0437") = 0 (0x0) 78009: sigprocmask(SIG_SETMASK,{ },0x0) = 0 (0x0) ... This stop only after I remove empty .history.lock or kill process. Reprodused on 12.2 and 13. amd64. On 13 it causes disk writes with ~2mb/sec per csh process, on 12.2 no disk writes. I have try use "truss -fp PID" to understand what goes wrong, but every time I connect truss before exit/term close - issue does not happen. contrib/tcsh/dotlock.c - code looks simple, and I suspect that some race condition in kernel exist that causes fail at this code: if (st.st_nlink != 2) { then it run first time on process exit, in next time code fails on link - file already exist. I try to reproduce this in small test app, by copy-paste code from contrib/tcsh/dotlock.c but no errors happen and st_nlink == 2. My second version that tcsh do something unusual with signal handling and truss revert it back. 1. Does some one expect same issue/can reproduse it? 2. I have mounted ".eli on /home/rim (ufs, local, noatime, nosuid, soft-updates)", is it OK that FreeBSD 13 write/flush to often/on every file create/delete and FreeBSD 12.2 does not? 3. If I do not use lock option then no chs hang on exit, but if terminal closed without exit file .history.1583640 (diff nums) created. Is any work around for this?