From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.1 required=3.0 tests=BAYES_00,DKIM_ADSP_NXDOMAIN, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD, SPF_PASS,T_DKIM_INVALID shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 7FBE7202DD for ; Fri, 14 Jul 2017 09:29:17 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 1D269120802; Fri, 14 Jul 2017 18:29:15 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id B6DE11207F8 for ; Fri, 14 Jul 2017 18:29:12 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=ZB4JPPg7IA1Py3PS2QTrng6OgO0=; b=oYhzAnwS70UxpO/bWR 1S8FvSpmY1gQ1sO51teyHgfOk40CMuOKSkayNoHbBWyzIgfw/8TM/hugoQo/qLeR JxInhI92echXN2k1o+GjU5RKnZqhUS/Z8PefEv0e7T8oZWO+4ioLx/DsujCQg4jV evxzAuBwkQeExQRtIYhRis3vk= Received: by filter0464p1mdw1.sendgrid.net with SMTP id filter0464p1mdw1-24583-59688EDA-3 2017-07-14 09:28:58.043001964 +0000 UTC Received: from herokuapp.com (ec2-54-235-63-38.compute-1.amazonaws.com [54.235.63.38]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id t7kORm3GRu6TiAJ_vPk56A for ; Fri, 14 Jul 2017 09:28:58.036 +0000 (UTC) Date: Fri, 14 Jul 2017 09:28:58 +0000 (UTC) From: naruse@airemix.jp To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 57103 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13654 X-Redmine-Issue-Author: charles.cooke X-Redmine-Issue-Assignee: keiju X-Redmine-Sender: naruse X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6hESVpC0XfM+YoeAb/MvpqKiGLuSKBHzfSy7 NthoUpdY0HilMd10dDuPLI2t31wSFje2A4bzv8Fw3K9y6/pMlEG+tC1gJSclP2vhk5zGCAPkLU5I73 QOd/isIGiER2acFTpXcsmRSYTZPMmSQoJj4S2+f7MuMJv6XTWk+H07vgmA== X-ML-Name: ruby-core X-Mail-Count: 82064 Subject: [ruby-core:82064] [Ruby trunk Bug#13654][Assigned] irb save-history extension is not concurrency-safe X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #13654 has been updated by naruse (Yui NARUSE). Status changed from Open to Assigned Assignee set to keiju (Keiju Ishitsuka) ---------------------------------------- Bug #13654: irb save-history extension is not concurrency-safe https://bugs.ruby-lang.org/issues/13654#change-65798 * Author: charles.cooke (Charles Cooke) * Status: Assigned * Priority: Normal * Assignee: keiju (Keiju Ishitsuka) * Target version: * ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- ## Issue If 2 simultaneous irb sessions are running with save-history enabled, the history will be overwritten in full by the last irb session to exit and history will be lost. The save-history extension currently loads the existing file on session start, maintains history throughout the session, then regenerates the history file with the preloaded + new history from the current session. Therefore if the file contents are changed while the irb session is running, those changes are not overwritten when the session exits. As many systems have logrotate and could manage the file buffering independently, one idea would be to just append the history from current session, rather than recreating the history file. ## Steps to reproduce 1. Enable the save-history extension to log to a file 1. Start an irb session (Session #1) 1. Start a second irb session (Session #2) 1. In Session #1, execute commands and exit - verify that the output is generated correctly 1. In Session #2, execute commands and exit - PROBLEM - the output from Session #1 has been deleted See output below: ~~~ [current]$ cat .irbrc require 'irb/ext/save-history' IRB.conf[:SAVE_HISTORY] = 1000 IRB.conf[:HISTORY_FILE] = File.join(Dir.pwd, 'log', 'irb.log') ==== START SESSION #1# ==== [current]$ irb irb(main):001:0> puts 'Session #1 - Output' Session #1 - Output => nil irb(main):002:0> [1]+ Stopped irb ==== BACKGROUND SESSION #1# ==== ==== START SESSION #2# ==== [current]$ irb irb(main):001:0> puts 'Session #2 - Output' Session #2 - Output => nil irb(main):002:0> exit ==== STOP SESSION #2# ==== ==== OUTPUT IS EXPECTED ==== [current]$ cat log/irb.log puts 'Session #2 - Output' exit ==== RESUME SESSION #1 ==== [current]$ fg irb(main):003:0* puts 'Session #1 - Overwrites everything' Session #1 - Overwrites everything => nil irb(main):004:0> exit ==== PROBLEM - OUTPUT FROM SESSION #1 ONLY ==== [current]$ cat log/irb.log puts 'Session #1 - Output' puts 'Session #1 - Overwrites everything' exit ~~~ -- https://bugs.ruby-lang.org/