You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segmentation fault at garbage collection after running ab09nd with return value of nr=0 #242
I'm using ab09nd to reduce systems. Mildly by accident we are putting in a large system and choosing inputs/outputs that don't touch any of the dynamics. The function correctly reduces the system to size zero on output, but for some reason this now causes a segmentation fault.
I've compiled Slycot with -fcheck=all -fbacktrace -Og -g -Wall, but the segfault only occurs after garbage collection, and will occur immediately if you force collection using 'import gc; gc.collect()'
somehow this output case needs to be handled better by f2py or the wrapper instructions.
Attached is a yaml file with the system A,B,C,D that triggers the bug when run with dico = 'C', job = 'B', equil = 'S'
On Debian 12 system running on x86_64 system via WSL, with the script below I get munmap_chunk(): invalid pointer on system exit after running this code. The same thing happens if ab09nd is only called once, and the gc.collect call is omitted. Differently from the report, I don't get a segfault the instant gc.collect() is called, but not sure that is really significant.
This Slycot 0.6.0 installed from conda-forge.
I've attached the conda environment file, though not it's not minimal since I installed jupyterlab to investigate.
compare with doc for AB09ND.f comment, fairly sure iwork calc is a bug:
C Workspace
C
C IWORK INTEGER array, dimension (MAX(1,2*N))
C On exit, if INFO = 0, IWORK(1) contains the order of the
C minimal realization of the ALPHA-stable part of the
C system.
C
here's a simpler reproducer, on which I'll base a unit test. The much-too-small iwork means AB09ND stomps all over the stack, giving wrong dr, and ultimately breaks everything.
Program:
import gc
import numpy as np
import slycot
import yaml
n = 67
m = 1
p = 1
a = -np.eye(n)
b = np.zeros((n, m))
c = np.zeros((p, n))
d = np.array([[42.24]])
nr, ar, br, cr, dr, ns, hsv = \
slycot.ab09nd(dico='C', job='B', equil='S', n=a.shape[0],
m=b.shape[1], p=c.shape[0], A=a, B=b, C=c, D=d)
print(f'{nr=}, {dr=}')
Activity
roryyorke commentedon Dec 22, 2024
Thanks for the report.
On Debian 12 system running on x86_64 system via WSL, with the script below I get
munmap_chunk(): invalid pointeron system exit after running this code. The same thing happens ifab09ndis only called once, and thegc.collectcall is omitted. Differently from the report, I don't get a segfault the instantgc.collect()is called, but not sure that is really significant.This Slycot 0.6.0 installed from conda-forge.
I've attached the conda environment file, though not it's not minimal since I installed jupyterlab to investigate.
Output:
Script:
roryyorke commentedon Dec 22, 2024
gh242.zip
bnavigator commentedon Dec 22, 2024
Thanks @roryyorke. I can reproduce on openSUSE Tumbleweed with the system package python311-slycot 0.6.0-1.3.
So that rules out the conda-forge build being significant.
roryyorke commentedon Dec 23, 2024
this seems to fix it
compare with doc for AB09ND.f comment, fairly sure iwork calc is a bug:
roryyorke commentedon Dec 23, 2024
here's a simpler reproducer, on which I'll base a unit test. The much-too-small iwork means AB09ND stomps all over the stack, giving wrong
dr, and ultimately breaks everything.Program:
Result pre-fix:
Post-fix: