"#pragma link defined_in" seems to select symbols incorrectly

Create issue
Issue #16 resolved
Shaheed Haque created an issue

As per discussions elsewhere, it seems that "#pragma link defined_in" can select symbols which are not defined in the listed file(s). One example of this appears in issue 12 in the context of the StringMap typedef in KF5.Attica:

$ pytest -s KF5.Attica/test.py              
cls = <class 'cppyy._cpython_cppyy.gbl'>, name = 'StringMap'

    def __getattr__(cls, name):
            attr = _backend.LookupCppEntity(name)
        except Exception as e:
>           raise AttributeError(str(e))
E           AttributeError: StringMap

Wim has indicated that the underlying issue here may be related to the fact that StringMap is a template instantiation referring to QString, and that QString may not be handled properly even though it is not defined in the selected file(s).

There are several other instances of what may be a similar problem:

  • Long64_t, referenced in KF5.Config.
  • GDoubleIEEE754, referenced in KF5.NetworkManagerQt

In both cases, these symbols are also in the .rootmap though not defined in the the selected files.

Comments (7)

  1. wlav repo owner

    Aside from the main problem, that's an older version of gbl. :) The gbl and std namespaces are no longer special cases, but instances of CPPScope, just like any other namespace. That class's lookup (meta_getattro) is a little different from LookupCppEntity. The latter is now only used for the lazy lookup on dictionaries, which is neither advertised nor used (AFAIK), and I'm thinking of dropping it altogether for easier maintenance.

  2. wlav repo owner

    StringMap (from #12) is no longer an issue b/c of the work around of #13.

    For Long64_t, what appears to be happening is that "long long" is requested, and rootcling makes it into Long64_t, which is a typedef of long long on Linux. Investigating ...

  3. wlav repo owner

    It's pretty deeply ingrained and several other codes rely on this feature (meaning: removing the mapping causes segfaults in other places).

    I've implemented a targeted workaround that only fixes up the rootmap file.

  4. Shaheed Haque reporter

    I've stopped using rootmap because (a) it is fundamentally unsupported and (b) I now have a _cppyy_generator.py which provides a tailored alternative. I still see the lookup failure on a number of typedefs across my footprint, and I am considering whether I can just ignore, at least for now.

    I think my next step is to try to characterise the failures.

  5. wlav repo owner

    Note that things like StringMap used to fail simply b/c the underlying types were not pulled in from anywhere (QString in that case). If the errors that remain look like that, the question is whether defined_in should be self-contained, or whether perhaps it should have some dependency set up.

  6. Shaheed Haque reporter

    LOL. Well that would at least explain things! I've not yet had a chance to delve deeper so this is a useful clue.

  7. Log in to comment