pkgcheck icon indicating copy to clipboard operation
pkgcheck copied to clipboard

[Bug]: EclassExportFuncsBeforeInherit is non-deterministic

Open thesamesam opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

At b1620a6c399a9950305159728dd9d7fc40e7dfe8 in gentoo.git:

eclass $ pkgcheck scan -k EclassExportFuncsBeforeInherit

eclass $ pkgcheck scan -k EclassExportFuncsBeforeInherit
eclass
  EclassExportFuncsBeforeInherit: xdg: EXPORT_FUNCTIONS (line 48) called before inherit (line 28)

eclass $ pkgcheck scan -k EclassExportFuncsBeforeInherit
eclass
  EclassExportFuncsBeforeInherit: guile: EXPORT_FUNCTIONS (line 356) called before inherit (line 96)
  EclassExportFuncsBeforeInherit: xdg: EXPORT_FUNCTIONS (line 48) called before inherit (line 28)

eclass $ pkgcheck scan -k EclassExportFuncsBeforeInherit
eclass
  EclassExportFuncsBeforeInherit: guile: EXPORT_FUNCTIONS (line 356) called before inherit (line 96)

eclass $ pkgcheck scan -k EclassExportFuncsBeforeInherit
eclass $ pkgcheck scan -k EclassExportFuncsBeforeInherit
eclass
  EclassExportFuncsBeforeInherit: guile-single: EXPORT_FUNCTIONS (line 243) called before inherit (line 115)
  EclassExportFuncsBeforeInherit: xdg: EXPORT_FUNCTIONS (line 48) called before inherit (line 28)

So, all-in-all, it reports:

  • guile.eclass
  • guile-single.eclass
  • xdg.eclass

Expected Behavior

Consistent output across runs.

pkgcheck version

0.10.31

pkgcore version

0.12.28

thesamesam avatar Sep 23 '24 10:09 thesamesam

This is still reproducible w/ that SHA in pkgcheck 0.10.37.

The odd part is the feed going into that function is stable, as is the vars in that code path, and it's pointing at the global_query. This is the output of shoving a print(f'{eclass.name}: {node}') in to see what it's examining, while limiting it to just xdg

(pkgcore) ferringb@hrair ~/gentoo/repo $ pkgcheck scan -k EclassExportFuncsBeforeInherit -j 1
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content)))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name)) (string_content) (expansion (variable_name) (word)) (string_content)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (word))
xdg: (command name: (command_name (word)) argument: (raw_string) argument: (word) argument: (word) argument: (word))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content)))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name))))
xdg: (command (variable_assignment name: (variable_name)) name: (command_name (word)) argument: (word) argument: (word) argument: (raw_string) argument: (word))
xdg: (command (variable_assignment name: (variable_name)) name: (command_name (word)) argument: (word) argument: (word) argument: (raw_string) argument: (word))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (word))
eclass
  EclassExportFuncsBeforeInherit: xdg: EXPORT_FUNCTIONS (line 48) called before inherit (line 28)


(pkgcore) ferringb@hrair ~/gentoo/repo $ pkgcheck scan -k EclassExportFuncsBeforeInherit -j 1
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command (variable_assignment name: (variable_name)) name: (command_name (word)) argument: (word) argument: (word) argument: (raw_string) argument: (word))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (raw_string) argument: (word) argument: (word) argument: (word))
xdg: (command name: (command_name (word)) argument: (word))
xdg: (command (variable_assignment name: (variable_name)) name: (command_name (word)) argument: (word) argument: (word) argument: (raw_string) argument: (word))
xdg: (command name: (command_name (word)) argument: (raw_string) argument: (word) argument: (word) argument: (word))
xdg: (command (variable_assignment name: (variable_name)) name: (command_name (word)) argument: (word) argument: (word) argument: (raw_string) argument: (word))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name))))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name))))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name)) (string_content) (expansion (variable_name) (word)) (string_content)))
xdg: (command name: (command_name (word)) argument: (word))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name))))
xdg: (command name: (command_name (word)) argument: (string (string_content)))
xdg: (command name: (command_name (word)))
xdg: (command name: (command_name (word)) argument: (raw_string) argument: (word) argument: (word) argument: (word))
xdg: (command name: (command_name (word)) argument: (string (expansion (variable_name)) (string_content) (expansion (variable_name)) (string_content)))
xdg: (command name: (command_name (word)) argument: (word) argument: (word) argument: (word))

The question being, why the hell is that query nondeterministic; it's explciitly coming from eclass.global_query(bash.cmd_query) and it's just about the second step that is where it diverges.

        export_funcs_called = None
        for node in eclass.global_query(bash.cmd_query):
            call = eclass.node_str(node)
            if call.startswith("EXPORT_FUNCTIONS"):
                export_funcs_called = node.start_point[0] + 1
            elif call.startswith("inherit"):
                if export_funcs_called is not None:
                    yield EclassExportFuncsBeforeInherit(
                        export_funcs_called, node.start_point[0] + 1, eclass=eclass.name
                    )
                    break

ferringb avatar Dec 07 '25 00:12 ferringb

Just confirming: is it intentional that if --cache=no is passed, the eclass check itself just doesn't run? That seems like a bug.

ferringb avatar Dec 07 '25 00:12 ferringb