From common-commits-return-77972-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Wed Jan 24 23:35:47 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 2107018076D for ; Wed, 24 Jan 2018 23:35:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 11946160C50; Wed, 24 Jan 2018 22:35:47 +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 643DA160C39 for ; Wed, 24 Jan 2018 23:35:46 +0100 (CET) Received: (qmail 87636 invoked by uid 500); 24 Jan 2018 22:35:33 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 86998 invoked by uid 99); 24 Jan 2018 22:35:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jan 2018 22:35:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E5694F4E04; Wed, 24 Jan 2018 22:35:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aengineer@apache.org To: common-commits@hadoop.apache.org Date: Wed, 24 Jan 2018 22:36:14 -0000 Message-Id: In-Reply-To: <449ff7436d854b3e8bafac8efec3974b@git.apache.org> References: <449ff7436d854b3e8bafac8efec3974b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [45/50] [abbrv] hadoop git commit: YARN-7796. Container-executor fails with segfault on certain OS configurations. Contributed by Gergo Repas. YARN-7796. Container-executor fails with segfault on certain OS configurations. Contributed by Gergo Repas. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/e7642a3e Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e7642a3e Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e7642a3e Branch: refs/heads/HDFS-7240 Commit: e7642a3e6f540b4b56367babfbaf35ee6b3c7675 Parents: 95743c6 Author: Miklos Szegedi Authored: Tue Jan 23 21:07:05 2018 -0800 Committer: Miklos Szegedi Committed: Tue Jan 23 21:07:05 2018 -0800 ---------------------------------------------------------------------- .../impl/container-executor.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/e7642a3e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c index b0b8e76..5ce6a00 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c @@ -1008,13 +1008,20 @@ static int open_file_as_nm(const char* filename) { static int copy_file(int input, const char* in_filename, const char* out_filename, mode_t perm) { const int buffer_size = 128*1024; - char buffer[buffer_size]; + char* buffer = malloc(buffer_size); + if (buffer == NULL) { + fprintf(LOGFILE, "Failed to allocate buffer while copying file: %s -> %s", + in_filename, out_filename); + fflush(LOGFILE); + return -1; + } int out_fd = open(out_filename, O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, perm); if (out_fd == -1) { fprintf(LOGFILE, "Can't open %s for output - %s\n", out_filename, strerror(errno)); fflush(LOGFILE); + free(buffer); return -1; } @@ -1024,15 +1031,18 @@ static int copy_file(int input, const char* in_filename, while (pos < len) { ssize_t write_result = write(out_fd, buffer + pos, len - pos); if (write_result <= 0) { - fprintf(LOGFILE, "Error writing to %s - %s\n", out_filename, - strerror(errno)); - close(out_fd); - return -1; + fprintf(LOGFILE, "Error writing to %s - %s\n", out_filename, + strerror(errno)); + close(out_fd); + free(buffer); + return -1; } pos += write_result; } len = read(input, buffer, buffer_size); } + free(buffer); + if (len < 0) { fprintf(LOGFILE, "Failed to read file %s - %s\n", in_filename, strerror(errno)); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org