Skip to content

Build directory (as a string) injected into _pydantic-core.*.so (which will cause non-reproducible builds) #1365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moto-timo opened this issue Jul 10, 2024 · 5 comments · Fixed by #1396
Assignees

Comments

@moto-timo
Copy link

While working on upgrading the Yocto Project recipe for pydantic-core to the latest version, I noticed that we are seeing build directory (TMPDIR) contamination in the _pydantic-core.*.so. This throws a QA warning for us, but would also lead to non-reproducible builds (because a different build directory would produce a different binary lib output).

On further inspection, it appears it might be a python backtrace related to the schema generation? (This happens on 2.19.0 and in this case 2.20.1 as well).

readelf -p 14 pydantic_core/_pydantic_core.cpython-312-x86_64-linux-gnu.so
pydantic-core-readelf-rodata.txt

Any ideas what could be causing this host information to be injected into the binary lib?

@davidhewitt
Copy link
Contributor

From a quick read it looks like these might be panic messages which are created by the Rust standard library. See rust-lang/rust#40374

It looks like these are hard to prevent.

@moto-timo
Copy link
Author

@davidhewitt I agree it looks like a panic message. It seems like it is related to schema validation?

Self SchemaError building self-schema:
  " validator:
  model-fieldsdataclasstuplefrozensetdefinition-refdefinitionsUnknown schema type: "2.20.1a-alphab-beta__version__profile=release pgo= -L /srv/build/ttorling/workspace-upgrades/build/tmp/work/core2-64-poky-linux/python3-pydantic-core/2.20.1/recipe-sysroot/usr/lib/rustlib/x86_64-poky-linux-gnu/lib --remap-path-prefix=/srv/build/ttorling/workspace-upgrades/build/tmp/work/core2-64-poky-linux/python3-pydantic-core/2.20.1=/usr/src/debug/python3-pydantic-core/2.20.1-Cprofile-use=args

What seems particularly strange is the 20.20.1a-alphab-beta substring, which so far I have only found in .github/check_version.py

Since it seems to be schema generation related, I can only guess the panic is from
generate_self_schema()?

@moto-timo
Copy link
Author

moto-timo commented Jul 29, 2024

In the GitHub 2.20.1 release whl, we see at least part of the same pattern

Self SchemaError building self-schema:
  Error building "" validator:
  modelmodel-fieldsdataclass-argsdataclasstuplefunction-afterfunction-beforefrozensetdefinition-refdefinitionsUnknown schema type: "2.20.1-alphaa-betabpydantic__version__profile=release pgo=args

And in the pypi wheel we see the same included host path pattern:

Self SchemaError building self-schema:
  " validator:
  model-fieldsdataclasstuplefrozensetdefinition-refdefinitionsUnknown schema type: "2.20.1a-alphab-beta__version__profile=release pgo=-Cprofile-use=/home/runner/work/pydantic-core/pydantic-core/merged.profdata-Cprofile-use=args

So it seems like we actually have a recurring general validation SchemaError?

@davidhewitt
Copy link
Contributor

The -CProfile-use bit is the RUSTFLAGS baked in by

option_env!("RUSTFLAGS").unwrap_or("").contains("-Cprofile-use="),

Perhaps if we wanted to write a way to evaluate that at build at const eval time then the flags could be omitted from the build.

The alpha / beta substring is probably coming from these pieces:

version.replace("-alpha", "a").replace("-beta", "b")

Probably the self-schema text comes from

Err(err) => return py_schema_err!("Error building self-schema:\n {}", err),

In all cases these look like string constants which are reasonably necessarily part of the build rather than some "general validation SchemaError.

@fdebrabander
Copy link

The problem for the reproducible builds with Yocto project seems to come from the first snippet.

option_env!("RUSTFLAGS").unwrap_or("").contains("-Cprofile-use="),

Yocto passes some flags with RUSTFLAGS, which includes paths that end up in the binary.

https://github.com/openembedded/openembedded-core/blob/bbcd56bace90f4a148960a7108dc8d0e6c364903/meta/classes-recipe/rust-common.bbclass#L15-L18

The '--remap-path-prefix' is to aid in creating reproducible builds, but that doesn't work in this case.

github-actions bot pushed a commit to Boeing/meta-openembedded-contrib that referenced this issue Aug 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
github-actions bot pushed a commit to Boeing/meta-openembedded-contrib that referenced this issue Aug 9, 2024
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 9, 2024
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 9, 2024
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 9, 2024
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 9, 2024
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue Aug 11, 2024
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orlingkonsulko.com>
Signed-off-by: Khem Raj <raj.khemgmail.com>
github-actions bot pushed a commit to Boeing/meta-openembedded-contrib that referenced this issue Aug 12, 2024
Backport a new upstream fix to remove the TMPDIR
reference from the rust code.

Signed-off-by: Frank de Brabander <debrabander@gmail.com>

We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Similar to Styhead 6f0a411, but for 2.18.4
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
github-actions bot pushed a commit to Boeing/meta-openembedded-contrib that referenced this issue Aug 14, 2024
Backport a new upstream fix to remove the TMPDIR
reference from the rust code.

Signed-off-by: Frank de Brabander <debrabander@gmail.com>

We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Similar to Styhead 6f0a411, but for 2.18.4
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue Aug 19, 2024
We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Signed-off-by: Tim Orling <tim.orlingkonsulko.com>
Signed-off-by: Khem Raj <raj.khemgmail.com>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/meta-openembedded that referenced this issue Aug 19, 2024
Source: meta-openembedded
MR: 158406
Type: Integration
Disposition: Merged from meta-openembedded
ChangeID: e041b4d
Description:

Backport a new upstream fix to remove the TMPDIR
reference from the rust code.

Signed-off-by: Frank de Brabander <debrabander@gmail.com>

We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Similar to Styhead 6f0a411, but for 2.18.4
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com>
daregit pushed a commit to daregit/yocto-combined that referenced this issue Apr 3, 2025
Backport a new upstream fix to remove the TMPDIR
reference from the rust code.

Signed-off-by: Frank de Brabander <debrabandergmail.com>

We've seen TMPDIR [build-paths] contamination in the
built pydantic_core/_pydantic_core.cpython-*-*-linux-gnu.so

See discussion upstream in:
pydantic/pydantic-core#1365

Backport fix from:
pydantic/pydantic-core@e07c41b

Similar to Styhead 6f0a41130c0dcf80e22f6f3fd93d39369c235693, but for 2.18.4
Signed-off-by: Tim Orling <tim.orlingkonsulko.com>
Signed-off-by: Armin Kuster <akuster808gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants