# Valid code leads to allocation memory excess or segmentation violation

**URL:** <https://forums.developer.nvidia.com/t/valid-code-leads-to-allocation-memory-excess-or-segmentation-violation/253197>\
**Category:** nvc, nvc++ and nvfortran\
**Tags:** nvbugs\
**Created:** [May 13, 2023, 12:19pm UTC](https://forums.developer.nvidia.com/t/valid-code-leads-to-allocation-memory-excess-or-segmentation-violation/253197 "2023-05-13T12:19:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juergen.reuter](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/juergen.reuter/32/38283_2.png) [@juergen.reuter](https://forums.developer.nvidia.com/u/juergen.reuter)\
**Post date:** [May 13, 2023, 12:19pm UTC](https://forums.developer.nvidia.com/t/valid-code-leads-to-allocation-memory-excess-or-segmentation-violation/253197/1 "2023-05-13T12:19:59Z")

</div>

The attached code, when compiled with nvfortran 23.1 and executed, leads to the error message:  
0: ALLOCATE: 3298534884208 bytes requested; not enough memory  
There could be an error in calculating the address space indices or so!?  
When removing the finalizers and a bit of oter code the code leads to a segmentation violation.  
Reproducer has ca. 1.8k lines.  
[alloc\_exceed\_mem.f90](https://forums.developer.nvidia.com/uploads/short-url/rzudZIXA1Tpw9mRzv67Fp2dSMM7.f90) (55.0 KB)

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [May 15, 2023, 5:02pm UTC](https://forums.developer.nvidia.com/t/valid-code-leads-to-allocation-memory-excess-or-segmentation-violation/253197/2 "2023-05-15T17:02:56Z")

</div>

Hi Juergen,

Looks like this one may have been fixed already as I can reproduce the issue in 23.1 but not in 23.3. Can you try updating to 23.3 to see if it fix it for you as well?

> **[NVIDIA HPC SDK Current Release Downloads](https://developer.nvidia.com/hpc-sdk-downloads)**
>
> Select Target Platform Click on the green buttons that describe your target platform. Only supported platforms will be shown. By downloading and using the software, you agree to fully comply with the terms and conditions of the HPC SDK Software...

```auto
% nvfortran alloc_exeed_mem.f90 -V23.1; a.out
* Test output: sf_base_13
* Purpose: initialize and fill a pair generator object

* Initialize configuration data

* Initialize generator object

0: ALLOCATE: 3298534884208 bytes requested; not enough memory
% nvfortran alloc_exeed_mem.f90 -V23.3 ; a.out
* Test output: sf_base_13
* Purpose: initialize and fill a pair generator object

* Initialize configuration data

* Initialize generator object

 inside sf_test_generator_init ++++++++++++++++
* Generate free r values

```

-Mat

---

<div class="post-metadata">

**Author:** ![juergen.reuter](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/juergen.reuter/32/38283_2.png) [@juergen.reuter](https://forums.developer.nvidia.com/u/juergen.reuter)\
**Post date:** [May 17, 2023, 3:04pm UTC](https://forums.developer.nvidia.com/t/valid-code-leads-to-allocation-memory-excess-or-segmentation-violation/253197/3 "2023-05-17T15:04:53Z")

</div>

Yes, I confirm that I don’t see this problem any more with nvfortran 23.3.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [May 31, 2023, 3:05pm UTC](https://forums.developer.nvidia.com/t/valid-code-leads-to-allocation-memory-excess-or-segmentation-violation/253197/4 "2023-05-31T15:05:30Z")

</div>

Closed on May 31, 2023, 3:05pm UTC

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