Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Re-Allocation Denied #58

Open
DonLocke opened this issue Nov 25, 2024 · 6 comments
Open

Memory Re-Allocation Denied #58

DonLocke opened this issue Nov 25, 2024 · 6 comments

Comments

@DonLocke
Copy link

When running xnec2c with the xnec2c-gao optimizer I regularly get the error Memory re-allocation denied in geometry.c which crashes the application and I unfortunately loose all progress that gao has made.

I don't believe this is a problem with xnec2c-gao, it is simply running the command:
xnec2c --optimize -j7 -i [myFile].nec > /dev/null 2>&1

I'm running xnec2c 4.4.16, installed on Manjaro (Arch-based) linux. I'm not sure where else to look to get better logs to debug the issue.

Thank you for any help you can provide!

@DonLocke
Copy link
Author

After some more testing, I was able to find get a card that always causes the issue, I'm not sure why these specific GW entries cause it to fail though, nothing seems obviously incorrect to me. It's specifically the combination of the two GWs, individually they load fine.

CM 	--- NEC2 Input File created or edited by xnec2c 4.4.16 ---
CM 	Memory re-allocation denied
CE 	--- End Comments ---
GW 	        1	       25	0,3136937	0,42493248	      0,0	0,3136937	-0,42493248	      0,0	   1,6e-3
GW 	        2	       20	0,3131709	0,42493248	      0,0	0,3136937	0,42493248	      0,0	   1,6e-3
GE 	0	0	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00
EX 	0	1	13	0	1,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00
LD 	5	0	0	0	3,70000E+07	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00
NH 	0	0	0	0	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00	0,00000E+00
NE 	0	20	15	1	-1,40000E+00	-1,40000E+00	5,00000E-02	2,00000E-01	2,00000E-01	0,00000E+00
RP 	0	37	73	1000	0,00000E+00	0,00000E+00	5,00000E+00	5,00000E+00	0,00000E+00	0,00000E+00
FR 	        0	       25	0	0	    144,0	   8,0e-2	    146,0
EN

@DonLocke
Copy link
Author

DonLocke commented Nov 26, 2024

It also only starts to fail when GW 2 Segments are >=13, if that helps

@KJ7LNW
Copy link
Owner

KJ7LNW commented Nov 26, 2024

I have not yet looked in detail, but typically these crashes are related to GW line intersections that do not me at a segment vertex, or lines that overlap at least partially. Is this possible?

(Assume floating point error is connected or overlapping within 1e-6.)

@KJ7LNW
Copy link
Owner

KJ7LNW commented Dec 29, 2024

fyi, crash was "fixed" via work-around in unreleased b085ded . The real issue is segment distance problems.

These warnings are not yet committed (soon!), but I have tested them on the file that you gave me in this is what I see:

[warn] Tag 2 segment 44 length 2.614e-05 is too short compared to tag 1 segment 1 length 3.399e-02; These segments are close enough that connection detection issues may occur
[warn] Tag 2 segment 45 length 2.614e-05 is too short compared to tag 1 segment 1 length 3.399e-02; These segments are close enough that connection detection issues may occur

[warn] tag=2/seg=44: length=2.614e-05 too short (and close enough) compared to tag=1/seg=1 length=3.399e-02; connection detection may fail
[warn] tag=2/seg=45: length=2.614e-05 too short (and close enough) compared to tag=1/seg=1 length=3.399e-02; connection detection may fail
[err] tag=2/seg=26: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=27: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=28: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=29: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=30: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=31: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=32: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=33: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=34: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=35: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=36: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=37: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)
[err] tag=2/seg=38: length/radius ratio of 0.0 < 2.0; standard thin-wire kernel field error exceeds 1% by a large margin (min=2.0, 1%accurate=8.0)

KJ7LNW pushed a commit that referenced this issue Dec 29, 2024
Add comprehensive geometry validation that checks:

1. Segment self-connections:
- Detects segments that would connect to themselves
- Validates endpoint separation distances

2. Segment overlaps:
- Checks for unintended segment proximity
- Validates segment spacing against connection thresholds
- Detects potential unwanted connections

3. Length ratio validation:
- Verifies relative segment lengths
- Checks for problematic length differences
- Validates connection detection with varying lengths

4. Wavelength ratio validation:
- Validates segment length vs wavelength (0.001-0.1λ)
- Checks high accuracy regions (<0.05λ)
- Improves error messages for ratio violations

5. Kernel ratio validation:
- Validates length/radius ratios for thin-wire kernels
- Standard kernel (2.0-8.0 range)
- Extended kernel (0.5-2.0 range)
- Maintains accurate 1% error threshold reporting

Refactor connection checking in conect():
- Add helper functions for consistent calculations:
  * calc_manhattan_distance() - fast endpoint distance check
  * calc_connection_threshold() - segment-specific connection limit
  * points_would_connect() - unified connection test
- Pre-allocate connection buffer based on typical wire geometry
  (2 connections per segment plus extra for junctions)
- Replace repeated distance calculations with helper functions
- Consolidate connection logic into reusable functions
- Improve readability of connection tests

Call validation after reading geometry and show warnings for issues.

Fixes #58

Signed-off-by: Eric Wheeler <[email protected]>
@KJ7LNW
Copy link
Owner

KJ7LNW commented Dec 29, 2024

Please build the segment-tests branch if you would like to test the additional verifications.

@DonLocke
Copy link
Author

DonLocke commented Jan 5, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants