title: segfault in g_slice_alloc
body: <p>I am calling a function with the following lines:</p>
  
  <pre><code>void call_system_command(const char *command_params)
  {
      GString *cmd = g_string_sized_new(1024);
      g_string_append_printf(cmd, "/bin/bash /path/to/my/script '%s'", command_params);
      system(cmd-&gt;str);
      g_string_free(cmd, TRUE);
  }
  </code></pre>
  
  <p>I am getting segfault in the line with g_string_sized_new.
  Backtrace from gdb shows:</p>
  
  <pre><code>(gdb) bt
  #0  0x000000320ce56264 in g_slice_alloc () from /lib64/libglib-2.0.so.0
  #1  0x000000320ce5c3db in g_string_sized_new () from /lib64/libglib-2.0.so.0
  ....
  </code></pre>
  
  <p>I have tried exporting G_SLICE=always-malloc, so that instead of glib's own allocator, malloc is used. However the problem remains same.
  I am still getting segfault in g_slice_alloc.
  Also I am calling this function 'call_system_command' from multiple threads.
  Could that be a problem?</p>
  
  <p>The function is a part of plugin that is called by cron every 15 minutes. The segfault does not occur every time the plugin is executed but one every 3-4 days.</p>
  
  <p>Any pointers on further debugging will be helpful.</p>
  
  <p>Thanks in advance.</p>