Skip to content
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

Order of generated code is arbitrary / random #84

Open
barsnick opened this issue Oct 22, 2024 · 0 comments
Open

Order of generated code is arbitrary / random #84

barsnick opened this issue Oct 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@barsnick
Copy link
Contributor

Describe the bug

When cbExiGen generates code, the order of types and functions in the generated code seems random. While the order is reproducible with a static version of cbExiGen, any change in the Python code will mangle the order.

This makes it difficult to compare the result. Committing changed code to the libcbv2g repository gives large diffs even for cosmetic changes.

To Reproduce

No response

Anything else?

If you look at the trees cbExiGen generates, you can see the differing order. (I think they can be enabled by setting generate_analysis_tree{,_20}.)

cbExiGen does do some sorting underways, and some order is required anyway to comply to code dependencies without forward declarations. This is all covered and continues to work. (It breaks if you try to sort the type arrays alphabetically.)

I thought this issue was due to Python's hash seed randomization. But even if I do export PYTHONHASHSEED=0; python3 src/main.py (you cannot disable from within a Python program), any change in the Python code shuffles order.

This may or may not be related to the order of elements handed out by xmlschema's API.

We probably need to create the data sets differently, e.g. by sorting at each branch point.

(See also https://stackoverflow.com/questions/51948243/why-is-the-order-of-python-sets-not-deterministic-even-when-pythonhashseed-0)

Any help appreciated.

@barsnick barsnick added the bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant