# Illegal pointer to class object back 0x0 165

**URL:** <https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084>\
**Category:** ROOT\
**Created:** [May 4, 2016, 7:13am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084 "2016-05-04T07:13:30Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esther](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@Esther](https://root-forum.cern.ch/u/Esther)\
**Post date:** [May 4, 2016, 7:13am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/1 "2016-05-04T07:13:30Z")

</div>

Hi every one!  
I want to subtract background of spectrum. I use the “TSpectrum.h”, but, I get the error “illegal pointer to class object back”, although I get all library.  
Would you mind fixing the problem!  
Thank every one too much!  
P/s: I attached the file  
[background.C](https://root-forum.cern.ch/uploads/default/original/2X/a/a138811baaef41bab20bb1bb6f5d3ed120b7cfa3.C) (1.12 KB)

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 4, 2016, 7:21am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/2 "2016-05-04T07:21:11Z")

</div>

If you “recreate” your file, there is nothing to “Get” from it.

---

<div class="post-metadata">

**Author:** ![Esther](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@Esther](https://root-forum.cern.ch/u/Esther)\
**Post date:** [May 4, 2016, 9:11am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/3 "2016-05-04T09:11:31Z")

</div>

However, When i use the exist root file in folder, this mistake didn’t fix. So, I don’t understand how to pointer to class although I call all library.  
Thank you so much!

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 4, 2016, 9:41am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/4 "2016-05-04T09:41:28Z")

</div>

Attach your root file.

---

<div class="post-metadata">

**Author:** ![Esther](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@Esther](https://root-forum.cern.ch/u/Esther)\
**Post date:** [May 5, 2016, 3:16am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/5 "2016-05-05T03:16:01Z")

</div>

This is the root file.  
[khongbia\_7200s\_03042016.root](https://root-forum.cern.ch/uploads/default/original/2X/d/d93fbc50e110af510e3d11c6c1e97228928b7da9.root) (306 Bytes)

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 5, 2016, 5:07am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/6 "2016-05-05T05:07:25Z")

</div>

This seems to be a broken / completely empty file:  
root [0] TFile \*f = TFile::Open(“khongbia\_7200s\_03042016.root”);  
Warning in TFile::Init: file khongbia\_7200s\_03042016.root has no keys  
Warning in TFile::Init: no StreamerInfo found in khongbia\_7200s\_03042016.root therefore preventing schema evolution when reading this file.

---

<div class="post-metadata">

**Author:** ![Esther](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@Esther](https://root-forum.cern.ch/u/Esther)\
**Post date:** [May 5, 2016, 7:54am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/7 "2016-05-05T07:54:45Z")

</div>

I use the new .rootfile (attached file). The warning don’t show. However, the mistake don’t be fixed.  
[AF11225\_5\_20\_20\_day5\_7200\_12042016.root](https://root-forum.cern.ch/uploads/default/original/2X/6/6cf7f7c4dc6442ecb2ee183cfbd2bf40bba1e67c.root) (8.11 KB)

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 5, 2016, 8:02am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/8 "2016-05-05T08:02:32Z")

</div>

There is just a single “h1” histogram (no “back1”) in your file:  
root [0] TFile _f = TFile::Open(“AF11225\_5\_20\_20\_day5\_7200\_12042016.root”)  
root [1] f-\>ls()  
TFile_\* AF11225\_5\_20\_20\_day5\_7200\_12042016.root  
TFile\* AF11225\_5\_20\_20\_day5\_7200\_12042016.root  
KEY: TH1F h1;1 energy vs count

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 5, 2016, 9:34am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/9 "2016-05-05T09:34:40Z")

</div>

Try the attached macro.  
[background.C](https://root-forum.cern.ch/uploads/default/original/2X/d/d34e61615124c65a76a7a5f7fef340a0b504bb73.C) (1.68 KB)

---

<div class="post-metadata">

**Author:** ![Esther](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@Esther](https://root-forum.cern.ch/u/Esther)\
**Post date:** [May 9, 2016, 5:10am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/10 "2016-05-09T05:10:30Z")

</div>

I try!  
Thanks !

---

<div class="post-metadata">

**Author:** ![Esther](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@Esther](https://root-forum.cern.ch/u/Esther)\
**Post date:** [May 9, 2016, 7:09am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/11 "2016-05-09T07:09:28Z")

</div>

It done!  
Thank you so much!

---

<div class="post-metadata">

**Author:** ![Esther](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8c91f0/32.png) [@Esther](https://root-forum.cern.ch/u/Esther)\
**Post date:** [May 10, 2016, 4:57am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/12 "2016-05-10T04:57:06Z")

</div>

Hi everyone!  
I use the Ubuntu running with VMware. I run the file.cpp and get the mistake  
 " \*\*\* Break \*\*\* segmentation violation  
 #0 0xb77accb0 in ?? ()  
Root \> Function lamtron() busy flag cleared "   
when I want to open the TBrowser b().  
Can you fix it?  
Thank u too much.

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 10, 2016, 6:26am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/13 "2016-05-10T06:26:30Z")

</div>

As you can see, the “lamtron()” function (defined and called from “file.cpp”?) breaks -\> you need to fix it.

---

<div class="post-metadata">

**Author:** ![Wukong](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/8491ac/32.png) [@Wukong](https://root-forum.cern.ch/u/Wukong)\
**Post date:** [May 10, 2016, 2:15pm UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/14 "2016-05-10T14:15:35Z")

</div>

> [@Pepe Le Pew](#):
>
> As you can see, the “lamtron()” function (defined and called from “file.cpp”?) breaks → you need to fix it.

How to fix this fail???

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 10, 2016, 2:18pm UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/15 "2016-05-10T14:18:45Z")

</div>

Without any source code … how is anybody here to know “how to fix some bug”?

---

<div class="post-metadata">

**Author:** ![Wukong](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/8491ac/32.png) [@Wukong](https://root-forum.cern.ch/u/Wukong)\
**Post date:** [May 11, 2016, 2:01am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/16 "2016-05-11T02:01:45Z")

</div>

> [@Pepe Le Pew](#):
>
> Without any source code … how is anybody here to know “how to fix some bug”?

this is source code  
Thank so much!!!  
[lamtron.cpp](https://root-forum.cern.ch/uploads/default/original/2X/1/1f50a38f5bddae5726056c1e09822a8706bce133.cpp) (2.74 KB)

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [May 11, 2016, 6:58am UTC](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/17 "2016-05-11T06:58:59Z")

</div>

Your “Mau AF11225\_5x20x20.TKA” and “Khongbia.TKA” data files are also needed in order to run your macro.

The first problem that I see is that you have:  
const int n = 2000000;  
Double\_t y1[n],y[n];  
and this uses more than 30MB on “stack” (quite often, the “stack” is limited to something like 8MB).  
See, for example: [No error when macro crashes](https://root-forum.cern.ch/t/no-error-when-macro-crashes/14931/2)

You also try to create two TFile objects with names which end with “.pdf” (which suggests “Adobe PDF” files, not ROOT files).

Notes:

1. Always try to precompile your macro using ACLiC, in order to find source code problems, e.g. try something like (inspect all reported warnings and errors):  
root [0] .L YourRootMacro.cxx++
2. You can “debug” many problems using “valgrind”. See, for example: [Segmentation Fault depending on linux distribution](https://root-forum.cern.ch/t/segmentation-fault-depending-on-linux-distribution/18020/6)
