Skip to content

Add import / export sections test#6497

Merged
oleks-rip merged 1 commit intoXRPLF:ripple/wasmi-host-functionsfrom
oleks-rip:imp_exp_tst
Mar 19, 2026
Merged

Add import / export sections test#6497
oleks-rip merged 1 commit intoXRPLF:ripple/wasmi-host-functionsfrom
oleks-rip:imp_exp_tst

Conversation

@oleks-rip
Copy link
Copy Markdown
Collaborator

High Level Overview of Change

Change in cycle every byte of import / export section and try to load module test

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

@oleks-rip oleks-rip requested review from mvadari and pwang200 March 7, 2026 00:11
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.3%. Comparing base (9c25d18) to head (2129601).
⚠️ Report is 1 commits behind head on ripple/wasmi-host-functions.

Additional details and impacted files

Impacted file tree graph

@@                     Coverage Diff                     @@
##           ripple/wasmi-host-functions   #6497   +/-   ##
===========================================================
  Coverage                         80.3%   80.3%           
===========================================================
  Files                              876     876           
  Lines                            69908   69908           
  Branches                          7590    7589    -1     
===========================================================
+ Hits                             56167   56168    +1     
+ Misses                           13741   13740    -1     

see 1 file with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oleks-rip oleks-rip force-pushed the imp_exp_tst branch 2 times, most recently from facafb8 to 44129ac Compare March 10, 2026 17:00
Comment thread src/test/app/Wasm_test.cpp Outdated

do
{
byte = (*it++) & 0x7F;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude flagged a bug, seems reasonable to me. Please take a look. @oleks-rip

Decodes a ULEB128 value from an iterator. This has a bug:

byte = (*it++) & 0x7F; // masks off the high bit → byte is now 0–127
byte <<= shift;
val |= byte;
shift += 7;
++count;
} while (byte >= 0x80); // ← always false!

After & 0x7F, byte is at most 127. Then byte <<= shift operates on a uint64_t so it can grow, but on the first iteration shift is 0, so byte remains 0–127, which is
always < 0x80. The loop always exits after one iteration, meaning it only ever reads a single byte.

This is masked in the test because the import/export sections are < 128 bytes (53 and 51), so their sizes happen to fit in a single ULEB128 byte. But for any section >=
128 bytes, this would return the wrong size.

Fix: save the raw byte before masking to check the continuation bit:

std::uint8_t raw;
do {
raw = *it++;
val |= (std::uint64_t(raw & 0x7F)) << shift;
shift += 7;
++count;
} while (raw & 0x80);


Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 929d461

@oleks-rip oleks-rip requested a review from pwang200 March 17, 2026 15:12
Copy link
Copy Markdown
Collaborator

@mvadari mvadari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are so many lines deleted in fixtures.cpp when there are no removals in fixtures.h?

@oleks-rip
Copy link
Copy Markdown
Collaborator Author

Why are so many lines deleted in fixtures.cpp when there are no removals in fixtures.h?

They are not deleted, they are formatted with new clang-format settings

@mvadari
Copy link
Copy Markdown
Collaborator

mvadari commented Mar 17, 2026

Why are so many lines deleted in fixtures.cpp when there are no removals in fixtures.h?

They are not deleted, they are formatted with new clang-format settings

Can that be done separately, given that this PR's parent branch isn't failing the clang-format check?

@oleks-rip
Copy link
Copy Markdown
Collaborator Author

Why are so many lines deleted in fixtures.cpp when there are no removals in fixtures.h?

They are not deleted, they are formatted with new clang-format settings

Can that be done separately, given that this PR's parent branch isn't failing the clang-format check?

removed

@oleks-rip oleks-rip requested a review from mvadari March 17, 2026 19:34
Copy link
Copy Markdown
Collaborator

@pwang200 pwang200 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only check the bug in my previous comment, and assumed other code is not changed except formatting. Force push make it hard to see what else is changed. Please let me know if you changed anything other than formatting.

@oleks-rip
Copy link
Copy Markdown
Collaborator Author

I only check the bug in my previous comment, and assumed other code is not changed except formatting. Force push make it hard to see what else is changed. Please let me know if you changed anything other than formatting.

removed formatting and rebases with latest changes from wasmi-host-functions

@oleks-rip oleks-rip merged commit 27468dd into XRPLF:ripple/wasmi-host-functions Mar 19, 2026
26 of 28 checks passed
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.

3 participants