Bug 107818 - Overflow of linemap breaks its chronological order
Summary: Overflow of linemap breaks its chronological order
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-22 15:01 UTC by Feng Xue
Modified: 2023-02-23 18:14 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Feng Xue 2022-11-22 15:01:31 UTC
Large-size source codes might exceed representation space of linemap. When this happens, UNKNOWN_LOCATION(0) would inserted to the end of linemap. And the action breaks the order constraint on the map, which requires all logical locations contained by it should remain chronologically-ordered, so that binary search could be used.(Comments in linemap_ordinary_map_lookup).


In the function "linemap_add":

  ...

  if (start_location >= LINE_MAP_MAX_LOCATION)
    /* We ran out of line map space.   */
    start_location = 0;

  line_map_ordinary *map
    = linemap_check_ordinary (new_linemap (set, start_location));
                              ^^^^^^^^^^^
                              UNKNOWN_LOCATION(0) is also added to linemap
  map->reason = reason;
  ...


Afterwards, logical location to source line would be mis-translated.

pr86872 only partially fixed see-able ICE due to linemap overflow, but made a this hidden issue.
Comment 1 Andrew Pinski 2023-02-23 18:14:44 UTC
include/line-map.h:const location_t LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000;
include/line-map.h:const location_t LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000;
include/line-map.h:const location_t LINE_MAP_MAX_LOCATION = 0x70000000;