Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 08149200D24 for ; Tue, 24 Oct 2017 23:20:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0664D1609C8; Tue, 24 Oct 2017 21:20:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 26F7B160BDB for ; Tue, 24 Oct 2017 23:20:07 +0200 (CEST) Received: (qmail 58173 invoked by uid 500); 24 Oct 2017 21:20:06 -0000 Mailing-List: contact mapreduce-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list mapreduce-issues@hadoop.apache.org Received: (qmail 58162 invoked by uid 99); 24 Oct 2017 21:20:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Oct 2017 21:20:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 6C5F01A03C8 for ; Tue, 24 Oct 2017 21:20:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id R--A5E6Vcv32 for ; Tue, 24 Oct 2017 21:20:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 8FDBB60E26 for ; Tue, 24 Oct 2017 21:20:03 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 58D6EE2654 for ; Tue, 24 Oct 2017 21:20:02 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 246742131D for ; Tue, 24 Oct 2017 21:20:01 +0000 (UTC) Date: Tue, 24 Oct 2017 21:20:01 +0000 (UTC) From: "Ting Dai (JIRA)" To: mapreduce-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (MAPREDUCE-6990) FileInputStream.skip function can return 0 when the file is corrupted, causing an infinite loop MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 24 Oct 2017 21:20:08 -0000 [ https://issues.apache.org/jira/browse/MAPREDUCE-6990?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ting Dai updated MAPREDUCE-6990: -------------------------------- Description: When file is corrupted, for example, bad encoding, [Yarn-2724](https://issues.apache.org/jira/browse/YARN-2724), the FileInputStream can return 0, causing the while loop in TaskLog$Reader become infinite. {code:java} public Reader(TaskAttemptID taskid, LogName kind, long start, long end, boolean isCleanup) throws IOException { // find the right log file LogFileDetail fileDetail = getLogFileDetail(taskid, kind, isCleanup); // calculate the start and stop long size = fileDetail.length; if (start < 0) { start += size + 1; } if (end < 0) { end += size + 1; } start = Math.max(0, Math.min(start, size)); end = Math.max(0, Math.min(end, size)); start += fileDetail.start; end += fileDetail.start; bytesRemaining = end - start; String owner = obtainLogDirOwner(taskid); file = SecureIOUtils.openForRead(new File(fileDetail.location, kind.toString()), owner, null); // skip upto start long pos = 0; while (pos < start) { long result = file.skip(start - pos); if (result < 0) { bytesRemaining = 0; break; } pos += result; } } {code} Similar bugs are [Hadoop-8614](https://issues.apache.org/jira/browse/HADOOP-8614), [Yarn-2905](https://issues.apache.org/jira/browse/YARN-2905) was: When file is corrupted, for example, bad encoding, [Yarn-2724](https://issues.apache.org/jira/browse/YARN-2724), the FileInputStream can return 0, causing the while loop in TaskLog$Reader become infinite. {code:java} // Some comments here public Reader(TaskAttemptID taskid, LogName kind, long start, long end, boolean isCleanup) throws IOException { // find the right log file LogFileDetail fileDetail = getLogFileDetail(taskid, kind, isCleanup); // calculate the start and stop long size = fileDetail.length; if (start < 0) { start += size + 1; } if (end < 0) { end += size + 1; } start = Math.max(0, Math.min(start, size)); end = Math.max(0, Math.min(end, size)); start += fileDetail.start; end += fileDetail.start; bytesRemaining = end - start; String owner = obtainLogDirOwner(taskid); file = SecureIOUtils.openForRead(new File(fileDetail.location, kind.toString()), owner, null); // skip upto start long pos = 0; while (pos < start) { long result = file.skip(start - pos); if (result < 0) { bytesRemaining = 0; break; } pos += result; } } {code} Similar bugs are [Hadoop-8614](https://issues.apache.org/jira/browse/HADOOP-8614), [Yarn-2905](https://issues.apache.org/jira/browse/YARN-2905) > FileInputStream.skip function can return 0 when the file is corrupted, causing an infinite loop > ----------------------------------------------------------------------------------------------- > > Key: MAPREDUCE-6990 > URL: https://issues.apache.org/jira/browse/MAPREDUCE-6990 > Project: Hadoop Map/Reduce > Issue Type: Bug > Affects Versions: 0.23.0 > Reporter: Ting Dai > > When file is corrupted, for example, bad encoding, [Yarn-2724](https://issues.apache.org/jira/browse/YARN-2724), the FileInputStream can return 0, causing the while loop in TaskLog$Reader become infinite. > {code:java} > public Reader(TaskAttemptID taskid, LogName kind, long start, long end, boolean isCleanup) throws IOException { > // find the right log file > LogFileDetail fileDetail = getLogFileDetail(taskid, kind, isCleanup); > // calculate the start and stop > long size = fileDetail.length; > if (start < 0) { > start += size + 1; > } > if (end < 0) { > end += size + 1; > } > start = Math.max(0, Math.min(start, size)); > end = Math.max(0, Math.min(end, size)); > start += fileDetail.start; > end += fileDetail.start; > bytesRemaining = end - start; > String owner = obtainLogDirOwner(taskid); > file = SecureIOUtils.openForRead(new File(fileDetail.location, kind.toString()), owner, null); > // skip upto start > long pos = 0; > while (pos < start) { > long result = file.skip(start - pos); > if (result < 0) { > bytesRemaining = 0; > break; > } > pos += result; > } > } > {code} > Similar bugs are [Hadoop-8614](https://issues.apache.org/jira/browse/HADOOP-8614), [Yarn-2905](https://issues.apache.org/jira/browse/YARN-2905) -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: mapreduce-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: mapreduce-issues-help@hadoop.apache.org