laverdet / isolated-vm

Secure & isolated JS environments for nodejs
ISC License
2.18k stars 154 forks source link

AssertionError in cpu-profiler.js Test on x64 UBI 9.3 Container for Isolated-VM Build #505

Closed pooja0805 closed 1 week ago

pooja0805 commented 2 weeks ago

Hello Team,

I attempted to build and test the isolated-vm library on an x64 UBI 9.3 container, but encountered the following error during the cpu-profiler.js test:

cpu-profiler.js: *fail*
code: 1 signal: null
stderr: node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

AssertionError [ERR_ASSERTION]: profiles should have length > 0
    at testAsync (/home/test/isolated-vm/tests/cpu-profiler.js:98:9)
    at async Promise.all (index 2) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

Node.js v22.10.0

Observed Behavior:

The test failed with an assertion error indicating "profiles should have length > 0".

Expected Behavior:

The cpu-profiler.js test should pass as it does when run in an Ubuntu container.

Steps to Reproduce the Error:

  1. Install required packages:
    sudo yum install -y wget tar git gzip gcc gcc-c++ make python3 python3-devel
  2. Install Node.js v22.10.0:
    NODE_VERSION=22.10.0 && wget -q https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz && tar -xzf node-v$NODE_VERSION-linux-x64.tar.gz && export PATH=$HOME/node-v$NODE_VERSION-linux-x64/bin:$PATH && node -v
  3. Clone and enter the isolated-vm repository:
    git clone -b 'v5.0.1' https://github.com/laverdet/isolated-vm.git && cd isolated-vm
  4. Install dependencies:
    npm install
  5. Run tests:
    npm test

Additional Information:

The test passes when running the same steps in an Ubuntu container. Please guide on resolving this issue in the UBI 9.3 environment.

Thanks.

laverdet commented 2 weeks ago

Could you try increasing the 2048 constant in the test suite? The CPU profiler is a sampler so it could just be that it is running with a lower sample rate for some reason

pooja0805 commented 2 weeks ago

Could you try increasing the 2048 constant in the test suite? The CPU profiler is a sampler so it could just be that it is running with a lower sample rate for some reason

@laverdet Thanks for the suggestion. I did try increasing the 2048 constant in the test suite to 4096 and it is now passing.

pooja0805 commented 2 weeks ago

@laverdet I was trying to build and test isolated-vm on UBI 9.3 ppc64le VM as well and encountered the same error as seen on x64 arch.

I tried increasing the 2048 constant in the test suite on ppc64le, but the error persists. I experimented with values of 4096, 8192, 16384, and 32768, but unfortunately, none of these changes resolved the issue. The profiler still fails to gather sufficient data, resulting in the same "profiles should have length > 0" assertion error.

If there are any additional suggestions for adjusting the sampling rate or profiling settings, I'd be happy to try them.

pooja0805 commented 1 week ago

Closing this issue as the issue is resolved.