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

JSON incorrect object alignment in arrays with 64bit members #59585

Closed
pdgendt opened this issue Jun 22, 2023 · 4 comments
Closed

JSON incorrect object alignment in arrays with 64bit members #59585

pdgendt opened this issue Jun 22, 2023 · 4 comments
Assignees
Labels
area: JSON bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale

Comments

@pdgendt
Copy link
Collaborator

pdgendt commented Jun 22, 2023

Describe the bug
Adding a 64bit member to a struct used for encoding/decoding in an array results in incorrect alignments, while looping the elements.

EDIT: Adding elements that are not in the object description are not supported, however adding a member to the description with a sizeof 8 still would not work.

See #59485 for changes

Tested on x86 64bit. I think the issue comes from the use of __alignof__ in include/zephyr/data/json.h, as the alignment will be fixed to 8 bytes. But the compiler still appears to use a 4 byte alignment.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout the PR branch
  2. $ west build -p -b native_posix_64 -s tests/lib/json/
  3. $ ./build/zephyr/zephyr.exe
  4. See error

Expected behavior
Adding such a member should not impact json encoding/decoding.

Impact
This currently blocks PR #59485.

Logs and console output

$ ./build/zephyr/zephyr.exe
START - test_json_masked_obj_arr_decoding

    Assertion failed at WEST_TOPDIR/zephyr/tests/lib/json/src/main.c:924: lib_json_test_test_json_masked_obj_arr_decoding: (oa.num_elements not equal to 3)
Number of masked object fields not decoded correctly
 FAIL - test_json_masked_obj_arr_decoding in 0.000 seconds
===================================================================
START - test_json_masked_obj_arr_encoding

    Assertion failed at WEST_TOPDIR/zephyr/tests/lib/json/src/main.c:896: lib_json_test_test_json_masked_obj_arr_encoding: (ret not equal to 0)
Encoding array of masked object returned error
 FAIL - test_json_masked_obj_arr_encoding in 0.000 seconds

Environment (please complete the following information):

  • OS: Linux (in WSL)
  • Toolchain: zephyr SDK 0.15.0
@pdgendt pdgendt added bug The issue is a bug, or the PR is fixing a bug area: JSON labels Jun 22, 2023
@pdgendt
Copy link
Collaborator Author

pdgendt commented Jun 22, 2023

A potential fix can be #53333

@jhedberg jhedberg added the priority: low Low impact/importance bug label Jul 4, 2023
@github-actions
Copy link

github-actions bot commented Sep 3, 2023

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Sep 3, 2023
@pdgendt pdgendt removed the Stale label Sep 4, 2023
Copy link

github-actions bot commented Nov 4, 2023

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Nov 4, 2023
@pdgendt pdgendt removed the Stale label Nov 6, 2023
Copy link

github-actions bot commented Jan 6, 2024

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Jan 6, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: JSON bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale
Projects
None yet
Development

No branches or pull requests

3 participants