Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: compiler hang in resolve pass #26376

Open
cassella opened this issue Dec 7, 2024 · 0 comments
Open

[Bug]: compiler hang in resolve pass #26376

cassella opened this issue Dec 7, 2024 · 0 comments

Comments

@cassella
Copy link
Contributor

cassella commented Dec 7, 2024

Summary of Problem

Description:

The compiler hangs compiling this reduced reproducer.

This happens with and without LLVM. With --print-passes, it hangs for at least a minute here, increasing its memory consumption by ~150MB/s:

Timing for driver compilation phase
--------------
                            init :   0.004 seconds  [      297]
             parseAndConvertUast :   9.574 seconds  [   327183]
               checkGeneratedAst :   0.075 seconds  [   327183]
                     readExternC :   0.007 seconds  [   327183]
          expandExternArrayCalls :   0.008 seconds  [   327183]
                         cleanup :   0.101 seconds  [   328273]
                    scopeResolve :   1.077 seconds  [   392047]
                  flattenClasses :   0.008 seconds  [   392047]
                       normalize :   1.126 seconds  [   824078]
                 checkNormalized :   0.022 seconds  [   824078]
           buildDefaultFunctions :   0.380 seconds  [  1147226]
             createTaskFunctions :   0.043 seconds  [  1151550]

The same program written slightly differently takes about 9 seconds for the next phase, resolve.

(That slightly differently is creating and copying to a new smaller array instead of passing a slice:

  var newnums = for i in 0..#nums.size-1 do nums[i+1];
  tryit(newnums);

)

Is this issue currently blocking your progress?
No. It was simple to work around by declaring a new array and copying elements manually.

Steps to Reproduce

Source Code:

var nums = [ 0, 0, 0 ];

proc tryit(nums) : bool {
  if nums.size == 0 then return false;
  if tryit(nums[1..].reindex(0..nums.size-2)) then
    return true;
  return false;
}

tryit(nums);

Compile command:
chpl foo.chpl

Associated Future Test(s):

test/functions/resolution/recursive-call-with-reindexed-array-slice.chpl #26377

Configuration Information

chpl version 2.3.0 pre-release (d80d75c443)

CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: llvm
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native *
CHPL_LOCALE_MODEL: flat
CHPL_COMM: gasnet *
  CHPL_COMM_SUBSTRATE: udp
  CHPL_GASNET_SEGMENT: everything
CHPL_TASKS: qthreads
CHPL_LAUNCHER: amudprun
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
  CHPL_NETWORK_ATOMICS: none
CHPL_GMP: bundled
CHPL_HWLOC: bundled
CHPL_RE2: bundled
CHPL_LLVM: system
CHPL_AUX_FILESYS: none

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
vasslitvinov pushed a commit that referenced this issue Dec 8, 2024
---
Signed-off-by: Paul Cassella <gitgitgit@manetheren.bigw.org>
vasslitvinov added a commit that referenced this issue Dec 8, 2024
The added test times out during resolution.

Note: the same program compiles when a distinct array is created instead of
passing a slice:

  var newnums = for i in 0..#nums.size-1 do nums[i+1];
  tryit(newnums);

Contributed by: @cassella - thanks!
Review and merge: @vasslitvinov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants