Skip to content
Snippets Groups Projects

Fix JavaScript bounds checking

Closed Josh Meredith requested to merge wip/js-boundsCheck into master

Fixes #23123 (closed)

This MR fixes JavaScript bounds checking for the -fcheck-prim-bounds flag with byte arrays by:

  • checking for the len field that is used to track byte array lengths, rather than the built-in JavaScript length field that is used by regular arrays
  • checking for range operations that use a size-zero range (effectively no-ops)

Additionally, the js_broken(23123) ("JS bounds checking broken") for the CheckBoundsOK test introduced in !9629 (closed) is changed to js_broken(21142) ("RuntimeRep requirements for novel Backends"), since the test is still failing on Addr representation.

Edited by Josh Meredith

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Josh Meredith added 100 commits

    added 100 commits

    Compare with previous version

  • Josh Meredith marked this merge request as ready

    marked this merge request as ready

  • Josh Meredith changed the description

    changed the description

  • This doesn't look finished because there are 7 failing tests still:

    Unexpected failures:
       /builds/ghc/ghc/tmp/ghctest-pg8kapvo/test   spaces/testsuite/tests/codeGen/should_fail/CheckBoundsCompareByteArray2.run       CheckBoundsCompareByteArray2 [bad exit code (0)] (normal)
       /builds/ghc/ghc/tmp/ghctest-pg8kapvo/test   spaces/testsuite/tests/codeGen/should_fail/CheckBoundsCompareByteArray3.run       CheckBoundsCompareByteArray3 [bad exit code (0)] (normal)
       /builds/ghc/ghc/tmp/ghctest-pg8kapvo/test   spaces/testsuite/tests/codeGen/should_fail/CheckBoundsReadInt64Array.run          CheckBoundsReadInt64Array [bad exit code (0)] (normal)
       /builds/ghc/ghc/tmp/ghctest-pg8kapvo/test   spaces/testsuite/tests/codeGen/should_fail/CheckBoundsReadWord64Array.run         CheckBoundsReadWord64Array [bad exit code (0)] (normal)
       /builds/ghc/ghc/tmp/ghctest-pg8kapvo/test   spaces/testsuite/tests/codeGen/should_fail/CheckBoundsReadWord8ArrayAsWord32.run  CheckBoundsReadWord8ArrayAsWord32 [bad exit code (1)] (normal)
       /builds/ghc/ghc/tmp/ghctest-pg8kapvo/test   spaces/testsuite/tests/codeGen/should_fail/CheckOverlapCopyAddrToByteArray.run    CheckOverlapCopyAddrToByteArray [bad exit code (0)] (normal)
       /builds/ghc/ghc/tmp/ghctest-pg8kapvo/test   spaces/testsuite/tests/codeGen/should_fail/CheckOverlapCopyByteArray.run          CheckOverlapCopyByteArray [bad exit code (0)] (normal)

    marking as draft.

    Can you also add more description to the commit message and make sure the ticket number is also in the commit message?

  • jeffrey young marked this merge request as draft

    marked this merge request as draft

  • jeffrey young requested review from @doyougnu

    requested review from @doyougnu

  • Sylvain Henry
  • 229 229 test('T22296',[only_ways(llvm_ways)
    230 230 ,unless(arch('x86_64'), skip)],compile_and_run,[''])
    231 231 test('T22798', normal, compile_and_run, ['-fregs-graph'])
    232 test('CheckBoundsOK', js_broken(23123), compile_and_run, ['-fcheck-prim-bounds'])
    232 test('CheckBoundsOK', js_broken(21142), compile_and_run, ['-fcheck-prim-bounds'])
    • Could you share the failure log of this test?

    • If we really want to punt on correctly bounds-checking readAddrArray# and friends, we should either:

      • entirely remove the bounds-checking logic for them from GHC.StgToJS.Prim, or
      • guard the specific problematic bits of this test with #if !defined(javascript_HOST_ARCH)
    • I don't agree that guarding is the correct solution here. Splitting the test (it does too much already) would allow better granularity for js_broken and inform us via unexpected passes when the behaviour changes.

    • Un-resolving.

      If you want to re-structure the test, fine. But leaving the entire test marked broken is pretty bad as there is no other test that tries to detect false positives.

      In fact, there is still at least one false-positive bug in this patch that the non-Addr# bits of this test would detect if the failure wasn't being hidden.

    • Sylvain Henry changed this line in version 10 of the diff

      changed this line in version 10 of the diff

    • Please register or sign in to reply
  • Josh Meredith added 1 commit

    added 1 commit

    • db5327f0 - JS: fix bounds checking (Issue 23123)

    Compare with previous version

  • Josh Meredith added 13 commits

    added 13 commits

    Compare with previous version

  • Sylvain Henry
  • Josh Meredith added 1 commit

    added 1 commit

    • 243bb9f9 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Josh Meredith added 1 commit

    added 1 commit

    • 53fbf777 - Revert bounds checking end index for JavaScript IndexByteArrayOp_Word8As*...

    Compare with previous version

  • Josh Meredith added 32 commits

    added 32 commits

    Compare with previous version

  • Josh Meredith marked this merge request as ready

    marked this merge request as ready

  • Josh Meredith resolved all threads

    resolved all threads

  • Josh Meredith requested review from @hsyl20

    requested review from @hsyl20

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading