Seg fault with static TF1

Hi,

I have static TF1 object in my code,
and looks it causes the program to segmentate.

I just wrote simple example demonstrating that problem.
Note that these codes work well in my local computer, but the problem appears
on University computers (gcc version 4.1.2, and root version 5.34/21)
I compile using the following 3 commands:

It compiles without errors.

codes are below

The header file test_class.h

#include <TF1.h>

class test_class
{
 public:
  test_class();
  
  static TF1 f_lin1;  

};

the cc file test_class.cc

#include <TF1.h>
#include "test_class.h"

#include <iostream>

using namespace std;

TF1 test_class::f_lin1 = TF1("f_lin1", "[0] + [1]*x", -45., 45.);

test_class::test_class()
{
  cout<<"Kuku"<<endl;
}

The main file test1.cc

#include "test_class.h"

int main()
{
  test_class t;

  return 0;
}

Rafo

Hi,

all seems fine also on OSx 10.10, root5 and root6.
There is the possibility that the error is related to a misconfiguration of the system.

Try to modify your “test_class.cc” file:
TF1 test_class::f_lin1(“f_lin1”, “[0] + [1]*x”, -45., 45.);

The commands you show create a “libtest_class.so.1.0.1” file, but the linker needs a “libtest_class.so” file. Can it be that you have some old “libtest_class.so” file around which is not a symbolic link to your “libtest_class.so.1.0.1”?

Thank you for your answers,

I tried TF1 test_class::f_lin1(“f_lin1”, “[0] + [1]*x”, -45., 45.);
it segmentated again.

About the linking of libtest_class.so.1.0.1, yes
I have a link libtest_class.so pointing to libtest_class.so.1.0.1,
so I think this is also ok.

I ran it with valgrind,
and it gives
“Invalid read of size 8”
TFormula::Analyze(char const*, int&, int)

I have no experience with valgrind, I put the output of it, just thought that
it might give you some hint

Well, maybe you could try the newest ROOT v5-34-25 (or the head of v5-34-00-patches branch).

Tried the newst v5-34-25, but again the same thing.

Rafo