-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
TLSWrap reports incorrect self_size #4250
Comments
@paddybyers I'm not exactly sure what do you ask about. |
@paddybyers |
I realise that what I'm saying isn't that believable but please bear with me. Here's a simple test:
Here's the dump: You can see that the value for Now try running the above test with the changes here: https://github.com/paddybyers/node-1/tree/log_tlswrap_retained_info I'm logging the constructor of
You can see that the call to It is just a matter of good fortune that this is harmlessly returning an invalid value and sooner or later there will be a layout change and something will properly break. I've seen this behaviour on Linux and OSX, on 4.2.2 and 5.1.0, with prebuilt packages and with node build from source. The above run was on OSX 10.10.5 with Xcode tools:
|
/cc @bnoordhuis any idea? |
Blergh, I know what's happening. This async wrap code is just terribly broken. @trevnorris @paddybyers sorry, I didn't understand your description at first, but now everything is clear. Thank you! |
@paddybyers may I ask you to give a try to a following patch? diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc
index bc830db..94f70eb 100644
--- a/src/tls_wrap.cc
+++ b/src/tls_wrap.cc
@@ -36,11 +36,11 @@ TLSWrap::TLSWrap(Environment* env,
Kind kind,
StreamBase* stream,
SecureContext* sc)
- : SSLWrap<TLSWrap>(env, sc, kind),
- StreamBase(env),
- AsyncWrap(env,
+ : AsyncWrap(env,
env->tls_wrap_constructor_function()->NewInstance(),
AsyncWrap::PROVIDER_TLSWRAP),
+ SSLWrap<TLSWrap>(env, sc, kind),
+ StreamBase(env),
sc_(sc),
stream_(stream),
enc_in_(nullptr),
diff --git a/src/tls_wrap.h b/src/tls_wrap.h
index 47cbf27..31d1952 100644
--- a/src/tls_wrap.h
+++ b/src/tls_wrap.h
@@ -21,9 +21,9 @@ namespace crypto {
class SecureContext;
}
-class TLSWrap : public crypto::SSLWrap<TLSWrap>,
- public StreamBase,
- public AsyncWrap {
+class TLSWrap : public AsyncWrap,
+ public crypto::SSLWrap<TLSWrap>,
+ public StreamBase {
public:
~TLSWrap() override;
|
@indutny: yes, that works. In fact I had already tried that but I wasn't sure if it was a general enough change or if there needed to be a way to |
@paddybyers technically speaking, I think @trevnorris what are your thoughts on this? |
`WrapperInfo` casts pointer in JS object's internal field to `AsyncWrap`. This approach fails miserably for `TLSWrap` because it was inhereted from the `StreamBase` first, creating different kind of `vtable` for the whole class. Reorder parent classes to put `AsyncWrap` first. Fix: nodejs#4250
Should be fixed by #4268 |
`WrapperInfo` casts pointer in JS object's internal field to `AsyncWrap`. This approach fails miserably for `TLSWrap` because it was inhereted from the `StreamBase` first, creating different kind of `vtable` for the whole class. Reorder parent classes to put `AsyncWrap` first. Fix: #4250 PR-URL: #4268 Reviewed-By: James M Snell <jasnell@gmail.com>
`WrapperInfo` casts pointer in JS object's internal field to `AsyncWrap`. This approach fails miserably for `TLSWrap` because it was inhereted from the `StreamBase` first, creating different kind of `vtable` for the whole class. Reorder parent classes to put `AsyncWrap` first. Fix: #4250 PR-URL: #4268 Reviewed-By: James M Snell <jasnell@gmail.com>
`WrapperInfo` casts pointer in JS object's internal field to `AsyncWrap`. This approach fails miserably for `TLSWrap` because it was inhereted from the `StreamBase` first, creating different kind of `vtable` for the whole class. Reorder parent classes to put `AsyncWrap` first. Fix: #4250 PR-URL: #4268 Reviewed-By: James M Snell <jasnell@gmail.com>
`WrapperInfo` casts pointer in JS object's internal field to `AsyncWrap`. This approach fails miserably for `TLSWrap` because it was inhereted from the `StreamBase` first, creating different kind of `vtable` for the whole class. Reorder parent classes to put `AsyncWrap` first. Fix: nodejs#4250 PR-URL: nodejs#4268 Reviewed-By: James M Snell <jasnell@gmail.com>
Im still seeing this strange behavior on EDIT: this was on |
Heapdumped profiles on node >=4.2 show unfeasibly large retained sizes for native
TLSWRAP
instances.I believe that this call: https://github.com/nodejs/node/blob/master/src/async-wrap.cc#L55 to
self_size()
, when on aTLSWrap
, are in fact enteringTLSWrap::Cast()
and thus returning thethis
pointer value. I don't know yet whether the problem is in the way it is being called or in the declaration inTLSWrap
but for some reason theself_size()
call is resolving to the wrong vtable entry. Someone more expert will I am sure find the root cause quicker than I will./cc @indutny is this yours?
The text was updated successfully, but these errors were encountered: