Bug 9762

Summary: Add support for poisoning of variables
Product: [Build System, Metadata & Runtime] BitBake Reporter: Igor Stoppa <igor.stoppa>
Component: bitbakeAssignee: Unassigned <unassigned>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: Low CC: patrick.ohly, poky.bs.watcher, poky.watcher, richard.purdie
Version: unspecified   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Igor Stoppa 2016-06-13 10:11:36 UTC
As author of a recipe, I would like to have means to ensure that certain variables are set.

The current approach is to initialise the variable to a known value that is outside the range of valid parameters and then perform a check later on.

This is where I think it would be more efficient and robust to have bitbake supporting poisoning.

The approaches could be 2:

a) let the user do something like:

MY_PRE_POISONED_VARIABLE ??= "DEADBEEF"

b) pre-initialize very variable to the poisoned value, like:

AUTO_POISONING='True' which would be the equivalent of:

RANDOM_VARIABLE ???= "DEADBEEF"


Either way, an error would be triggered whenever accessing a poisoned variable.
Comment 1 Richard Purdie 2016-06-16 15:26:18 UTC
Could you give a bit more information about what kinds of problems you're seeing here? There are a few different ways this could possibly be implemented but that really depends on the exact problem which is being addressed.

You can today tell whether a value is set if you use anonymous python by seeing if the return value of getVar is None. If it is None, you know it wasn't set. I'd much prefer checking for that value rather than adding poisoning support to bitbake.
Comment 2 Richard Purdie 2016-06-16 15:26:44 UTC
Assign to Igor for more info.
Comment 3 Igor Stoppa 2016-06-16 15:32:20 UTC
Yes, I could do as proposed, but what I'm after is to avoid having to add custom code for the check.

The scenario I have in mind would be:

when creating a recipe, I declare one or more variables as poisoned and then I do not have to worry about when they are used.

The first time they are used without being initialised, I get an ERROR.

IOW I would like to move the burden of the verification on the tool, instead than on the author of the recipe.

Does this clarify the rationale?
Comment 4 Igor Stoppa 2016-06-16 15:34:23 UTC
Back to original state and assignee.
Comment 5 Richard Purdie 2022-06-09 16:11:16 UTC
The trouble is we need to have consistent behaviour on how we handle default values. Most class code or similar checks for values and errors if they are unset. Adding in a new mechanism for such values would likely confuse more than it would help and we're unlikely to want to use poison values for many of our defaults.