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=-3.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_DKIM_INVALID, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham 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 C54381FA7B for ; Tue, 13 Jun 2017 13:17:18 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 9161A120787; Tue, 13 Jun 2017 22:17:15 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 3315E120784 for ; Tue, 13 Jun 2017 22:17: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=Rn9WRpjX6/Hljtt+VeTBA5eQSAI=; b=Mo/HtqGFTalweSuZ7T a+114+RaK7KzIUCdszNYO0M94vYtJz7aTVBK2t5ISUEyLrsXgq/l5kZD+Zrzs5jQ 3rNWikbJxtqfsUqccULK8WG2j3oe7GuFPqguoYyzBA0GN+r205M9ZivZxNfPcgeN 9VzuMOh9pAsp4pv12UxCZVdu8= Received: by filter0940p1mdw1.sendgrid.net with SMTP id filter0940p1mdw1-6999-593FE5D5-2A 2017-06-13 13:17:09.450657204 +0000 UTC Received: from herokuapp.com (ec2-54-226-42-236.compute-1.amazonaws.com [54.226.42.236]) by ismtpd0003p1iad1.sendgrid.net (SG) with ESMTP id V1GV_69TRYe6SVnLnucrUQ for ; Tue, 13 Jun 2017 13:17:09.377 +0000 (UTC) Date: Tue, 13 Jun 2017 13:17:09 +0000 From: charles.cooke@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 56690 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13654 X-Redmine-Issue-Author: charles.cooke X-Redmine-Sender: charles.cooke 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS52ZfHA1+gGlwK0LW48g/mUFlrwInSW4gRi0Z NC3oW9rd7l5Jg0uWm6kgHVt1xSXuDDsNmoKpHNh3MpSq6Zuk7yAKb0I+W41wXl/VbTxsAol/py9Wnr v+wEuY7Sc+HAFffPTEP3Va8Icmb9vmPQroCjdm1kV5CaZg3H938aLVdzEw== X-ML-Name: ruby-core X-Mail-Count: 81661 Subject: [ruby-core:81661] [Ruby trunk Bug#13654] 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 reported by charles.cooke (Charles Cooke). ---------------------------------------- Bug #13654: irb save-history extension is not concurrency-safe https://bugs.ruby-lang.org/issues/13654 * Author: charles.cooke (Charles Cooke) * Status: Open * Priority: Normal * Assignee: * 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/