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

Civetweb failing to compile due to pointers<->int conversions #108

Closed
Proch92 opened this issue Aug 23, 2017 · 11 comments
Closed

Civetweb failing to compile due to pointers<->int conversions #108

Proch92 opened this issue Aug 23, 2017 · 11 comments

Comments

@Proch92
Copy link

Proch92 commented Aug 23, 2017

Hello,
i'm on linux 64bit and i'm trying to build the api.

GCC 7.1.1
Target: x86_64-pc-linux-gnu

After the steps provided in the docs

cd build
cmake ../

the make command fails at building civetweb. Here's the error:

/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_create’:
/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c:2425:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  return (void *)ret;
         ^
/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_wait’:
/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c:2433:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  int s = (int)read((int)eventhdl, &u, sizeof(u));
                    ^
/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_signal’:
/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c:2447:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  int s = (int)write((int)eventhdl, &u, sizeof(u));
                     ^
/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_destroy’:
/home/proch/dev/sc2ai/s2client-api/contrib/civetweb/src/civetweb.c:2459:8: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  close((int)eventhdl);
        ^

Can someone point me in the right direction?

Thanks

@mejan
Copy link

mejan commented Aug 23, 2017

Yea I got the same problem. But the error is not in the "s2client-api" it is in the submodule civetweb (which they change on 22 Aug) from a oder version. I will check now if I can pull a older version before they changed.

@KevinCalderone
Copy link

We are using a slightly modified version of civetweb v1.9.1.

Do you get the same error if you build the latest master of civetweb?
https://github.com/civetweb/civetweb

Maybe they have a fix we can pull in. Otherwise we may need to ask them to look into it.

@kuzi117
Copy link
Contributor

kuzi117 commented Aug 23, 2017

I'm getting the error too now, and I think the lines in question are from a commit about a year old. Master builds fine for me.

@KevinCalderone
Copy link

Seems like they fixed it recently:
civetweb/civetweb@c6fbe01

If that does fix it, we could cherry-pick that commit onto our fork. We have avoiding using their latest master as it is unclear how stable it is since they haven't made a new release tag for awhile.

@wizzup
Copy link

wizzup commented Aug 25, 2017

civetweb/civetweb@c6fbe01 didn't work for me. same error with different location

$ make                                           
Scanning dependencies of target c-library
[  1%] Building C object contrib/civetweb/src/CMakeFiles/c-library.dir/civetweb.c.o
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_create’:
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c:2428:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  ret = (void *)evhdl;
        ^
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_wait’:
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c:2449:11: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  evhdl = (int)eventhdl;
          ^
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_signal’:
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c:2475:11: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  evhdl = (int)eventhdl;
          ^
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c: In function ‘event_destroy’:
/home/wizzup/works/beta_projects/starcraft2/s2client-api/contrib/civetweb/src/civetweb.c:2499:11: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  evhdl = (int)eventhdl;
          ^
cc1: all warnings being treated as errors
make[2]: *** [contrib/civetweb/src/CMakeFiles/c-library.dir/build.make:63: contrib/civetweb/src/CMakeFiles/c-library.dir/civetweb.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: contrib/civetweb/src/CMakeFiles/c-library.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

this is how I patch, I am on origin/master branch inside contrib/civetweb

$ git rev-parse HEAD
73303c4562d3ea5922e65a543d55233fc0d1f747

$ curl https://github.com/civetweb/civetweb/commit/c6fbe01f68d9e0975b0c0296baf902873e2eb792.diff | patch -p1                                                                                           
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                    
                                Dload  Upload   Total   Spent    Left  Speed                      
100  1895    0  1895    0     0   1895      0 --:--:--  0:00:01 --:--:--  1321                     
patching file src/civetweb.c   

@Proch92
Copy link
Author

Proch92 commented Aug 25, 2017

Yeah they """fixed""" it.

Too bad the compiler doesn't know the bad cast is inside a
if (sizeof(int) == sizeof(void *)) {
condition. so he just throws the error again

@KevinCalderone
Copy link

KevinCalderone commented Aug 25, 2017

That seems to be how it is on their latest master. I am confused then by how kuzi117 says their master build fine. Did they have some later commit where they suppressed this warning?

@Proch92
Copy link
Author

Proch92 commented Aug 25, 2017

Yeah i don't know either.
Also, i built it just fine too. i merged the two masters (civetweb's and yours) and successfully compiled the whole api.

@kuzi117
Copy link
Contributor

kuzi117 commented Aug 25, 2017

@Proch92 That's sort of incorrect. It does understand that it's inside an if, and since size_of is a compile time operator it can understand that code inside of it can become unreachable code. It seems like clang is the only one to emit a warning about it though.

@KevinCalderone This seems like the commit that fixes it. It pushes diagnostics to ignore those warnings, and in the case of clang, ignore unreachable code. I glanced over the rest of it and it seems to be mostly just formatting fixes.

@KevinCalderone
Copy link

It looks like @jrepp committed the fix: KevinCalderone/civetweb@ba9c16f

Also this issue seemed to start happening because our civetweb submodule got messed up briefly and we pulled in a bunch of new civetweb changes that we hadn't tested. That should all be reverted now too.

Can you please retest, and reopen this issue if it is still occurring for you?

@Proch92
Copy link
Author

Proch92 commented Aug 29, 2017

Nothing to reopen ;)
I just tested it on arch, gcc 7.1.1
All went smooth

jrepp pushed a commit to jrepp/s2client-api that referenced this issue Nov 18, 2017
Improved handling timeout errors and crashes. Reviewer: abrunasso
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

No branches or pull requests

5 participants