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

fix map a type parsing issue for export/extern types #1563

Merged
merged 1 commit into from
Jan 29, 2018
Merged

fix map a type parsing issue for export/extern types #1563

merged 1 commit into from
Jan 29, 2018

Conversation

yonghong-song
Copy link
Collaborator

Fix issue #1562.

Currently, bcc allows a map defined in one module and
used in the same or a different module. At tests/python directory,
test_clang.py and test_shared_table.py have such an example.
...
b1 = BPF(text="""BPF_TABLE_PUBLIC("hash", int, int, table1, 10);""")
b2 = BPF(text="""BPF_TABLE("extern", int, int, table1, 10);""")
t = b2["table"]
...

With current implementation, the map key/value types are parsed
twice, resulting a type "int int" instead of "int". When type
is retrieved through t = b2["table"], python decoding error
will appear.

The issue is fixed by preventing the second map key/value type
parsing if the map is extern. Also add t = b2["table"]
so the issue will be triggered if bcc clang frontend fix is not there.

Signed-off-by: Yonghong Song yhs@fb.com

Fix issue #1562.

Currently, bcc allows a map defined in one module and
used in the same or a different module. At tests/python directory,
test_clang.py and test_shared_table.py have such an example.
  ...
  b1 = BPF(text="""BPF_TABLE_PUBLIC("hash", int, int, table1, 10);""")
  b2 = BPF(text="""BPF_TABLE("extern", int, int, table1, 10);""")
  t = b2["table"]
  ...

With current implementation, the map key/value types are parsed
twice, resulting a type "int int" instead of "int". When type
is retrieved through `t = b2["table"]`, python decoding error
will appear.

The issue is fixed by preventing the second map key/value type
parsing if the map is `extern`. Also add `t = b2["table"]`
so the issue will be triggered if bcc clang frontend fix is not there.

Signed-off-by: Yonghong Song <yhs@fb.com>
@4ast 4ast merged commit 7aaa12f into master Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants