cmusatyalab / coda

Coda is an advanced networked filesystem. It has been developed at CMU since 1987 by the systems group of M. Satyanarayanan in the SCS department.
http://coda.cs.cmu.edu/
GNU General Public License v2.0
130 stars 22 forks source link

After rpc2 update to 2.14, coda_server 6.9.5 breaks: error: unterminated conditional directive #46

Open yurivict opened 6 years ago

yurivict commented 6 years ago
In file included from cml.multi.c:3:
./cml.h:1:2: error: unterminated conditional directive
#ifndef _CML_
 ^

Found this problem after the FreeBSD port was updated to 2.14.

jaharkes commented 6 years ago

The rpc stub generator (rp2gen) must have failed while it was generating that file. You could try a make clean; make to rebuild all the generated files (like cml.h).

If that doesn't fix it, try to run rp2gen cml.rpc2 in the coda-src/vicedep subdirectory and see if it gives any error messages.

yurivict commented 6 years ago
$ rp2gen cml.rpc2 
Client should not unpack RPC2_CountedBS!
Abort trap
jaharkes commented 6 years ago

Odd, I remember there was a bug related to that message. I found it but this was part of a commit b9e514104395b54fa3723329572c84cf8c5fe4fd made in 2016, but that was merged into RPC2-2.12.

Could there be an older version of rp2gen on your system that is being picked up instead of the one from RPC2-2.14?

yurivict commented 6 years ago

It is installed by the latest rpc2.

$ which rp2gen
/usr/local/bin/rp2gen
[yuri@yv ~]$ pkg which /usr/local/bin/rp2gen
/usr/local/bin/rp2gen was installed by package rpc2-2.14
[yuri@yv ~]$ ls -l /usr/local/bin/rp2gen
-rwxr-xr-x  1 root  wheel  86560 Feb 13 13:50 /usr/local/bin/rp2gen
jaharkes commented 6 years ago

Got it, you are building 6.9.5, which still had the 'OLDCML' definitions. There was a reason we switched away from them and that was because the client code was generating effectively buggy code. The CountedBS input buffer doesn't specify the available buffer space on a client, so it can cause buffer overflows on the reply side of a remote procedure call.

Now in the CML case, there is no reply message because we're just leveraging the existing packing/unpacking code to send things to the server in a well defined and network agnostic format. But since we wanted to add stricter checks at the RPC2 layer we created new CML operations that avoid the problematic CountedBS input buffers. Coda clients stopped using the old packing functions in coda-5.3.20, servers supported both formats to handle legacy clients.

In 2016 we redid the pack/unpack functionality in RPC2 (rpc2-2.12) and added the stricter checks and removed the OLDCML operations from the server (coda-6.9.9). And because you are trying to build and older Coda release with the stricter version of RPC2 it fails to generate the stub code. Unfortunately it fails halfway through generating the output, so even if it fails the make the left over files are picked up by the next make execution and get the unterminated conditional because the generated file was truncated.

yurivict commented 6 years ago

I actually know nothing about coda. I only tried to update the FreeBSD port for rpc2, and it broke coda. Automatic version discovery system told me that ftp://ftp.wu-wien.ac.at/pub/systems/coda/src/coda-6.9.5.tar.gz is the latest version.

What is the URL of the latest tarball then?

jaharkes commented 6 years ago

http://coda.cs.cmu.edu/coda/source/coda-6.12.0.tar.gz

There is a .xz compressed one as well. That source tree actually includes the lwp, rpc2, and rvm sources. It made sense because no other project is actually using those libraries independently and it makes builds more reliable because the Coda source will always build against the included versions of the libraries.

It may be a bit of work to get it up and running. I haven't run Coda on FreeBSD in quite a while because it isn't a system I use on a day-to-day basis and I don't know if there have been any significant changes to the kernel module and such.

yurivict commented 6 years ago

Build of 6.12.0 fails:

libtool: link: c++ -O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer -Wall -fno-exceptions -fcheck-new -rdynamic -fstack-protector -o codasrv srv.o srvproc.o srvproc2.o coppend.o codaproc.o codaproc2.o clientproc.o vicecb.o smon.o ../../coda-src/vicedep/.libs/voldump.client.o ../../coda-src/vicedep/.libs/volutil.server.o  -L/usr/local/lib ./.libs/libviceerror.a ../../coda-src/vicedep/.libs/libvicedep.a ../../coda-src/volutil/.libs/libvolutil.a ../../coda-src/volutil/.libs/libvolserv.a ../../coda-src/resolution/.libs/libres.a ../../coda-src/librepair/.libs/librepio.a ../../coda-src/vol/.libs/libvol.a ../../coda-src/lka/.libs/liblka.a ../../coda-src/vv/.libs/libvv.a ../../coda-src/auth2/.libs/libauth2.a ../../coda-src/partition/.libs/libpartition.a ../../coda-src/al/.libs/libal.a ../../coda-src/dir/.libs/libcodadir.a ../../coda-src/util/.libs/libutil.a ../../lib-src/rwcdb/.libs/librwcdb.a ../../lib-src/base/.libs/libbase.a -L/usr/ports/net/coda6_server/work/coda-6.12.0/lib-src/rvm/rds -lrdslwp -L/usr/ports/net/coda6_server/work/coda-6.12.0/lib-src/rvm/seg -lseglwp -L/usr/ports/net/coda6_server/work/coda-6.12.0/lib-src/rvm/rvm -lrvmlwp -L/usr/ports/net/coda6_server/work/coda-6.12.0/lib-src/lwp/src -L/usr/ports/net/coda6_server/work/coda-6.12.0/lib-src/rpc2/rpc2-src -lrpc2 -lse -llwp -lkvm 
srv.o: In function `main':
srv.cc:(.text+0x1523): undefined reference to `codatunnel_fork'
jaharkes commented 6 years ago

Odd, the RPC2 library in that tree should have provided a stub function when the (currently experimental) codatunnel changes for RPC2 are not built. The same (stub) function is also called from the Coda client code in 'coda-src/venus' which at that point should have already been built.