title: Segmentation Fault (Core Dumped): Error while returning from function
body: <p>I have two functions.</p>
  
  <pre><code>struct logger_message vget_log_msg(enum LogStatus log_status, const char* format, va_list args) {    
      struct logger_message log_msg;
      log_msg.status = log_status;
      log_msg.timestamp = get_current_timestamp();
  
      memset(log_msg.message_buffer, 0, MESSAGE_SIZE);
      if(format){    
          vsprintf(log_msg.message_buffer, format, args);
      }
      return log_msg;
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>int send_log_message_to_mqueue(mqd_t mqd, enum LogStatus log_status, const char* format, ...) {
      struct logger_message msg;
      va_list argp;
      va_start(argp, format); 
      msg = vget_log_msg(log_status, format, argp);
      va_end(argp);
      int res; 
      res = send_message_to_mqueue(mqd, (char *)&amp;msg, sizeof(msg));
      return res;
  }
  </code></pre>
  
  <p>So, I get the error "Segmentation Fault(Core dumped)" while returning from vget_log_msg on line:</p>
  
  <pre><code>msg = vget_log_msg(log_status, format, argp);
  </code></pre>
  
  <p><strong>EDIT: Maybe this information can be useful</strong></p>
  
  <pre><code>struct logger_message{
      enum LogStatus status;
      time_t timestamp;
      char message_buffer[MESSAGE_SIZE];    
  };
  </code></pre>
  
  <p>Does anybody know why I get this error? how to correct it?</p>