Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix crypto bio integer wraparound on 32 bits #1192

Merged
merged 1 commit into from
Mar 18, 2015

Conversation

bnoordhuis
Copy link
Member

Fix a bug where a size_t was negated and passed to a function that takes
an int64_t. It works by accident when sizeof(size_t) == sizeof(int64_t)
but it causes the value to underflow when size_t is a 32 bits type.

v8::Isolate::AdjustAmountOfExternalAllocatedMemory() is the function I'm
talking about. The goal of that call is to tell V8 that some memory has
been freed but due to that underflow, we were actually reporting that we
had just allocated gigabytes of memory. It set off a garbage collector
frenzy and essentially brought the VM to a standstill.

Fixes: #1188

R=@indutny

/cc @Nibbler999 – can you confirm that the patch fixes your issue?

https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/323/

@indutny
Copy link
Member

indutny commented Mar 18, 2015

Oh god, again.

LGTM

Fix a bug where a size_t was negated and passed to a function that takes
an int64_t.  It works by accident when sizeof(size_t) == sizeof(int64_t)
but it causes the value to underflow when size_t is a 32 bits type.

v8::Isolate::AdjustAmountOfExternalAllocatedMemory() is the function I'm
talking about.  The goal of that call is to tell V8 that some memory has
been freed but due to that underflow, we were actually reporting that we
had just allocated gigabytes of memory.  It set off a garbage collector
frenzy and essentially brought the VM to a standstill.

Fixes: nodejs#1188
PR-URL: nodejs#1192
Reviewed-By: Fedor Indutny <[email protected]>
@bnoordhuis bnoordhuis closed this Mar 18, 2015
@bnoordhuis bnoordhuis deleted the fix-issue-1188 branch March 18, 2015 19:08
@bnoordhuis bnoordhuis merged commit fe0f015 into nodejs:v1.x Mar 18, 2015
@rvagg rvagg mentioned this pull request Mar 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants