Skip to content

Fix nodejs on 64bit machines #236

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

Merged
merged 1 commit into from
Feb 19, 2018
Merged

Fix nodejs on 64bit machines #236

merged 1 commit into from
Feb 19, 2018

Conversation

amir-s
Copy link

@amir-s amir-s commented Feb 19, 2018

Running nodejs on my 64bit server always produces empty user.out and therefore results in wrong answer.

Running ldd `which nodejs` gives me:

linux-vdso.so.1 =>  (0x00007fff34849000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd35691c000)
libuv.so.1 => /usr/lib/x86_64-linux-gnu/libuv.so.1 (0x00007fd3566f9000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd3564f1000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd3562d4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd3560d0000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fd355e67000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fd355a23000)
libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007fd3555c1000)
libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007fd35522d000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd354eab000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd354ba2000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd35498c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd3545c2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd356b36000)
libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007fd352b0b000)

So, I updated the list of dynamic libraries needed for nodejs accordingly.
I ran judge_client and added the missing syscalls.
Now it seems to be working:

$ ./judge_client 1013 1 /home/judge debug
127.0.0.1
debian-sys-maint
****************
jol
3306
2
64
-Xms64M
-Xmx128M
0
0
http://127.0.0.1/JudgeOnline
IP
admin
1
1
1
0
0
ifconfig|grep 'inet'|awk -F: '{printf $2}'|awk  '{printf $1}'
/bin/umount -f /home/judge/run1//proc
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f /home/judge/run1//dev 
umount: /home/judge/run1//dev: mountpoint not found
/bin/umount -f /home/judge/run1//lib 
umount: /home/judge/run1//lib: mountpoint not found
/bin/umount -f /home/judge/run1//lib64 
umount: /home/judge/run1//lib64: mountpoint not found
/bin/umount -f /home/judge/run1//etc/alternatives 
umount: /home/judge/run1//etc/alternatives: mountpoint not found
/bin/umount -f /home/judge/run1//usr 
umount: /home/judge/run1//usr: mountpoint not found
/bin/umount -f /home/judge/run1//bin 
umount: /home/judge/run1//bin: mountpoint not found
/bin/umount -f /home/judge/run1//proc 
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f bin usr lib lib64 etc/alternatives proc dev 
umount: bin: mountpoint not found
umount: usr: mountpoint not found
umount: lib: mountpoint not found
umount: lib64: mountpoint not found
umount: etc/alternatives: mountpoint not found
umount: /proc: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
umount: dev: mountpoint not found
/bin/umount -f /home/judge/run1//* 
umount: /home/judge/run1//log: not mounted
/bin/umount -f /home/judge/run1//log/* 
umount: /home/judge/run1//log/Main.js: not mounted
umount: /home/judge/run1//log/ce.txt: not mounted
umount: /home/judge/run1//log/data.in: not mounted
umount: /home/judge/run1//log/dev: not mounted
umount: /home/judge/run1//log/error.out: not mounted
umount: /home/judge/run1//log/lib: not mounted
umount: /home/judge/run1//log/lib64: not mounted
umount: /home/judge/run1//log/nodejs: not mounted
umount: /home/judge/run1//log/user.out: not mounted
umount: /home/judge/run1//log/usr: not mounted
/bin/umount -f /home/judge/run1//log/etc/alternatives 
umount: /home/judge/run1//log/etc/alternatives: mountpoint not found
/bin/rm -rf /home/judge/run1//log/*
mkdir /home/judge/run1//log/
mkdir: cannot create directory ‘/home/judge/run1//log/’: File exists
/bin/mv /home/judge/run1//* /home/judge/run1//log/
/bin/mv: cannot move '/home/judge/run1//log' to a subdirectory of itself, '/home/judge/run1//log/log'
/bin/mkdir -p /dev/shm/hustoj//home/judge/run1/
/bin/ln -s /dev/shm/hustoj//home/judge/run1/ /home/judge/
/bin/ln: failed to create symbolic link '/home/judge/run1': File exists
/bin/chown judge /dev/shm/hustoj//home/judge/run1/ 
chmod 755 /dev/shm/hustoj//home/judge/run1/ 
/bin/ln -s /home/judge/data /dev/shm/hustoj//home/judge/
/bin/ln: failed to create symbolic link '/dev/shm/hustoj//home/judge/data': File exists
Main=Main.jschown judge /home/judge/run1//Main.js
time: 3 mem: 320
nothing to do!
compile end!
status=0
/bin/umount -f bin usr lib lib64 etc/alternatives proc dev 2>&1 >/dev/null
umount: bin: mountpoint not found
umount: usr: mountpoint not found
umount: lib: mountpoint not found
umount: lib64: mountpoint not found
umount: etc/alternatives: mountpoint not found
umount: /proc: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
umount: dev: mountpoint not found
/bin/umount -f /home/judge/run1//* 2>&1 >/dev/null
umount: /home/judge/run1//Main.js: not mounted
umount: /home/judge/run1//ce.txt: not mounted
umount: /home/judge/run1//log: not mounted
/bin/umount -f /home/judge/run1//proc
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f /home/judge/run1//dev 
umount: /home/judge/run1//dev: mountpoint not found
/bin/umount -f /home/judge/run1//lib 
umount: /home/judge/run1//lib: mountpoint not found
/bin/umount -f /home/judge/run1//lib64 
umount: /home/judge/run1//lib64: mountpoint not found
/bin/umount -f /home/judge/run1//etc/alternatives 
umount: /home/judge/run1//etc/alternatives: mountpoint not found
/bin/umount -f /home/judge/run1//usr 
umount: /home/judge/run1//usr: mountpoint not found
/bin/umount -f /home/judge/run1//bin 
umount: /home/judge/run1//bin: mountpoint not found
/bin/umount -f /home/judge/run1//proc 
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f bin usr lib lib64 etc/alternatives proc dev 
umount: bin: mountpoint not found
umount: usr: mountpoint not found
umount: lib: mountpoint not found
umount: lib64: mountpoint not found
umount: etc/alternatives: mountpoint not found
umount: /proc: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
umount: dev: mountpoint not found
/bin/umount -f /home/judge/run1//* 
umount: /home/judge/run1//Main.js: not mounted
umount: /home/judge/run1//ce.txt: not mounted
umount: /home/judge/run1//log: not mounted
/bin/umount -f /home/judge/run1//log/* 
umount: /home/judge/run1//log/*: mountpoint not found
/bin/umount -f /home/judge/run1//log/etc/alternatives 
umount: /home/judge/run1//log/etc/alternatives: mountpoint not found
/bin/umount -f /home/judge/run1//proc
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f /home/judge/run1//dev 
umount: /home/judge/run1//dev: mountpoint not found
/bin/umount -f /home/judge/run1//lib 
umount: /home/judge/run1//lib: mountpoint not found
/bin/umount -f /home/judge/run1//lib64 
umount: /home/judge/run1//lib64: mountpoint not found
/bin/umount -f /home/judge/run1//etc/alternatives 
umount: /home/judge/run1//etc/alternatives: mountpoint not found
/bin/umount -f /home/judge/run1//usr 
umount: /home/judge/run1//usr: mountpoint not found
/bin/umount -f /home/judge/run1//bin 
umount: /home/judge/run1//bin: mountpoint not found
/bin/umount -f /home/judge/run1//proc 
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f bin usr lib lib64 etc/alternatives proc dev 
umount: bin: mountpoint not found
umount: usr: mountpoint not found
umount: lib: mountpoint not found
umount: lib64: mountpoint not found
umount: etc/alternatives: mountpoint not found
umount: /proc: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
umount: dev: mountpoint not found
/bin/umount -f /home/judge/run1//* 
umount: /home/judge/run1//Main.js: not mounted
umount: /home/judge/run1//ce.txt: not mounted
umount: /home/judge/run1//log: not mounted
/bin/umount -f /home/judge/run1//log/* 
umount: /home/judge/run1//log/*: mountpoint not found
/bin/umount -f /home/judge/run1//log/etc/alternatives 
umount: /home/judge/run1//log/etc/alternatives: mountpoint not found
mkdir -p /home/judge/run1//dev
/bin/mount -o bind /dev /home/judge/run1//dev
/bin/mkdir -p /home/judge/run1//usr/lib /home/judge/run1//lib/i386-linux-gnu/ /home/judge/run1//lib64/
/bin/cp /lib/i386-linux-gnu/libz.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libz.so.*': No such file or directory
/bin/cp /usr/lib/i386-linux-gnu/libuv.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/usr/lib/i386-linux-gnu/libuv.so.*': No such file or directory
/bin/cp /usr/lib/i386-linux-gnu/libicui18n.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/usr/lib/i386-linux-gnu/libicui18n.so.*': No such file or directory
/bin/cp /usr/lib/i386-linux-gnu/libicuuc.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/usr/lib/i386-linux-gnu/libicuuc.so.*': No such file or directory
/bin/cp /usr/lib/i386-linux-gnu/libicudata.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/usr/lib/i386-linux-gnu/libicudata.so.*': No such file or directory
/bin/cp /lib/i386-linux-gnu/libtinfo.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libtinfo.so.*': No such file or directory
/bin/cp /usr/lib/i386-linux-gnu/libcares.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/usr/lib/i386-linux-gnu/libcares.so.*': No such file or directory
/bin/cp /usr/lib/libv8.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/usr/lib/libv8.so.*': No such file or directory
/bin/cp /lib/i386-linux-gnu/libssl.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libssl.so.*': No such file or directory
/bin/cp /lib/i386-linux-gnu/libcrypto.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libcrypto.so.*': No such file or directory
/bin/cp /lib/i386-linux-gnu/libdl.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libdl.so.*': No such file or directory
/bin/cp /lib/i386-linux-gnu/librt.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/librt.so.*': No such file or directory
/bin/cp /usr/lib/i386-linux-gnu/libstdc++.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/usr/lib/i386-linux-gnu/libstdc++.so.*': No such file or directory
/bin/cp /lib/i386-linux-gnu/libpthread.so.*  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libpthread.so.*': No such file or directory
/bin/cp /lib/i386-linux-gnu/libc.so.6  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libc.so.6': No such file or directory
/bin/cp /lib/i386-linux-gnu/libm.so.6  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libm.so.6': No such file or directory
/bin/cp /lib/i386-linux-gnu/libgcc_s.so.1  /home/judge/run1//lib/i386-linux-gnu/
/bin/cp: cannot stat '/lib/i386-linux-gnu/libgcc_s.so.1': No such file or directory
/bin/cp /lib/ld-linux.so.*  /home/judge/run1//lib/
/bin/cp: cannot stat '/lib/ld-linux.so.*': No such file or directory
/bin/mkdir -p /home/judge/run1//usr/lib /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libz.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /usr/lib/x86_64-linux-gnu/libuv.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/librt.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libpthread.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libdl.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libssl.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libcrypto.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /usr/lib/x86_64-linux-gnu/libicui18n.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /usr/lib/x86_64-linux-gnu/libicuuc.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /usr/lib/x86_64-linux-gnu/libstdc++.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libm.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libgcc_s.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib/x86_64-linux-gnu/libc.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /lib64/ld-linux-x86-64.so.* /home/judge/run1//lib64/
/bin/cp /usr/lib/x86_64-linux-gnu/libicudata.so.* /home/judge/run1//lib/x86_64-linux-gnu/
/bin/cp /usr/bin/nodejs /home/judge/run1//
sample
sample
/bin/cp '/home/judge/data/1000/sample.in' /home/judge/run1//data.in
/bin/cp /home/judge/data/1000/*.dic /home/judge/run1//
/bin/cp: cannot stat '/home/judge/data/1000/*.dic': No such file or directory
init_call_counter:16
pid=17423 judging /home/judge/data/1000/sample.in
/bin/grep 'python2' Main.py
/bin/grep: Main.py: No such file or directory
test0
test0
/bin/cp '/home/judge/data/1000/test0.in' /home/judge/run1//data.in
/bin/cp /home/judge/data/1000/*.dic /home/judge/run1//
/bin/cp: cannot stat '/home/judge/data/1000/*.dic': No such file or directory
init_call_counter:16
pid=17438 judging /home/judge/data/1000/test0.in
/bin/grep 'python2' Main.py
/bin/grep: Main.py: No such file or directory
test1
test1
/bin/cp '/home/judge/data/1000/test1.in' /home/judge/run1//data.in
/bin/cp /home/judge/data/1000/*.dic /home/judge/run1//
/bin/cp: cannot stat '/home/judge/data/1000/*.dic': No such file or directory
init_call_counter:16
pid=17453 judging /home/judge/data/1000/test1.in
/bin/grep 'python2' Main.py
/bin/grep: Main.py: No such file or directory
/bin/umount -f /home/judge/run1//proc
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f /home/judge/run1//dev 
/bin/umount -f /home/judge/run1//lib 
umount: /home/judge/run1//lib: not mounted
/bin/umount -f /home/judge/run1//lib64 
umount: /home/judge/run1//lib64: not mounted
/bin/umount -f /home/judge/run1//etc/alternatives 
umount: /home/judge/run1//etc/alternatives: mountpoint not found
/bin/umount -f /home/judge/run1//usr 
umount: /home/judge/run1//usr: not mounted
/bin/umount -f /home/judge/run1//bin 
umount: /home/judge/run1//bin: mountpoint not found
/bin/umount -f /home/judge/run1//proc 
umount: /home/judge/run1//proc: mountpoint not found
/bin/umount -f bin usr lib lib64 etc/alternatives proc dev 
umount: bin: mountpoint not found
umount: usr: not mounted
umount: lib: not mounted
umount: lib64: not mounted
umount: etc/alternatives: mountpoint not found
umount: /proc: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
umount: dev: not mounted
/bin/umount -f /home/judge/run1//* 
umount: /home/judge/run1//Main.js: not mounted
umount: /home/judge/run1//ce.txt: not mounted
umount: /home/judge/run1//data.in: not mounted
umount: /home/judge/run1//dev: not mounted
umount: /home/judge/run1//error.out: not mounted
umount: /home/judge/run1//lib: not mounted
umount: /home/judge/run1//lib64: not mounted
umount: /home/judge/run1//log: not mounted
umount: /home/judge/run1//nodejs: not mounted
umount: /home/judge/run1//user.out: not mounted
umount: /home/judge/run1//usr: not mounted
/bin/umount -f /home/judge/run1//log/* 
umount: /home/judge/run1//log/*: mountpoint not found
/bin/umount -f /home/judge/run1//log/etc/alternatives 
umount: /home/judge/run1//log/etc/alternatives: mountpoint not found
/bin/rm -rf /home/judge/run1//log/*
mkdir /home/judge/run1//log/
mkdir: cannot create directory ‘/home/judge/run1//log/’: File exists
/bin/mv /home/judge/run1//* /home/judge/run1//log/
/bin/mv: cannot move '/home/judge/run1//log' to a subdirectory of itself, '/home/judge/run1//log/log'
result=4

One thing I'm not so sure about is syscall 160 which is not whitelisted in any other languages. 160 is sys_setrlimit in 64bit architecture!

Also, syscall 7 is unique to JS (sys_poll) which I think should be ok since JS has non-blocking IO.

the JS code I've tested the client with:

var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', function(line){
    console.log(line.split(' ').map(i => Number(i)).reduce((s,i) => s+i));
});

@amir-s
Copy link
Author

amir-s commented Feb 19, 2018

I can provide a 64bit ubuntu machine if you need to test the code!

@zhblue zhblue merged commit 656aa53 into zhblue:master Feb 19, 2018
@zhblue
Copy link
Owner

zhblue commented Feb 19, 2018

let's hope nodejs won't do anything "bad"

@amir-s amir-s mentioned this pull request Apr 1, 2018
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

Successfully merging this pull request may close these issues.

2 participants