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

Linux bin execution error #36

Open
amsXYZ opened this issue May 8, 2019 · 15 comments
Open

Linux bin execution error #36

amsXYZ opened this issue May 8, 2019 · 15 comments

Comments

@amsXYZ
Copy link

amsXYZ commented May 8, 2019

When calling your package from a JS script, I get the following error on linux (Ubuntu 16.04.6):

Error: Command failed: /mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux msdf -format text -stdout -size 11 16 -translate 2 26 -pxrange 8 -defineshape "{2.4, -13.664; 1.92, -22.048; 5.088, -22.048; 4.608, -13.664; 2.4, -13.664; }"
/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux: 9: /mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux: Syntax error: ")" unexpected

(node:61) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'slice' of undefined
    at MaxRectsPacker.sort (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/maxrects-packer/src/maxrects_packer.ts:125:22)
    at MaxRectsPacker.addArray (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/maxrects-packer/src/maxrects_packer.ts:70:14)
    at mapLimit (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/index.js:174:12)
    at f (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/map-limit/node_modules/once/once.js:17:25)
    at abort (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/map-limit/index.js:38:12)
    at /mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/map-limit/index.js:47:23
    at generateImage (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/index.js:166:23)
    at exec (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/index.js:329:21)
    at ChildProcess.exithandler (child_process.js:296:5)
    at ChildProcess.emit (events.js:182:13)

Any idea of why this might be happening? Only happens locally, and runs fine on a xenial docker image.

@soimy
Copy link
Owner

soimy commented May 9, 2019

Sorry, no way to reproduce this currently.
Take a look at cli.js for example usage.
@amsgames94 Can you try

msdfgen.linux msdf -format text -stdout -size 11 16 -translate 2 26 -pxrange 8 -defineshape "{2.4, -13.664; 1.92, -22.048; 5.088, -22.048; 4.608, -13.664; 2.4, -13.664; }"

in terminal and get some feedback?

@amsXYZ
Copy link
Author

amsXYZ commented May 15, 2019

I actually cannot run it from terminal... Getting exec format error, even though arch of my VM and the program is the same (x86-64):

$ arch
x86_64
$ file msdfgen.linux
msdfgen.linux: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 2.6.32, BuildID[sha1]=48e0bf17683cfabd5614f52eaa28ff79d61c7a29, not stripped
$ ./msdfgen.linux msdf -format text -stdout -size 11 16 -translate 2 26 -pxrange 8 -defineshape "{2.4, -13.664; 1.92, -22.048; 5.088, -22.048; 4.608, -13.664; 2.4, -13.664; }"
-bash: ./msdfgen.linux: cannot execute binary file: Exec format error

Could it be because it's been compiled as a shared object? Both the OSX and Win32 version of the same file are executables:

$ file darwin/msdfgen.osx
darwin/msdfgen.osx: Mach-O 64-bit x86_64 executable
$ file win32/msdfgen.exe
win32/msdfgen.exe: PE32 executable (console) Intel 80386, for MS Windows

@soimy
Copy link
Owner

soimy commented May 15, 2019

All shared objects are localized with edited ELFs.
I think a quick way to solve your problem is to compile msdfgen.linux yourself. See #17 (comment)

@soimy soimy assigned soimy and unassigned soimy May 15, 2019
@soimy soimy added the question label May 15, 2019
@zellm
Copy link

zellm commented May 15, 2019

I see the same issue (cannot execute binary file: Exec format error) on WSL/Ubuntu 18.04. But there is something odd but I am not sure whether this is related to the problem. Since

file msdfgen.linux
msdfgen.linux: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 2.6.32, BuildID[sha1]=48e0bf17683cfabd5614f52eaa28ff79d61c7a29, not stripped

showed binary is "not stripped", I run strip just to see what happens and I got an error:

strip msdfgen.linux
strip: stGyGj8o: Not enough room for program headers, try linking with -N
strip:stGyGj8o[.interp]: Bad value

Strip is failing with exactly the same error message on a native Ubuntu although the binary itself is running there without a problem. Could it be that the ELF structure of msdfgen.linux is broken? I did a quick check with readelf but did not spot anything unusual yet.

@soimy
Copy link
Owner

soimy commented May 15, 2019

@zellm Might related to this NixOS/patchelf/issues/10
Will dig.

@ninok
Copy link

ninok commented May 17, 2019

@amsgames94, @zellm, @soimy I had the same issue and build msdfgen from latest mainline and it works. (also strip is working).
Should I create a PR with the updated binary I build?

@soimy
Copy link
Owner

soimy commented May 17, 2019

PR really welcomed!
@ninok Can you try to use patchelf to localize the following shared libraries:

  • libfreetype.so.6
  • libpng16.so.16
  • libstsdc++.so.6
  • libz.so.1

I've tried to build them in my new linux vm but having hard time get the binary working with TravisCI.

@ninok
Copy link

ninok commented May 20, 2019

PR is here: #37 but Travis is also failing for me: https://travis-ci.org/soimy/msdf-bmfont-xml/builds/534678791?utm_source=github_status&utm_medium=notification

Can you point me to how I have to patch the binary with patchelf. I tried the following but the libraries did not change:

$ patchelf --replace-needed /usr/lib/x86_64-linux-gnu/libfreetype.so.6 ./lib/libfreetype.so.6 msdfgen.linux
$ ldd msdfgen.linux
        linux-vdso.so.1 (0x00007ffff0d05000)
        libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fdc088d0000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fdc08540000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdc081a0000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fdc07f80000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdc07b80000)
        libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007fdc07940000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fdc07710000)
        lib/libfreetype.so.6 => /lib64/ld-linux-x86-64.so.2 (0x00007fdc09000000)

Could we not just take the libraries from the system and update the ones used in Travis?

@soimy
Copy link
Owner

soimy commented May 20, 2019

Thanks for the effort!
I used patchelf --set-rpath '$ORIGIN\lib' msdfgen.linux and put all shared libraries in the lib folder to make them locally.
But gcc toolchain is a bit hard to make right. Let's try.

@ninok
Copy link

ninok commented Jun 5, 2019

Sorry for the delayed answer. I tried to set the rpath but I also get a corrupted binary file.
Might be the same issue as described here: NixOS/patchelf#146
My Ubuntu 18.04 WSL comes with patchelf 0.9. l will try with a newer version and post results soon.

@ninok
Copy link

ninok commented Jun 5, 2019

Unfortunately building latest patchelf from source did not help. So we have to wait until NixOS/patchelf#146 is fixed or upgrade CI to use Ubuntu 18.04.

@soimy
Copy link
Owner

soimy commented Jun 6, 2019

@ninok Thanks for the effort! Let's follow the progress of patchelf fix that problem. For now I think I should update the README for an FAQ on compiling msdfgen.

@ninok
Copy link

ninok commented Jun 6, 2019

@soimy Have you ever tried to set rpath when building msdfgen instead of patching it after building it? I will try this if I find time.

@BladePoint
Copy link

I'm getting a similar warning, also on Ubuntu (18.04.3 LTS):

(node:7778) UnhandledPromiseRejectionWarning: Error: Command failed: /usr/local/lib/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux msdf -format text -stdout -size 10 10 -translate -1 8 -pxrange 4 -defineshape "{6.72, 0.63; 6.72, 0.63; (5.418, 0.63); 4.452, -0.315; (3.486, -1.26); 3.486, -2.562; 3.486, -2.562; (3.486, -3.906); 4.452, -4.851; (5.418, -5.796); 6.72, -5.796; 6.72, -5.796; (8.064, -5.796); 9.009, -4.851; (9.954, -3.906); 9.954, -2.562; 9.954, -2.562; (9.954, -1.26); 9.009, -0.315; (8.064, 0.63); 6.72, 0.63; 6.72, 0.63; }"
/bin/sh: 1: /usr/local/lib/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux: Exec format error

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:567:12)
(node:7778) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7778) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@progrematic
Copy link

@BladePoint I had the same issue on WSL.
@ninok 's PR #37 fixed it for me.
Just download his modified binary and install it in /usr/local/lib/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux

Thanks @ninok !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants