1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Array problem - /lib/libgcc_s.so.1

Discussion in 'C' started by alejandro910, Jan 15, 2010.

  1. alejandro910

    alejandro910 New Member

    Hi, I'm writing a server in C that accepts messages from users through TCP/IP connection and then forwards them to a list of file descriptors that are connected to the server...

    I use a global variable to store all incoming messages
    char* messages[1000];

    When a user connects to the server to send a message, i create a new therad that receives the message, saves it in the messages array, and print it with puts() in server screen. Then it signals another thread that will send this message to the list of file descriptors that are waiting for this message..

    the problem is this:
    the thread receives the signal, and tries to read the message that was previously saved in the array.. but when I'm trying to print it in the server screen, I get /lib/libgcc_s.so.1 instead of the message.. it's not an error, process still runs, but I get this.. and the clients that receive the message, also print this..

    any idea why is this happening?

    i use gcc in ubuntu 9.1
  2. Gene Poole

    Gene Poole New Member

    Are you using any kind of synchronization, or can just any thread read/write to messages[] at anytime?
  3. alejandro910

    alejandro910 New Member

    i'm using mutex and condition variable to protect the array..
  4. alejandro910

    alejandro910 New Member

    i found the error.. i forgot to put '\0' at the end of my string.. solved

Share This Page