# Possible bug in schema evolution with TClonesArray

**URL:** <https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918>\
**Category:** ROOT\
**Tags:** bug\
**Created:** [June 26, 2026, 8:24pm UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918 "2026-06-26T20:24:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sghinesc](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/4af34b/32.png) [@sghinesc](https://root-forum.cern.ch/u/sghinesc)\
**Post date:** [June 26, 2026, 8:24pm UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/1 "2026-06-26T20:24:49Z")

</div>

* * *

_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_

### Describe the bug

I have encountered a potential issue in the case one tries to alter, via pragma instructions in LinkDef, the contetns of a class while reading it from a file if the class is stored as part of a TClonesArray. What we observe is that even if the class is not modified, adding an instruction in the linkdef to access the ‘onfile’ memeber crashes the execution of the program. This seems to happen only if the class in question is stored as part of a TClonesArray (storing it as a part of a vector works OK).

Just to give a bit of context, we are attempting this in order to correct ‘on the fly’ the data stored in a class in a wrong way.  
Increasing the classdef and adding/removing other memebers does not help.

### Expected behavior

The data member(s) should be modifiable without crashes. It works with `std::vector`  
[MWE.zip](https://root-forum.cern.ch/uploads/short-url/rQ0qLC9nXfLnGbgGPFl1roQLYCC.zip) (2.6 KB)

### To Reproduce

Steps to reproduce the behavior:

1. Unzip MWE.zip and `cd` to that directory.
2. `$mkdir build && cd build && cmake ../ && make`
3. Run ‘write’ step with `./main 1`
4. Uncomment the pragma lines in `Linkdef.hh`
5. Run ‘read’ step with `./main 2`

### Setup

```auto
ROOT v6.38.04
Built for linuxx8664gcc on Mar 12 2026, 21:22:56
From tags/6-38-04@6-38-04
With std202002
Binary directory: /home/stefan/miniconda3/envs/na62/bin

```

via conda

### Additional context

Edit: This problem does not occur with ROOT v6.32

Thanks for any help with this,  
Stefan,  
NA62 sw coordinator

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [June 28, 2026, 9:10pm UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/2 "2026-06-28T21:10:10Z")

</div>

Thank you for the report! I can confirm the issue and I moved this to Github: [I/O customization rules crash with TClonesArray · Issue #22725 · root-project/root · GitHub](https://github.com/root-project/root/issues/22725)

---

<div class="post-metadata">

**Author:** ![sghinesc](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/4af34b/32.png) [@sghinesc](https://root-forum.cern.ch/u/sghinesc)\
**Post date:** [June 29, 2026, 8:35am UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/3 "2026-06-29T08:35:11Z")

</div>

Thanks for the quick reply. Is there any workaround we can use until the patch is available?

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [June 29, 2026, 4:11pm UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/4 "2026-06-29T16:11:18Z")

</div>

A possible workaround is writing an I/O rule for the parent class (`class A` in the example). This rule would leave `target` and `source` empty (set to empty string), so that it operates on the whole object once read from disk. The `code` section of that rule would then need to loop through the `TClonesArray` member and fix it up.

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [June 29, 2026, 4:24pm UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/5 "2026-06-29T16:24:59Z")

</div>

Actually, you can also put the the whole class rule directly on `Class B` (the member of the `TClonesArray`). Also, you can put the fixup code in a method that you call from the I/O rule. That can make the `#pragma` statement a little more digestable.

EDIT: you can access the object to be fixed up in the `code = "{...}"` block through the `newObj` pointer.

---

<div class="post-metadata">

**Author:** ![sghinesc](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/4af34b/32.png) [@sghinesc](https://root-forum.cern.ch/u/sghinesc)\
**Post date:** [June 30, 2026, 8:29am UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/6 "2026-06-30T08:29:41Z")

</div>

Thank you for the suggestion. I want to confirm that the following `#pragma` seems to work (at least in the MWE).

```auto
#pragma read sourceClass = "ClassB"\
         version = "[1]" \
    source = "" \
    targetClass = "ClassB" \
    target = "" \
    code = "{ newObj->SetField2(newObj->GetField2() + 2);}"

```

Is this what you meant, @jblomer?

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [June 30, 2026, 8:45am UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/7 "2026-06-30T08:45:24Z")

</div>

Yes, if this is workable for you, I’d suggest this as a workaround for the time being.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 14, 2026, 8:46am UTC](https://root-forum.cern.ch/t/possible-bug-in-schema-evolution-with-tclonesarray/64918/8 "2026-07-14T08:46:16Z")

</div>

Closed on July 14, 2026, 8:46am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
