I'm getting multiple exception errors resulting in a segfault when trying 
to control how long SageMath spends on structure_description() of a finite 
group. I'll attach a MWE and traceback, but basically what I'm doing is:

creating a Finite Group with ~10-20 generators and ~half that relations.

Setting an alarm...
running structure_description() with three possible outcomes of 
try...except:
* it works, tell me the result
* it fails, GAP knows why and I take over
* It fails because of the alarm timeout

Running this code in a loop eventually results in a segfault, probably with 
some conflict between the alarm and GAP exceptions, but the traceback 
suggests it's a problem in the free_group module...anyone have any thoughts?

[running code resulting in crash....]

Group Type is: --
20 [[9, 6, 2, 8], [8, 8], [10], [7, 2, 14, 4], [8], [14, 2, 6], [2, 10], 
[7, 9, 2], [10, 6, 8, 2], [13, 6, 11, 8], [3], [3]]
Finitely presented group < x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, 
x11, x12, x13, x14 | x8*x5*x1*x7, x7^2, x9, x6*x1*x13*x3, x7, x13*x1*x5, 
x1*x9, x6*x8*x1, x9*x5*x7*x1, x12*x5*x10*x7, x2, x2 >
Some Unhandled exception!
Group Type is: --
21 [[5, 11, 6, 11], [1], [7, 11, 12], [14, 4], [7], [1], [10, 4], [14], [8, 
11, 10, 1], [10, 10, 4], [10, 12], [12, 10, 14, 10]]
Traceback (most recent call last):
  File 
"/home/cduston/Downloads/SageMath/local/lib/python3.7/site-packages/sage/groups/free_group.py",
 
line 881, in _element_constructor_
    P = x.parent()
AttributeError: 'list' object has no attribute 'parent'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "MWE.sage.py", line 39, in <module>
    G=H/[H(Y[i]) for i in range(g*V)]
  File "MWE.sage.py", line 39, in <listcomp>
    G=H/[H(Y[i]) for i in range(g*V)]
  File "sage/structure/parent.pyx", line 900, in 
sage.structure.parent.Parent.__call__ 
(build/cythonized/sage/structure/parent.c:9218)
  File "sage/structure/coerce_maps.pyx", line 156, in 
sage.structure.coerce_maps.DefaultConvertMap_unique._call_ 
(build/cythonized/sage/structure/coerce_maps.c:4448)
  File 
"/home/cduston/Downloads/SageMath/local/lib/python3.7/site-packages/sage/groups/free_group.py",
 
line 883, in _element_constructor_
    return self.element_class(self, x, **kwds)
  File 
"/home/cduston/Downloads/SageMath/local/lib/python3.7/site-packages/sage/groups/free_group.py",
 
line 230, in __init__
    AbstractWordTietzeWord = libgap.eval('AbstractWordTietzeWord')
  File "sage/libs/gap/libgap.pyx", line 400, in 
sage.libs.gap.libgap.Gap.eval (build/cythonized/sage/libs/gap/libgap.c:4205)
  File "sage/libs/gap/util.pyx", line 395, in sage.libs.gap.util.gap_eval 
(build/cythonized/sage/libs/gap/util.c:5990)
cysignals.signals.SignalError: Segmentation fault


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/36aed71a-552b-4e09-a3ab-172a50d90547n%40googlegroups.com.
"""
This script will try to replicate the multiple exception call
errors I am getting without all the excess baggage associated with
the Fox Algorithm.
"""
g=3 # Covers, but this is just a multiplicative factor here
E=5 # edges in the graph
V=4 # Sides in the graph (relations)
W=5 # Max word size for the relations

H=FreeGroup(E*g)

N=1000
ExCases = 0 # To keep track of exceptional cases....
for i in range(N):
    
    # Randomly create some relations
    Y = []
    for j in range(V*g):
        YY = []
        for k in range(randrange(1,W)):
            num = randrange(1,g*E)
            sign = randrange(1,2) # positive or negative
            if sign == 1:
                YY.append(num)
            elif sign == 2:
                YY.append(-num)
        #print(YY)
        Y.append(YY)
    print(i,Y)

    # Now calculate the structure of the group
    G=H/[H(Y[i]) for i in range(g*V)]
    print(G)

    alarm(5)
    try:
        grpstr = str(G.structure_description())
    except ValueError:
        if G.simplified().relations() == ():
            grpstr = "F" + str(G.simplified().ngens())
        else:
            grpstr = "--"
            ExCases += 1
            pass
    except AlarmInterrupt:
        grpstr = "--"
        ExCases += 1
        pass
    except:
        print("Some Unhandled exception!")
    cancel_alarm()

    print("Group Type is:",grpstr)
print("Exceptional cases:",ExCases)

Reply via email to