#12266: 3^3^3^3 segfaults
-------------------------+--------------------------------------------------
Reporter: vbraun | Owner: jason, jkantor
Type: defect | Status: new
Priority: major | Milestone: sage-5.0
Component: numerical | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
-------------------------+--------------------------------------------------
Comment(by was):
A remark from Bill Hart about what is going on:
{{{
Hi William,
It appears to eventually call __gmp_tmp_reentrant_alloc. Here is that
function:
__gmp_tmp_reentrant_alloc (struct tmp_reentrant_t **markp, size_t size)
{
char *p;
size_t total_size;
#define P ((struct tmp_reentrant_t *) p)
total_size = size + HSIZ;
p = (*__gmp_allocate_func) (total_size);
P->size = total_size;
P->next = *markp;
*markp = P;
return p + HSIZ;
}
As you can see, there is no state stored here. It merely calls
__gmp_allocate_func. Here is that latter function:
void * (*__gmp_allocate_func) _PROTO ((size_t)) = __gmp_default_allocate;
void *
__gmp_default_allocate (size_t size)
{
void *ret;
#ifdef DEBUG
size_t req_size = size;
size += 2 * BYTES_PER_MP_LIMB;
#endif
ret = malloc (size);
if (ret == 0)
{
#if defined _MSC_VER && defined _WIN64
fprintf (stderr, "GNU MP: Cannot allocate memory (size=%llu)\n",
size);
#else
fprintf (stderr, "GNU MP: Cannot allocate memory (size=%u)\n", size);
#endif
abort ();
}
#ifdef DEBUG
{
mp_ptr p = ret;
p++;
p[-1] = (0xdeadbeef << 31) + 0xdeafdeed;
if (req_size % BYTES_PER_MP_LIMB == 0)
p[req_size / BYTES_PER_MP_LIMB] = ~((0xdeadbeef << 31) + 0xdeafdeed);
ret = p;
}
#endif
return ret;
}
As you can see, it is just a simple call to malloc, plus an abort if
malloc fails. So I don't think this is a problem in MPIR, unless MPIR
is being built in malloc-notreentrant mode (note that alloca or
malloc-reentrant is the default).
So I don't know what you mean by "properly dealing with this sort of
thing". Did you have something particular in mind?
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12266#comment:2>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.