#14501: Fix memory allocation problems in data_structures_pyx.pxi
---------------------------------+------------------------------------------
       Reporter:  dcoudert       |         Owner:  joyner      
           Type:  defect         |        Status:  needs_review
       Priority:  major          |     Milestone:  sage-5.10   
      Component:  group theory   |    Resolution:              
       Keywords:                 |   Work issues:              
Report Upstream:  N/A            |     Reviewers:              
        Authors:  David Coudert  |     Merged in:              
   Dependencies:                 |      Stopgaps:              
---------------------------------+------------------------------------------

Old description:

> The following test causes a segfault on my computer (Intel(R) Xeon(R) CPU
> W3520 @ 2.67GHz / 4GB ram / linux)
> {{{
> sage: G = graphs.CompleteGraph(10)
> sage: GG = G.line_graph().line_graph().line_graph()
> sage: H = GG.relabel(inplace=False)
> sage: GG.is_isomorphic(H)
> ...
> sage: line 135:  3438 Segmentation fault      (core dumped)
> "$SAGE_ROOT/spkg/bin/sage" "$@"
> }}}
> Tracking the segfault, I ended up in the {{{SC_new}}} of
> {{{sage/groups/perm_gps/partn_ref/data_structures_pyx.pxi}}}
>
> This patch fix some assignments performed before testing memory
> allocations and other similar stuff, but does not fix my problem.
>
> Apply:
> * trac_14501.2.patch

New description:

 The following test causes a segfault on my computer (Intel(R) Xeon(R) CPU
 W3520 @ 2.67GHz / 4GB ram / linux)
 {{{
 sage: G = graphs.CompleteGraph(10)
 sage: GG = G.line_graph().line_graph().line_graph()
 sage: H = GG.relabel(inplace=False)
 sage: GG.is_isomorphic(H)
 ...
 sage: line 135:  3438 Segmentation fault      (core dumped)
 "$SAGE_ROOT/spkg/bin/sage" "$@"
 }}}
 Tracking the segfault, I ended up in the {{{SC_new}}} of
 {{{sage/groups/perm_gps/partn_ref/data_structures_pyx.pxi}}} and also in
 the {{{(de)allocate_dc_work_space}}} methods of {{{double_coset.pyx}}}
 file.

 This patch fix some assignments performed before testing memory
 allocations and other similar stuff. Finally, I end up with a proper
 MemoryError and so the problem is solved

 Apply:
 * trac_14501.patch

--

Comment (by dcoudert):

 > In the case at hand, 10 lines after the malloc that you relaced with a
 calloc the whole vector is overwritten with data that makes sense,
 contrary to 0s.

 The point is that if the {{{SC_dealloc}}} function is called before
 assigning something that make sense to SC.generators[i], then sage_free is
 called with unknown argument.

 I did further corrections in this file plus in the {{{double_coset.pyx}}}
 file.
 In both files we had calls to free methods on unassigned pointers.

 Overall these modification solve the problem and now the method raises a
 MemoryError!

 Further cleaning should certainly be done in these files to prevent
 similar errors.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14501#comment:6>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to