Skip to content

CUDA debug info is invalid - compile units have an empty list of subprograms #5835

Closed

Description

@gmarkall

The NvvmDIBuilder has this method for constructing compile units:

    def _di_compile_unit(self):
        filepair = self._filepair()
        empty = self.module.add_metadata([self._const_int(0)])
        return self.module.add_metadata([
            self._const_int(self.DI_Compile_unit),         # tag
            filepair,                   # source directory and file pair
            self._const_int(self.DW_LANG_Python),  # language
            'Numba',                     # producer
            self._const_bool(True),      # optimized
            "",                          # flags??
            self._const_int(0),          # runtime version
            empty,                       # enums types
            empty,                       # retained types
            self.module.add_metadata(self.subprograms),  # subprograms
            empty,                       # global variables
            empty,                       # imported entities
            "",                          # split debug filename
        ])

This is used to create a compile unit as soon as the NvvmDIBuilder is constructed. At this point, self.subprograms is empty, so the compile unit has an empty list of subprograms. If subprograms are added later, then the subprograms metadata referenced by the compile unit remains empty.

This can cause segfaults in NVVM, or in certain cases, a failed assertion:

Assertion # 1 failed!
Function:   beginFunction
Expression: TheCU && "Unable to find compile unit!"

The list of subprograms is used to build a reverse mapping from subprograms to compile units - because the list is empty, NVVM can't find the compile unit for a given subprogram at this point. Issues with debuginfo generation like this have also affected other users of LLVM 3.4 - e.g. ispc/ispc#848.

I think the right thing to do is to modify the debug info generation so that the list of subprograms belonging to the compile unit can be updated each time a new subprogram is added, but I think this will take some work because the existing implementation is set up for everything to be immutable after creation.

Activity

  1. added 2 commits that reference this issue on Jun 10, 2020
    bfd1b71
    88a4b3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CUDACUDA related issue/PRbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions