legion: Regent: -fbounds-checks 1 causes compilation to fail

Inside my code I’ve found some (terra) IO code causing some unexpected free faults resulting in crashes. I tried to enable -fbounds-checks 1 to try to chase down the issue.

What I have now found is that my code that runs normally fails to compile with -fbounds-checks, but doesn’t give me any real information to work out why:

/home/aidan/Legion/legion/language/terra/src/terralib.lua:1160: Errors reported during typechecking.
/home/aidan/Legion/legion/language/src/regent/codegen.t:1141: invalid conversion from int1d(part(), $771439) to int1d(part(), $771440)
        [pointer_value], [pointer_index],
                     ^
/home/aidan/Legion/legion/language/src/regent/codegen.t:1141: user-defined cast failed: /home/aidan/Legion/legion/language/src/regent/std.t:2117: assertion failed!
stack traceback:
        [C]: in function 'assert'
        /home/aidan/Legion/legion/language/src/regent/std.t:2117: in function </home/aidan/Legion/legion/language/src/regent/std.t:2111>
        [C]: in function 'xpcall'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:1141: Errors reported during invoking __cast
        [pointer_value], [pointer_index],
                     ^
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2248: in function 'insertcast'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2623: in function 'trylist'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2632: in function 'tryinsertcasts'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2809: in function 'docheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3039: in function 'checkexp'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3354: in function 'typecheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:1160: in function 'definequote'
        ...
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3354: in function 'typecheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:1160: in function 'definequote'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:8434: in function 'fn'
        /home/aidan/Legion/legion/language/terra/src/terralist.lua:150: in function 'block'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:10856: in function 'compile_thunk'
        /home/aidan/Legion/legion/language/src/regent/std_base.t:1609: in function 'complete'
        /home/aidan/Legion/legion/language/src/regent/std.t:4424: in function </home/aidan/Legion/legion/language/src/regent/std.t:4422>
        /home/aidan/Legion/legion/language/src/regent/std.t:4426: in function 'compile_tasks_in_parallel'
        /home/aidan/Legion/legion/language/src/regent/std.t:4560: in function 'start'
        src/interactions/dl_meso/mdvv.rg:486: in main chunk
        [pointer_value], [pointer_index],
                     ^
/home/aidan/Legion/legion/language/src/regent/codegen.t:1141: user-defined cast failed: /home/aidan/Legion/legion/language/src/regent/std.t:2117: assertion failed!
stack traceback:
        [C]: in function 'assert'
        /home/aidan/Legion/legion/language/src/regent/std.t:2117: in function </home/aidan/Legion/legion/language/src/regent/std.t:2111>
        [C]: in function 'xpcall'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:1141: Errors reported during invoking __cast
        [pointer_value], [pointer_index],
                     ^
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2248: in function 'insertcast'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2623: in function 'trylist'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2632: in function 'tryinsertcasts'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:2809: in function 'docheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3039: in function 'checkexp'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3354: in function 'typecheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:1160: in function 'definequote'
        ...
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3354: in function 'typecheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:1160: in function 'definequote'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:8434: in function 'fn'
        /home/aidan/Legion/legion/language/terra/src/terralist.lua:150: in function 'block'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:10856: in function 'compile_thunk'
        /home/aidan/Legion/legion/language/src/regent/std_base.t:1609: in function 'complete'
        /home/aidan/Legion/legion/language/src/regent/std.t:4424: in function </home/aidan/Legion/legion/language/src/regent/std.t:4422>
        /home/aidan/Legion/legion/language/src/regent/std.t:4426: in function 'compile_tasks_in_parallel'
        /home/aidan/Legion/legion/language/src/regent/std.t:4560: in function 'start'
        src/interactions/dl_meso/mdvv.rg:486: in main chunk
        [pointer_value], [pointer_index],
                     ^

stack traceback:
        [C]: in function 'error'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:390: in function 'finishandabortiferrors'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3356: in function 'typecheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:1160: in function 'definequote'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:1139: in function 'fn'
        /home/aidan/Legion/legion/language/terra/src/terralist.lua:150: in function 'map'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:1310: in function '__ref'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:1343: in function 'read'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:8102: in function 'fn'
        /home/aidan/Legion/legion/language/terra/src/terralist.lua:150: in function 'block'
        ...
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:3354: in function 'typecheck'
        /home/aidan/Legion/legion/language/terra/src/terralib.lua:1160: in function 'definequote'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:8434: in function 'fn'
        /home/aidan/Legion/legion/language/terra/src/terralist.lua:150: in function 'block'
        /home/aidan/Legion/legion/language/src/regent/codegen.t:10856: in function 'compile_thunk'
        /home/aidan/Legion/legion/language/src/regent/std_base.t:1609: in function 'complete'
        /home/aidan/Legion/legion/language/src/regent/std.t:4424: in function </home/aidan/Legion/legion/language/src/regent/std.t:4422>
        /home/aidan/Legion/legion/language/src/regent/std.t:4426: in function 'compile_tasks_in_parallel'
        /home/aidan/Legion/legion/language/src/regent/std.t:4560: in function 'start'
        src/interactions/dl_meso/mdvv.rg:486: in main chunk

(line 486 is just the regentlib.start() call). I tried looking in my code for casts that might cause the problem, but I don’t use casts of the particle type. I wondered if it was caused somehow due to an array type inside the field space, but I can’t make a small replicator that has the same issue.

Is there any way Regent can give more information here?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

For what it’s worth, the original issue seems to be one of not having the subregion stored in a single variable. This is a problem that’s been in the compiler for a while and might take longer to resolve. But you can work around it like this:


Note you will need an up-to-date copy of master to get #945, otherwise the reproducer hits that issue.
import "regent"

fspace part {
  cell_id : int3d,
}

task main()
  var r = region(ispace(int1d, 1), part)
  var p = partition(equal, r, ispace(int3d, {1,1,1}))
  for cell in p.colors do
    var x = p[cell]
    for part in x do
      regentlib.assert(x[part].cell_id == int3d(cell), "test failed")
    -- for part in p[cell] do
    --   regentlib.assert(p[cell][part].cell_id == int3d(cell), "test failed")
    end
  end
end
regentlib.start(main)

I reproduced the issue on Linux.