Menu

tcpstream.getline() problem on Solaris

Porting
2002-01-21
2002-01-27
  • Costas Kotsokalis

    Heya,
      working with the CVS version of CC++ on Solaris 2.7/Sparc, g++ 2.95.1.
    The following code will work fine on Linux; however, on Solaris as soon as a connection is made the program receives a SIGILL and dies:

    #include <cc++/socket.h>
    #include <cc++/thread.h>

    #ifdef  CCXX_NAMESPACES
    using namespace std;
    using namespace ost;
    #endif

    #include <iostream>

    int main(int argc, char *argv[]){
        char *line = (char *)malloc(200);

        InetAddress addr = "0";
        TCPSocket *sock = new TCPSocket(addr, 9000);
        while (1){
            if (sock->isPendingConnection()){
                tcpstream tcp;
                tcp.open(*sock);
                tcp.getline(line, 200);
                cout << line << endl;
                tcp.close();
            }
        }
    }

    The socket is not closed before getline() is called, I have checked that. It is still open, yet the call to getline() fails. I tried to use gdb having compiled CC++ with debug info but I only managed to find that the problem takes place when TCPStream::underflow is called. It's weird though that gdb could not step into underflow(), it could only get to the point that it's called.

    Any ideas? Thanks!

      Costas

     
    • Frediano Ziglio

      Frediano Ziglio - 2002-01-23

      Very strange problem...
      I added to all TCPStream methods a line such
        cout << "funcname" << endl;
      And TCPStream::underflow is NOT called...
      Is seem a library bug...
      If you change che calling to underflow in TCPStream::uflow from underflow to TCPStream::underflow it run correctly (it exec underflow)...
      I watch header but the code is strange. It use a _IO_FILE C structure and some static C function like __underflow...
      Perhaps it's a Gcc 2.95.1/2.95.2 library problem ???

      Why the behavior change calling underflow from a TCPStream and TCPStream::underflow ?? Perhaps the compiler ?? (streambuf::underflow is public and TCPStream::underflow protected as standard?). I tried to remove virtual from TCPStream::underflow declaration but nothing change...

      freddy77

       
      • Frediano Ziglio

        Frediano Ziglio - 2002-01-27

        Fixed in CVS..
        Many hours are gone...
        This is a g++ bug (should be libio). libio (a library used for FILE* and streambuf I/O) is a C library that use C++ virutal table making some assumption. Perhaps these assumption are not very correct for some platform...
        streambuf MUST BE the first superclass on those version...

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.