title: Start of thread changes already set global variable
body: <p>I have ran into very strange behavior of my code, the basic flow of code is</p>
  
  <p><code>main ()</code> parses a file and sets global variables accordingly.. such as</p>
  
  <pre><code>int frame_size, version;
    typedef struct//file parsing variables
      {
          int frame,
          int version; } configuration;
  ***//the function init_parse calls***
      static int handler(void* user, const char* section, const char* name,
                         const char* value)
      {
          configuration* pconfig = (configuration*)user;
  
      #define MATCH(s, n) strcmp(section, s) == 0 &amp;&amp; strcmp(name, n) == 0
      if (MATCH("protocol", "version")) {
          pconfig-&gt;version = atoi(value);
      } 
      else if (MATCH("basic", "frames")) {
              pconfig-&gt;frames= atoi(value);
              frame_size=pconfig-&gt;frames;
                          }
      else {
          return 0;  /* unknown section/name, error */
      }
      return 1;
  }
  
  main (){
          configuration config;
      if (ini_parse("test.ini", handler, &amp;config) &lt; 0) {
                  printf("Can't load 'test.ini'\n");
                  getchar();
  iret = pthread_create(&amp;hThread,NULL, pcapreader, NULL);
      if(iret)
      {
          fprintf(stderr,"Error - pthread_create() return code: %d\n",iret);
          exit(EXIT_FAILURE);
      }
  
          }
  </code></pre>
  
  <p>Now, the line followed by <code>main()</code>'s parsing line, everything seems set, but as soon as thread is started , the value frame_size changes to something 6345720:/</p>
  
  <p>I have double checked code for possible replicated variable. thread only uses <code>frame_size</code> in for loop to check the limit. </p>