Cygwin64: allocating too much memory causes a crash (corrected)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Cygwin64: allocating too much memory causes a crash (corrected)

Bengt Larsson-4
(I'm sorry I attached the wrong file. This should be right.)

On Cygwin64, if I malloc too much memory I get a stackdump, instead of a
NULL in return (for example testmalloc 5000000000).


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

testmalloc.c (468 bytes) Download Attachment
testmalloc.exe.stackdump (1K) Download Attachment
cygcheck.out (21K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Cygwin64: allocating too much memory causes a crash (corrected)

Corinna Vinschen-2
On Sep 10 18:02, Bengt Larsson wrote:
> (I'm sorry I attached the wrong file. This should be right.)
>
> On Cygwin64, if I malloc too much memory I get a stackdump, instead of a
> NULL in return (for example testmalloc 5000000000).

Sorry for the late reply, I was abroad for a couple of weeks.

I just tried it myself and could easily reproduce the problem.
I found the culprit in mmap.  It was using DWORD instead of size_t
for a variable which was used for rounding purposes.  This accidentally
restricted the length of any allocation to < 4 Gigs(*).  When called
from malloc, malloc would get a valid pointer, pointing to a too small
memory block.  Writing the malloc fencepost then crashed.

Thanks for the report and especially the testcase!  I applied a fix
and will provide a new developer snapshot with this fix on
http://cygwin.com/snapshots/ soon.


Corinna

(*) Naturally the 32 bit version would never see this problem...

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (853 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Cygwin64: allocating too much memory causes a crash (corrected)

Ryan Johnson-10
On 15/10/2013 4:18 AM, Corinna Vinschen wrote:

> On Sep 10 18:02, Bengt Larsson wrote:
>> (I'm sorry I attached the wrong file. This should be right.)
>>
>> On Cygwin64, if I malloc too much memory I get a stackdump, instead of a
>> NULL in return (for example testmalloc 5000000000).
> Sorry for the late reply, I was abroad for a couple of weeks.
>
> I just tried it myself and could easily reproduce the problem.
> I found the culprit in mmap.  It was using DWORD instead of size_t
> for a variable which was used for rounding purposes.
You know, this might be only the second 32->64 migration hiccup I've
seen since the dust settled (the other being in gettimeofday or some such).

That's really impressive, given the number of places in the code where a
DWORD (or other 32-bit value) could make things go really wrong...

Ryan


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: Cygwin64: allocating too much memory causes a crash (corrected)

Bengt Larsson-4
In reply to this post by Corinna Vinschen-2
Corinna Vinschen wrote:

>Thanks for the report and especially the testcase!  I applied a fix
>and will provide a new developer snapshot with this fix on
>http://cygwin.com/snapshots/ soon.

Thank you Corinna.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: Cygwin64: allocating too much memory causes a crash (corrected)

Bengt Larsson-4
In reply to this post by Corinna Vinschen-2
Corinna Vinschen wrote:

>Thanks for the report and especially the testcase!  I applied a fix
>and will provide a new developer snapshot with this fix on
>http://cygwin.com/snapshots/ soon.

I tested the snapshot and it works with my testprogram. It also works
with my other program where I detected it.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: Cygwin64: allocating too much memory causes a crash (corrected)

Corinna Vinschen-2
On Oct 16 22:28, Bengt Larsson wrote:
> Corinna Vinschen wrote:
>
> >Thanks for the report and especially the testcase!  I applied a fix
> >and will provide a new developer snapshot with this fix on
> >http://cygwin.com/snapshots/ soon.
>
> I tested the snapshot and it works with my testprogram. It also works
> with my other program where I detected it.

Thanks for your feedback!


Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

attachment0 (853 bytes) Download Attachment