Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 638
    • Merge requests 638
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #22573

JavaScript backend fileStat struct population doesn't work with hsc2hs features.

Summary

The way the JavaScript backend populates a fileStat struct is incompatible with the field ordering used by Emscripten. Usually this isn't a problem, but when these struct fields are referenced in HSC files using the #peek feature, the usual accessor functions are replaced with the peekBytes function, which will be looking at the wrong bytes in memory. So, the JavaScript backend will provide incorrect results for fileStats referenced through HSC files.

Steps to reproduce

Using FilePath functions that check a fileStat's mode, such as doesDirectoryExist and doesFileExist. These will incorrectly always return false due to the peekBytes function accessing memory in the JavaScript stat that is filled with 0.

There are several test cases in the GHC testsuite that fail due to the use of setSessionDynFlags which indirectly calls doesDirectoryExist. One such test is CallArity1.

Expected behavior

fileStat functions that are implemented using HSC features should return correct results using the JavaScript backend.

Environment

  • GHC version used: master after the JavaScript backend merge
  • System Architecture: JavaScript
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking