# Crash with std::bad\_array\_new\_length while loading large ensight gold case file

**URL:** https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631
**Category:** ParaView Support
**Created:** [March 5, 2021, 8:46pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631 "2021-03-05T20:46:53Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![flotus1](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@flotus1](https://discourse.paraview.org/u/flotus1)
#### Post date: [March 5, 2021, 8:46pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/1 "2021-03-05T20:46:53Z")

</div>

My first time trying to open a rather large ensight gold case file (~400 million hexa8 elements, 100 time steps, 1 scalar, 1 3D vector) did not go so well.  
This is the first time I am having this issue, smaller cases (let’s say around 200 million elements, total file size was larger than the case I am having trouble with, due to higher number of time steps) worked like a charm.

What I did: open PV, open case file, click “Apply”.  
PV 5.6 crashes with the following output to shell:  
terminate called after throwing an instance of ‘std::bad\_array\_new\_length’  
what(): std::bad\_array\_new\_length  
Aborted (core dumped)

So I downloaded the latest version 5.9 and tried again, with -l=pv\_debug.txt,TRACE  
It still crashes, here is the output I get:  
[pv\_59\_shell.txt](https://discourse.paraview.org/uploads/short-url/5cEsudhQkbcJAeMHcijd1GeKvDt.txt) (14.1 KB)  
[pv\_59\_debug.txt](https://discourse.paraview.org/uploads/short-url/1YtbojHZK5lESCw0CwZ2OM6DTNq.txt) (320.1 KB)

Did I do something wrong, or have I run into a software limitation?

---

<div class="post-metadata">

### Author: ![flotus1](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@flotus1](https://discourse.paraview.org/u/flotus1)
#### Post date: [March 8, 2021, 8:45pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/2 "2021-03-08T20:45:06Z")

</div>

I dug a little deeper. I am reasonably certain that my ensight geo file is fine according to the documentation.  
I wrote a small routine that reads it, and does some plausibility checks.

However, running ens\_checker tool on that file, it claims that some of the node indices are negative. Which is not the case according to my check routine. Weirdly enough, ens\_checker reports the first error as:  
For hexa8 element number 67108864:  
connectivity element 6, is given as -144802628  
This is beyond the number of nodes (373714618) in this part

67108864 elements x (8 nodes per element) x (4 byte per node) = 2147483648 byte = 2^31 byte.  
In the documentation for ensight gold file format, I found no mention of such a limit. And I would expect that ens\_checker would warn about the amount of elements being too high, if elements x nodes exceeds such a limit.  
Any ideas would be welcome.

---

<div class="post-metadata">

### Author: ![flotus1](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@flotus1](https://discourse.paraview.org/u/flotus1)
#### Post date: [March 9, 2021, 4:26pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/3 "2021-03-09T16:26:25Z")

</div>

My conclusion for now:

- my export routine works correctly, at least according to the ensight gold file format documentation
- the documentation mentions no element or node count limits with unformatted files. There are file size limits, but I am way below them
- ens\_checker fails as soon as one field is larger than 2^31 Byte. In my case the field with 8 node indices for each hexa8 element
- Paraview is a bit more lenient, but fails as soon as (number of elements x number of nodes per element) exceeds 2^31. Even if the actual number of nodes is lower, due to many elements sharing the same nodes
- I wasted a lot of time with ensight gold file format

---

<div class="post-metadata">

### Author: ![Thomas\_Caissard](https://discourse.paraview.org/user_avatar/discourse.paraview.org/thomas_caissard/32/5950_2.png) [@Thomas\_Caissard](https://discourse.paraview.org/u/Thomas_Caissard)
#### Post date: [March 9, 2021, 4:48pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/4 "2021-03-09T16:48:44Z")

</div>

Are you using a 32b machine? It looks like the number of element the reader is trying to allocates exceeds what size\_t can hold

---

<div class="post-metadata">

### Author: ![flotus1](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@flotus1](https://discourse.paraview.org/u/flotus1)
#### Post date: [March 9, 2021, 4:56pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/5 "2021-03-09T16:56:35Z")

</div>

That would explain some things, but no. 64bit

---

<div class="post-metadata">

### Author: ![Thomas\_Caissard](https://discourse.paraview.org/user_avatar/discourse.paraview.org/thomas_caissard/32/5950_2.png) [@Thomas\_Caissard](https://discourse.paraview.org/u/Thomas_Caissard)
#### Post date: [March 9, 2021, 4:59pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/6 "2021-03-09T16:59:05Z")

</div>

Would you be able to give us the dataset ?

---

<div class="post-metadata">

### Author: ![flotus1](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@flotus1](https://discourse.paraview.org/u/flotus1)
#### Post date: [March 9, 2021, 5:07pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/7 "2021-03-09T17:07:32Z")

</div>

The .geo file is about 14GiB. I don’t think I can upload that anywhere.

I might have some idea why ens\_checker fails. The way I have to open the files in fortran for writing differs depending on where I want to use them. Found via trial&error:

```
open(output_unit,file=trim(adjustl(out_file)), status='replace', action='write', form='unformatted', access='stream') ! for paraview
open(output_unit,file=trim(adjustl(out_file)), status='replace', action='write', form='unformatted') ! for ens_checker

```

I guess the latter is record-based?, and the record length might be limited by a 32bit integer. Just a guess, not that I knew a whole lot about that. And I can read it just fine with my own program. But it’s besides the point anyway, I need Paraview to read it, and don’t care too much about ens\_checker at this point.

---

<div class="post-metadata">

### Author: ![bmk](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@bmk](https://discourse.paraview.org/u/bmk)
#### Post date: [July 22, 2021, 11:55am UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/8 "2021-07-22T11:55:21Z")

</div>

hi @flotus1 , I am also facing the same issue with larges ensight gold files.  
In my case however the size of elements are different.  
I have two poly-hexcore meshes, one with ~70 million elements (nodes little less than 100 million) and the other with 140 million elements (nodes around 250 million).  
I am using Linux and Paraview 5.4.1 version. The same python script works for 70M elements but crashes with bad\_array\_new\_length error for 140M elements.

I can see total number of nodes is less than 2^31 but it still crashes.

Did you find a way to fix this or is there any other workaround for this ?  
Thank you in advance

---

<div class="post-metadata">

### Author: ![flotus1](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@flotus1](https://discourse.paraview.org/u/flotus1)
#### Post date: [July 22, 2021, 12:39pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/9 "2021-07-22T12:39:48Z")

</div>

hi @bmk : I can kind of see why your limits might be different with polyhedral cells. The relevant limit for paraview seems to be the amount of “unmerged” vertices. I.e. PV treats the vertices of each element separately during import, resulting in a much larger amount of vertices. With hexa8 elements, I have 8 “unmerged” vertices per element. You probably have more due to polyhedral cells.  
Unfortunately, I don’t know of any workaround for this bug that doesn’t involve switching to a different file format entirely.

---

<div class="post-metadata">

### Author: ![bmk](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/bb73d2/32.png) [@bmk](https://discourse.paraview.org/u/bmk)
#### Post date: [July 22, 2021, 1:40pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/10 "2021-07-22T13:40:06Z")

</div>

Ohk, Thanks for the quick response. @flotus1

What other format can I try ? cgns?

---

<div class="post-metadata">

### Author: ![flotus1](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@flotus1](https://discourse.paraview.org/u/flotus1)
#### Post date: [July 22, 2021, 1:52pm UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/11 "2021-07-22T13:52:22Z")

</div>

Yeah, CGNS would be the obvious choice. Or VTK if that still ticks all your boxes.  
I didn’t get around to changing my implementation to CGNS yet, but that’s my plan for the future.

---

<div class="post-metadata">

### Author: ![Louis\_Gombert](https://discourse.paraview.org/user_avatar/discourse.paraview.org/louis_gombert/32/14576_2.png) [@Louis\_Gombert](https://discourse.paraview.org/u/Louis_Gombert)
#### Post date: [October 23, 2024, 9:23am UTC](https://discourse.paraview.org/t/crash-with-std-bad-array-new-length-while-loading-large-ensight-gold-case-file/6631/12 "2024-10-23T09:23:41Z")

</div>

Hello, for information the overflow issue in the Ensight Gold reader has been [fixed in VTK](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/11518) and is now available in ParaView nightly builds (or next release)
