ish-app / ish

Linux shell for iOS
https://ish.app
Other
16.94k stars 892 forks source link

nodejs / copyfile: bad address in system call argument #2146

Open mzoliker opened 1 year ago

mzoliker commented 1 year ago

Hi iSH team!

Some of my nodejs apps are failing on iSH because of a bug in system call copyfile (see below).

Could somebody please help in fixing this issue in iSH?

And of course let me know if I can help in any way :-).

Thanks a lot and keep the excellent work with iSH!

Kind regards, Maurice

** Easy steps to reproduce this bug on iSH v1.3.2 (Build 494)

echo hello >a apk add nodejs node -e "require('fs').copyFileSync('a','b')"

** Note

Having a non empty 'a' file is important because copying an empty file actually works

** Results on the defaut iSH alpine v3.14 with default minirootfs v3.14.3

node -e "require('fs').copyFileSync('a','b')" internal/fs/utils.js:332 throw err; ^

Error: EPERM: operation not permitted, copyfile 'a' -> 'b' at Object.copyFileSync (fs.js:2062:3) at [eval]:1:15 at Script.runInThisContext (vm.js:134:12) at Object.runInThisContext (vm.js:310:38) at internal/process/execution.js:81:19 at [eval]-wrapper:6:22 at evalScript (internal/process/execution.js:80:60) at internal/main/eval_string.js:27:3 { errno: -1, syscall: 'copyfile', code: 'EPERM', path: 'a', dest: 'b' }

node -v v14.21.3

** More expressive results on latest alpine v3.18 with minirootfs v3.18.2

node -e "require('fs').copyFileSync('a','b')" node:internal/fs/utils:351 throw err; ^

Error: EFAULT: bad address in system call argument, copyfile 'a' -> 'b' at Object.copyFileSync (node:fs:2980:3) at [eval]:1:15 at Script.runInThisContext (node:vm:122:12) at Object.runInThisContext (node:vm:298:38) at node:internal/process/execution:83:21 at [eval]-wrapper:6:24 at runScript (node:internal/process/execution:82:62) at evalScript (node:internal/process/execution:104:10) at node:internal/main/eval_string:50:3 { errno: -14, syscall: 'copyfile', code: 'EFAULT', path: 'a', dest: 'b' }

Node.js v20.3.1

** Results using previous alpine versions

echo hello >a apk add nodejs node -e "require('fs').copyFileSync('a','b')"

minirootfs:

** Some variations if needed

node -e "require('fs').copyFileSync('a','b')" node -e "require('fs').copyFile('a','b',console.log)" node -e "require('fs').promises.copyFile('a','b')" node -e "require('fs').cpSync('a','b')" node -e "require('fs').cp('a','b',console.log)" node -e "require('fs').promises.cp('a','b')"

mzoliker commented 1 year ago

Hi!

As this works perfectly on my laptop, I am pretty sure this is an issue with iSH.

Maybe tbodt himself may look into this, as this is a system call problem?

Thanks a lot and please let me know if I can help :-).

Kind regards, Maurice

Alex979 commented 2 months ago

+1 I'm experiencing the same issue