# TF2 Parameters Leads to Seg Fault

**URL:** <https://root-forum.cern.ch/t/tf2-parameters-leads-to-seg-fault/58334>\
**Category:** Newbie\
**Tags:** root\
**Created:** [February 29, 2024, 6:06am UTC](https://root-forum.cern.ch/t/tf2-parameters-leads-to-seg-fault/58334 "2024-02-29T06:06:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denali\_Jah](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/denali_jah/32/34137_2.png) [@Denali\_Jah](https://root-forum.cern.ch/u/Denali_Jah)\
**Post date:** [February 29, 2024, 6:06am UTC](https://root-forum.cern.ch/t/tf2-parameters-leads-to-seg-fault/58334/1 "2024-02-29T06:06:37Z")

</div>

When I call for a parameter in a function being integrated by TF2 I receive a segmentation fault.

```auto
#include <stdlib.h>
#include "TF2.h"

//Function Integrated Over
double func_sub(double *vals, double *par)
{
  std::cout << par[0] << std::endl; //This is where the Seg happens
  return cos(vals[0]*vals[1]);
}

//Function Setting up Integral  
void func()  
{
  TF2 * inter = new TF2("tester",func_sub,0,1,0,1);
  inter->SetParameter(0,1);

  std::cout << inter->Integral(0,1,0,1) << std::endl;
}

int main()
{
  func();
}

```

_ROOT Version:_ **6.28.04**  
_Platform:_ Windows but running through Umbuntu  
_Compiler:_ g++

* * *

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 29, 2024, 7:43am UTC](https://root-forum.cern.ch/t/tf2-parameters-leads-to-seg-fault/58334/2 "2024-02-29T07:43:00Z")

</div>

Welcome to the ROOT forum.

You missed `npar`. You should do:

```auto
  TF2 * inter = new TF2("tester",func_sub,0,1,0,1,1);

```

---

<div class="post-metadata">

**Author:** ![Denali\_Jah](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/denali_jah/32/34137_2.png) [@Denali\_Jah](https://root-forum.cern.ch/u/Denali_Jah)\
**Post date:** [February 29, 2024, 3:12pm UTC](https://root-forum.cern.ch/t/tf2-parameters-leads-to-seg-fault/58334/3 "2024-02-29T15:12:58Z")

</div>

Thank you. I really appreciate you taking the time.
