Skip to content
This repository was archived by the owner on Sep 4, 2019. It is now read-only.

HttpParser fails to build on recent ArchLinux and Julia Version 0.6.0 (2017-06-19 13:05 UTC) #75

Closed
WilCrofter opened this issue Aug 26, 2017 · 17 comments

Comments

@WilCrofter
Copy link

A fix which seems to have worked for me was to comment out the -Werror switch in ~/.julia/v0.6/HttpParser/deps/src/http-parser-2.7.1/Makefile line 57:

CFLAGS += -Wall -Wextra #-Werror

Otherwise, a warning which stems from a drop through in case 2: below (line 1817 ~/.julia/v0.6/HttpParser/deps/src/http-parser-2.7.1/http_parser.c is treated as an error and aborts the build. However, the drop through (missing break statement) in case 2: seems purposeful. I am guessing about that however.

        if (settings->on_headers_complete) {
          switch (settings->on_headers_complete(parser)) {
            case 0:
              break;

            case 2:
              parser->upgrade = 1;

            case 1:
              parser->flags |= F_SKIPBODY;
              break;

            default:
              SET_ERRNO(HPE_CB_headers_complete);
              RETURN(p - data); /* Error */
          }
        }
@aviks
Copy link
Member

aviks commented Aug 26, 2017

What gcc version are you on? This might need to be reported upstream https://github.com/nodejs/http-parser

@WilCrofter
Copy link
Author

WilCrofter commented Aug 26, 2017

Apparently Arch and I are somewhat behind the curve, the current stable version of gcc being 7.2.0.

$ gcc --version
gcc (GCC) 7.1.1 20170630
$ pacman -Ss gcc
core/gcc 7.1.1-4 (base-devel) [installed]

I think you are right about reporting this upstream. Shall I do that and close the issue?

@WilCrofter
Copy link
Author

WilCrofter commented Aug 26, 2017

Actually, the latest source at https://github.com/nodejs/http-parser builds without issue on the same Arch Linux box using gcc 7.1.1. (See abbreviated session below.) But the latest source differs significantly from that in my ~/.julia/v0.6/HttpParser/deps/src/http-parser-2.7.1, so it appears that Pkg.add("HttpParser") downloaded and attempted to build an earlier version.

Namely v2.7.1 which I see is specified in build.jl. Unsure how to proceed from here. Thinking.

Sorry to be so verbose, but version 2.7.1 does build with an older gcc on an ubuntu machine. (Ubuntu 4.8.4 vs latest stable release of 5.3.)

$ git clone [email protected]:nodejs/http-parser.git
Cloning into 'http-parser'...
$ cd http-parser/
$ make
cc  -I. -DHTTP_PARSER_STRICT=1  -Wall -Wextra -Werror -O0 -g  -c http_parser.c -o http_parser_g.o
...
test_g
...
requests okay
./test_fast
...
requests okay

@aviks
Copy link
Member

aviks commented Aug 27, 2017

Thank you for the investigation, this is very helpful. Especially the verbosity!

So the latest release of node-parser is 2.7.1, from about a year ago. They haven't made a new release since, but apparently fixed this issue in master. I'm not sure we want the julia package to download master by default. Can you make this change locally in your environment? And/or ask them when they propose to release a new version?

@aviks
Copy link
Member

aviks commented Aug 27, 2017

In particular, the commit that fixed this seems to be this one: nodejs/http-parser@0852bea

@WilCrofter
Copy link
Author

Thanks, @aviks, that's a good plan. Let me educate myself about this gcc7 fallthrough issue a little more today. Then I'll open an issue at nodejs/http-parser as you suggest and link to it from here. We can close this issue or not as you think best.

I can easily make the appropriate changes in my local environment. Thanks.

@WilCrofter
Copy link
Author

Issue requesting new release opened at nodejs/http_parser.

Shall we close here, or leave open until completely resolved?

@aviks
Copy link
Member

aviks commented Aug 27, 2017

Leave it open. We'll upgrade to a new version once released and tested.

@WilCrofter
Copy link
Author

Just in case anyone else needs a quick fix, there are just two lines to change in .julia/v0.x/HttpParser/deps/src/http-parser-2.7.1/http_parser.c.

Line 1818 is blank. It should contain a /* FALLTHROUGH */ comment as follows.

            case 2:
              parser->upgrade = 1; # line 1817
              /* FALLTHROUGH */    # was blank
            case 1:
              parser->flags |= F_SKIPBODY;
              break;

Line 2378 contains a comment misspelled as /* FALLTROUGH */. The missing H should be added as follows.

      case s_req_server_with_at:
        found_at = 1;

      /* FALLTHROUGH */   # line 2378 --was misspelled
      case s_req_server:
        uf = UF_HOST;
        break;

Running make should then compile and successfully test the code.

@christopher-dG
Copy link
Member

This is still present on Arch with gcc 7.2.0, but the above fix still works.

@WilCrofter
Copy link
Author

@christopher-dG, I should have mentioned that if http-parser is first installed with the system package manager, e.g., sudo pacman -S http-parser for Arch, then julia> Pkg.add("HttpParser") will install without issue. I've also verified the process for Debian, sudo apt-get install http-parser. There may be problems with CentOS 7 and similar. Forums seem to indicate that http-parser was, at some point, missing from the nodejs dependencies. I don't know if this has been resolved.

So far, the nodejs project has not acted on my request for a new release.

@AShedko
Copy link

AShedko commented Nov 1, 2017

By the way I am still experiencing this very bug on ubuntu 17.10 on current master.
Any news on this?

@Azzaare
Copy link

Azzaare commented Nov 13, 2017

@AShedko You can follow @WilCrofter instruction to modify .julia/v0.x/HttpParser/deps/src/http-parser-2.7.1/http_parser.c
You can then run make or even Pkg.build("HttpParser") in Julia REPL. It should fix it.

@WilCrofter
Copy link
Author

You can also comment out the -Werror switch on line 49 of the Makefile. This is my preference (despite my original comment,) but opinions differ.

Http_parser is available as an npm package for all distributions, I think. I've ended up using the version available as an Arch Linux package. Once that is installed, the Julia package should build flawlessly.

@WilCrofter
Copy link
Author

WilCrofter commented Feb 9, 2018

aviks added a commit that referenced this issue Feb 14, 2018
@randyzwitch
Copy link

Can we tag a new version for METADATA? Checking out master resolved my error On Pop_OS! (Ubuntu 17.10), so it seems like it's worth bumping the version for others.

@Cevadra
Copy link

Cevadra commented Mar 19, 2018

me 2 when building on Ubuntu 17.10
problem solved, thanks WilCrofter !~

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

Successfully merging a pull request may close this issue.

7 participants