From patchwork Wed Sep 11 09:30:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1160851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-508827-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uNsU/O4P"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46SxTr6MFpz9s00 for ; Wed, 11 Sep 2019 19:30:54 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=wqAVH8m/fjBBYlvS /67+IdO/vUkyZWvQFzG+lIaRjpZ4Q/H0L9zNfUpxs/SpMD3vhc3FWB6CRftDwfMU EbSR0feteYISe1ZZuqE7oLTcWlXmhjoVtETSaBcIl0CX8VgCBUeB3Ffi4rW76xnD CA5Z18bG3iKtVWKDW2ZiB9fwN6k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=AeXrs0Ipsu5yThEZEe3vuD s1V/A=; b=uNsU/O4PLuvuwsGEUjWBMxMJRAp8tux0o3ZUD2PMF4kD6w5SWz8No7 robP+qjapwXu50xyyKQhmPHjHihyU4dknUp8DGAIY9+PyKFSVMtHEezW4RRPhxCk kGPyL1D+afIUBDDPl3ehyVBWqlyEM0UeAwZ+zxeMs702culTXdrl0= Received: (qmail 100480 invoked by alias); 11 Sep 2019 09:30:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 100442 invoked by uid 89); 11 Sep 2019 09:30:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=H*c:alternative X-HELO: esa1.mentor.iphmx.com Received: from esa1.mentor.iphmx.com (HELO esa1.mentor.iphmx.com) (68.232.129.153) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Sep 2019 09:30:37 +0000 IronPort-SDR: f8osKFnm3Id68VEGpZn+DmueB7WM/MlwGW7laZ0A+q5pJO7o2qwb/i9WNrybAzbkbLAb/w4wdh 67L+YV7ktuRu6l+6UC4MhF26rhDj5Ogte6y2iaUumDs/NZ4GvcuWEpTfaKoGibRprrjhDO/yyJ stpbjSYRKydn4lxVNxbxMMlin2kJP67c94WAsb2YP1Oid0N8eDtR0u83xIuTb2uxjIrj+wF7kJ Zi5xUwBw91EnoawXN2rcmSM6Nea+mRTfSQt09kxINgIdd72FqLAfyHgVpe2ipEx+3qC2RMKgS3 hYM= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 11 Sep 2019 01:30:34 -0800 IronPort-SDR: 9k3FCjFcb4zaqj4elsony5uhEVukYyGpac73vkBUjLP0hxnmaacz1C5ipuYv4+jUmy6ULAdoEq dPdnaQPhdeRfQvQFWouXOAt/ldRslLbkTIOR7DBp7dO3x6QsKxcx65OY2FEQFGPn6OC8kI0zrZ rnfkzfCU+KV+q7Z8ite8+8qM/OAY10bzY7+NaabJoYYlSJYSi1Nsx9bTJdLxYWR/QcrQaXbCgi W2r7lG3jZ+dIx9opVvwBGXc0tBNAEACZeZddeImp7DqRXQfbI2SOqGnRvPKEr2NZG1Pegi+qTZ g7Y= To: , Jakub Jelinek From: Tobias Burnus Subject: [patch, libgomp] Fix segfault with plugin-hsa Message-ID: Date: Wed, 11 Sep 2019 11:30:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Hi all, hi Jakub, when playing around with offloading, I got an hsa initialization error (/dev/... lacked write permission) and the library call returned with an error status – but hsa_fns.hsa_status_string_fn didn't set the message to the string variable. Hence, the string variable was uninitialized and libgomp crashed when printing the error message; "[unknown]" is not the best HSA run-time message, but at least the primary message is shown and there is no crash :-) Build and tested on x86_64-gnu-linux. OK for the trunk and GCC 9? Tobias 2019-09-11 Tobias Burnus * plugin/plugin-hsa.c (hsa_warn, hsa_fatal, hsa_error): Ensure string is initialized. diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c index 80f23f9beb6..c0837d04e5d 100644 --- a/libgomp/plugin/plugin-hsa.c +++ b/libgomp/plugin/plugin-hsa.c @@ -289,7 +289,7 @@ hsa_warn (const char *str, hsa_status_t status) if (!debug) return; - const char *hsa_error_msg; + const char *hsa_error_msg = "[unknown]"; hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); fprintf (stderr, "HSA warning: %s\nRuntime message: %s", str, hsa_error_msg); @@ -301,7 +301,7 @@ hsa_warn (const char *str, hsa_status_t status) static void hsa_fatal (const char *str, hsa_status_t status) { - const char *hsa_error_msg; + const char *hsa_error_msg = "[unknown]"; hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); GOMP_PLUGIN_fatal ("HSA fatal error: %s\nRuntime message: %s", str, hsa_error_msg); @@ -313,7 +313,7 @@ hsa_fatal (const char *str, hsa_status_t status) static bool hsa_error (const char *str, hsa_status_t status) { - const char *hsa_error_msg; + const char *hsa_error_msg = "[unknown]"; hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); GOMP_PLUGIN_error ("HSA fatal error: %s\nRuntime message: %s", str, hsa_error_msg);