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

RangeError: Index out of range #1022

Closed
shaikh-shahid opened this issue May 7, 2021 · 13 comments
Closed

RangeError: Index out of range #1022

shaikh-shahid opened this issue May 7, 2021 · 13 comments

Comments

@shaikh-shahid
Copy link

Getting this error when run ops run using the vscode extension.

What could be the possible issue?

booting /home/shahidshaikh/.ops/images/node ...
�[1;33mYou specified hardware acceleration, but it is not supported
Are you running inside a vm? If so disable accel with --accel=false
�[0m
�[1;33mAnyway, we will try to enable hardware acceleration
�[0mstderr: Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
stderr: qemu-system-x86_64: Back to tcg accelerator
en1: assigned 10.0.2.15
en1: assigned FE80::18E9:80FF:FE34:7D33
buffer.js:607
slice: (buf, start, end) => buf.utf8Slice(start, end),
^

RangeError: Index out of range
at Object.slice (buffer.js:607:37)
at Buffer.toString (buffer.js:804:14)
at Object.readFileSync (fs.js:408:41)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1195:22)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'ERR_OUT_OF_RANGE'
}
exit status 3

@fabioDMFerreira
Copy link
Contributor

@shaikh-shahid could you provide more context about your problem like the steps you followed, the environment where you're running and if possible your program source code.

@shaikh-shahid
Copy link
Author

Hey sure,

I am using the official code.

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(8083, "0.0.0.0");
console.log('Server running at http://127.0.0.1:8083/');

I have installed ops in machine and i am using vscode ops extension to execute.

In vscode, i am opening the command palete using shift+ctrl+p and running Ops: run open file command.

and i am getting the error shown above.

Same error when i am executing it via commands.

ops pkg load node_v14.2.0 -a app.js

@eyberg
Copy link
Contributor

eyberg commented May 7, 2021

@shaikh-shahid are you on linux / mac / windows?

what version of qemu are you using?

 qemu-system-x86_64 --version

or

 ops profile

@eyberg
Copy link
Contributor

eyberg commented May 7, 2021

this might be from an older version of qemu nanovms/nanos#340

@shaikh-shahid
Copy link
Author

Hey I am on Ubuntu,

ops profile results

Ops version: 0.1.22
Nanos version: 0.0
Qemu version: 2.11.1
Arch: linux
Virtualized: false

@eyberg
Copy link
Contributor

eyberg commented May 7, 2021

yeh - that's what I expected - it's an old qemu version

what release of ubuntu was that?

cat /etc/lsb-release

I just tried on 18.04 bionic with that version though, some qemu notes -> https://github.com/nanovms/nanos/wiki/qemu

is it possible to try on a more up-to-date ubuntu or later version of qemu?

@shaikh-shahid
Copy link
Author

I am running on 18.04

@shaikh-shahid
Copy link
Author

Any guide to upgrade to qemu ? I tried few commands but ops profile returning the same version.

@eyberg
Copy link
Contributor

eyberg commented May 7, 2021

https://askubuntu.com/questions/1067722/how-do-i-install-qemu-3-0-on-ubuntu-18-04 or just upgrading the distro would work too

@eyberg
Copy link
Contributor

eyberg commented May 7, 2021

fyi -- I was able to replicate what you see on 18.04 when accel is turned off

eyberg@box:~/j$ ops pkg load node_v14.2.0 -v -p 8083 --accel=false -a hi.js
booting /home/eyberg/.ops/images/node ...
You have disabled hardware acceleration

qemu-system-x86_64 -machine q35 -device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x3 -device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x3.0x1 -device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x3.0x2 -device virtio-scsi-pci,bus=pci.2,addr=0x0,id=scsi0 -device scsi-hd,bus=scsi0.0,drive=hd0 -vga none -smp 1 -device isa-debug-exit -m 2G -no-reboot -cpu max -drive file=/home/eyberg/.ops/images/node,format=raw,if=none,id=hd0 -device virtio-net,bus=pci.3,addr=0x0,netdev=n0,mac=aa:30:d4:9d:28:56 -netdev user,id=n0,hostfwd=tcp::8083-:8083 -display none -serial stdio
en1: assigned 10.0.2.15
en1: assigned FE80::A830:D4FF:FE9D:2856

buffer.js:607
    slice: (buf, start, end) => buf.utf8Slice(start, end),
                                    ^

RangeError: Index out of range
    at Object.slice (buffer.js:607:37)
    at Buffer.toString (buffer.js:804:14)
    at Object.readFileSync (fs.js:408:41)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1195:22)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'ERR_OUT_OF_RANGE'
}
exit status 3

if you have access to use kvm that might fix it as well because it works when accel is on (which is the default)

@eyberg
Copy link
Contributor

eyberg commented May 7, 2021

if you are on real hardware you can add yourself to kvm group as well https://nanovms.gitbook.io/ops/acceleration

@shaikh-shahid
Copy link
Author

I followed the link you gave, it seems I enabled everything. groups command is returning the kvm user group. I am just gonna switch to my MacBook and use ops there for tutorial sake. I think my company laptop has some restrictions.

@shaikh-shahid
Copy link
Author

Working fine in my Mac. Something wrong with my Ubuntu machine. Closing the issue.

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

No branches or pull requests

3 participants