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

failed to create js VM #574

Closed
compilenix opened this issue Sep 7, 2022 · 15 comments
Closed

failed to create js VM #574

compilenix opened this issue Sep 7, 2022 · 15 comments

Comments

@compilenix
Copy link

Hey,
I run into issues regarding the example njs config and nginx build from source (for a container image) and hope for someone to give me a hint what / where I might be missing something.

The error message, on container start:

nginx    | 2022/09/07 22:14:55 [emerg] 1#1: failed to create js VM
nginx    | nginx: [emerg] failed to create js VM

The build config: Dockerfile
The runtime config: njs git test branch commit

The error message shows as soon as js_import http.js; is added into the http block in nginx.conf.

I've already looked at #57 and #18 but don't see how this would apply here.

@xeioex
Copy link
Contributor

xeioex commented Sep 7, 2022

Hi @compilenix,

Can you reproduce with the official nginx docker?

@compilenix
Copy link
Author

No, that's why I hoped for an idea.

@xeioex
Copy link
Contributor

xeioex commented Sep 7, 2022

Can you try to build official nginx docker, but with the latest njs commit?

@xeioex
Copy link
Contributor

xeioex commented Sep 8, 2022

@compilenix

Please share docker build log and add the exact arguments you are using CFLAGS_ADD HEADERS_MORE_VERSION NGINX_COMMIT NGINX_VERSION NGX_BROTLI_COMMIT NJS_COMMIT OPENSSL_VERSION ZLIB_VERSION and everything else needed for reproduction of the issue.

@xeioex xeioex added the question label Sep 8, 2022
@compilenix
Copy link
Author

I'm using docker-compose build to build this, using the ENV vars from .env.

I'll post the build log shortly :)

@compilenix
Copy link
Author

Here is the build.log produced with docker-compose build --no-cache >build.log.

OS: Fedora 36 Workstation

docker-compose version via RPM package docker-compose-1.29.2-4.fc36:

docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.10.6
OpenSSL version: OpenSSL 3.0.5 5 Jul 2022

docker version via RPM package: moby-engine-20.10.17-5.fc36.x86_64:

Client:
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.18.4
 Git commit:        aa7e414
 Built:             Tue Jul 19 21:40:23 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.4
  Git commit:       f756502
  Built:            Tue Jul 19 21:40:23 2022
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.8
  GitCommit:        
 runc:
  Version:          1.1.3
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        

@xeioex
Copy link
Contributor

xeioex commented Sep 9, 2022

Hi @compilenix,

I stripped additional modules, and simplified build script

Dockerfile.574

docker build --build-arg BUSYBOX_VERSION="1.34.1" \
             --build-arg ALPINE_VERSION="3.16.1" \
             --build-arg NGINX_VERSION="1.23.1" \
             --build-arg NGINX_COMMIT=a63d0a70afea \
             --build-arg NJS_COMMIT=461dfb0bb60e \
             -f Dockerfile.574 .

This way, nginx/njs works as expected (no failed to create js VM).

So, If I were you, I would start adding everything else back by chunks and see the result.

My guess the problem is related to one of the following:

  1. PCRE lib (you are building from source all the dependencies but not libpcre2, at the same time you provide -static to the linker)
  2. OpenSSL lib
  3. CFLAGS and LDFLAGS compatibility of built libraries and nginx (--with-ld-opt="-s -static"?)

@xeioex xeioex added the answered label Sep 9, 2022
@compilenix
Copy link
Author

Thank you very much!
I'll try that on the weekend.

@xeioex
Copy link
Contributor

xeioex commented Sep 12, 2022

Hi @compilenix,

If you have any news, feel free to share the findings.

@compilenix
Copy link
Author

While I get your Dockerfile to build, I can't get nginx to do anything useful besides running. Every http request gets cut off by an connection reset and nginx does not write anything to error and access logs.

I'll continue trying to find a solution and will share more if I manage to get it running.

compilenix added a commit to compilenix/docker-nginx that referenced this issue Sep 17, 2022
@compilenix
Copy link
Author

After a couple more hours, I think I've found the issue. But I cant really see or explain why and even how this could happen.

Compressing busybox using upx causes this issue.
So this is a one-line change: commit with change

@xeioex Does njs depend on busybox (or any of it's provided functions) during runtime?

@xeioex
Copy link
Contributor

xeioex commented Sep 21, 2022

Hi @compilenix,

no, it does not.

The result is very strange to me. Busybox is a set of unix utilities combined into a single binary.
njs does not depend on any other binaries, but only libraries.
njs almost self-contained and is linked to a very small number of libraries: libc, libm, libpcre2, libcrypto

@compilenix
Copy link
Author

Hmm okay, strange indeed.
The issue is resolved, from my point of view. I leave it up to you if you want to keep this issue open for further investigation or to close it.

Thanks for your support @xeioex

@xeioex xeioex closed this as completed Sep 22, 2022
@xeioex
Copy link
Contributor

xeioex commented Sep 30, 2022

Hi @compilenix,

Take a look at #581, it may be related to your issue.

@calvin2021y
Copy link

still get this problem with 1.25.2 & njs 8.1 and openssl 1.1.1w. is there any tips how to fix this ?

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

3 participants