From patchwork Fri Oct 4 19:06:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1172026 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-510300-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DMfH6Fga"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rWEwpnBr"; 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 46lKBB19klz9sPL for ; Sat, 5 Oct 2019 05:07:11 +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; q=dns; s=default; b=DiMU0s7pGlDBYpRmNXfCnxNYdRk5lRWP9FesPgAOaX/lk+hWE2 tvtmGgCqj5O7rvGeGt7Xt4KkoTuMGvsMU+eosl7Tbi8SsudB3QAPfFL3uInluJIP YJWoCC5T5EKfuhCrdtqvtJKXMsv/bQnHnNRQwhah/DwlCVi7fYZvXEm6k= 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; s= default; bh=M2TqTOZZvHpHssPYvwRgD2s7K9E=; b=DMfH6FgaGs97J6mK0Dqz fpcNG2+hkFyn8fB/CeBfjcwaboT9RZefo1t+cfK/TZZVNoboldBy50SwzJH75h9G pn11VTOw3Y6WjuxvQS9JD4r+RgOeYhH0YqAJvA2F30ZEYPpgqUlmHqF67dcfeEL0 3XvYvWLuppGyBATkYpFAE4o= Received: (qmail 33227 invoked by alias); 4 Oct 2019 19:07:03 -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 33219 invoked by uid 89); 4 Oct 2019 19:07:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*r:500, H*r:10d, HX-Languages-Length:1906 X-HELO: mail-qt1-f172.google.com Received: from mail-qt1-f172.google.com (HELO mail-qt1-f172.google.com) (209.85.160.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 19:07:01 +0000 Received: by mail-qt1-f172.google.com with SMTP id c21so9940665qtj.12 for ; Fri, 04 Oct 2019 12:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=YBiQGditRTpUoK/p5YLtVZzBCr2RZS93JUfxTo6cveQ=; b=rWEwpnBrL7VD9ji1oqBrb2+t5/9tbd2DCyIW/YBlJley8tmD13zrCHTCXagbjJ9M4v vMlR6ye/2RoH6/o8f2sB3zrk6ai0RM68AnPyatIh5mXPeSId0QpKROJUZhdUo7wwlnD8 xvGAuxLY/TdQDu14AomAp7TIAMXc10OHiLQKnLpBQD3T0pZbeivwUOLzmjP4m41yc29O 1SNF6E4jbUoqiYFVXLyTdfPQVM6xZhR61d91yckagr82ShZ2c2i1RtbN47AZ098PTY2b 9JkBsyPPNfHiPlJxHavSbHKrrCWCrmaBtMCP4FazLN1bSJtqXUiWewhuJ/fb/rRV1T0I G7ag== Received: from ?IPv6:2620:10d:c0a3:1407:ed4f:88de:bea4:d214? ([2620:10d:c091:500::2:119e]) by smtp.googlemail.com with ESMTPSA id j17sm3116501qki.99.2019.10.04.12.06.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Oct 2019 12:06:58 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [preprocessor/91991] column location overflow Message-ID: Date: Fri, 4 Oct 2019 15:06:57 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 this patch fixes 91991. My fix for 91639 tickled a latent bug in the line map code. In that patch I set highest_line when linemap_line_start ran out of locations. But I did not clear max_column_hint. The latter's clearing is presumed by linemap_position_for_column. It was happily reporting a location that was in the macro range for a column after we'd run out of line numbers. And that led to the assert. this patch fixes linemap_line_start to: 1) when we run out of locations, set the max_column_hint to 1 2) record that max column hint on the failure path 3) make sure all failure paths go through a common exit block. With this patch I can compile the sqlite package in the PR. committing to trunk. nathan 2019-10-04 Nathan Sidwell PR preprocessor/91991 * line-map.c (linemap_line_start): Clear max_column_hint if we run out of locations. Index: libcpp/line-map.c =================================================================== --- libcpp/line-map.c (revision 276586) +++ libcpp/line-map.c (working copy) @@ -718,9 +718,9 @@ linemap_line_start (line_maps *set, line number of location_ts, give up on column numbers (and on packed ranges). */ - max_column_hint = 0; + max_column_hint = 1; column_bits = 0; range_bits = 0; if (highest >= LINE_MAP_MAX_LOCATION) - return 0; + goto overflowed; } else @@ -736,4 +736,5 @@ linemap_line_start (line_maps *set, line column_bits += range_bits; } + /* Allocate the new line_map. However, if the current map only has a single line we can sometimes just increase its column_bits instead. */ @@ -766,6 +767,9 @@ linemap_line_start (line_maps *set, line if (r >= LINE_MAP_MAX_LOCATION) { + overflowed: /* Remember we overflowed. */ set->highest_line = set->highest_location = LINE_MAP_MAX_LOCATION - 1; + /* No column numbers! */ + set->max_column_hint = 1; return 0; }