phillipstanleymarbell / Noisy-lang-compiler

Noisy language compiler
MIT License
17 stars 1 forks source link

SIGSEGV fault when running newton CGI interface #618

Open janithpet opened 2 years ago

janithpet commented 2 years ago

Describe the bug After fixing Issues #615, #616 and #617, and compiling, running the webtool generates the following text in red, on the top of the page:

⚠    Web interface to compiler halted the computation (WcgiAsync). Memory or CPU usage limit exceeded or other asynchronous error.

See screenshot below for how it is seen on the webpage.

image

This text is caused by the signal handler timeoutSignalHandler in src/newton/cgimain.c. By adding a write statement on line 116, to print the signal code that caused the error, we can see that it is a SIG-11 (SIGSEGV).

To Reproduce Steps to reproduce the behavior; this assumes that Apache2 is setup, with cgi modules enabled on your machine:

  1. Clone repo using git clone --recursive git@github.com:phillipstanleymarbell/Noisy-lang-compiler.git
  2. Create config.local in root directory, and submodules/libflex. config.local looks like:
    LIBFLEXPATH=<path-to-repo>/Noisy-lang-compiler/submodules/libflex
    CONFIGPATH=<path-to-repo>/home/janith/Noisy-lang-compiler/submodules/libflex
    OSTYPE=linux
    MACHTYPE=x86_64
  3. run make in submodules/libflex.
  4. run mkdir icons in src/. This is a temporary fix for Issue-#616. See note below.
  5. run sudo cp NewtonBaseSignals.nt /usr/bin/cgi-bin/ from src/newton. This is a temporary fix for Issue-#617.
  6. run make installcgi in src/newton.
  7. run
    wget http://code.jquery.com/jquery-git.js /tmp/
    sudo cp /tmp/jquery-git.js /var/www/html/tmp/

    and

    git clone https://github.com/ajaxorg/ace-builds.git /tmp/ace-builds
    sudo cp -r /tmp/ace-builds/src-noconflict /var/www/html/tmp/
  8. On a browser, go to localhost/cgi-bin/newtoncgi-linux-EN/?c=.

Host OS (please complete the following information):

Your local changes (please complete the following information):

Additional Notes

janithpet commented 2 years ago

The following changes to cgimain.c seem to fix this issue.

--- a/src/newton/cgimain.c
+++ b/src/newton/cgimain.c
@@ -372,10 +372,10 @@ main(void)
        sigaction(SIGVTALRM, &sa, NULL);

-       newtonCgiState = init(kCommonModeDefault|kCommonModeCallStatistics/* | kCommonModeCallTracing */|kCommonModeCGI);
-       newtonCgiDimensionsState = init(kCommonModeDefault|kCommonModeCallStatistics/* | kCommonModeCallTracing */|kCommonModeCGI);
+       newtonCgiState = init(kCommonModeDefault/*|kCommonModeCallStatistics | kCommonModeCallTracing */|kCommonModeCGI);
+       newtonCgiDimensionsState = init(kCommonModeDefault/*|kCommonModeCallStatistics | kCommonModeCallTracing */|kCommonModeCGI);
        timestampsInit(newtonCgiState);
-
+       timestampsInit(newtonCgiDimensionsState);

        /*
         *      Extra \n, to send the blank line:

I will make a PR with these changes.