Starting in the last 2-5 days, I started getting failed self-test on cert_new as shown:
tortls/create_certificate: [forking] OK
tortls/cert_new: [forking] [Lost connection!]
[cert_new FAILED]
just built 'tor -V' shows:
Oct 23 20:41:00.966 [notice] Tor v0.2.8.0-alpha-dev (git-8acaac4622c67ce8)
running on NetBSD with Libevent 2.1.5-beta, OpenSSL 1.1.0-dev and Zlib 1.2.3.
NOTE : I'm building against HEAD on OpenSSL 1.1.0-dev ... in case the bug is an OpenSSL regression...
Trac: Username: yancm
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
OK, that "fixes" it too, but... just setting ret = NULL seems kluge-y? If the value of ret should be NULL when coming back from tor_x509_cert_free(), why not fix this in that function?
I apologize if these are impertinent comments, but thought I should speak up... no offense intended none to be felt from your reply...
Here's my reasoning. tor_x509_cert_new() allocates a tor_x509_cert_t object. tor_x509_cert_free() then frees it. At the end of the function, it tries to free it again. One of the ways to avoid double-freeing things is to set the pointer to NULL after first freeing the memory. Note that ret the pointer cannot be cleared inside tor_x509_cert_free() because tor_x509_cert_free() receives a new copy of that pointer and cannot do anything about the old copy in the testcase.
If you compile Tor with non-cutting-edge OpenSSL, this portion of code will be compiled in:
Here, it creates a new tor_x509_cert_t object. If I refrained from freeing the memory before the new tor_x509_cert_t instance is created (like I did in my first patch), everyone would forget about the old instance and the memory would be leaked.
Now, if I free the previous tor_x509_cert_t instance and nullify the pointer, there will be no memory leak regardless the OPENSSL_OPAQUE macro. And there is no double-free crashbug because tor_x509_cert_free(NULL) is no-op.
Ah, ok... If I understand the short of it; with bleeding edge OpenSSL, ret is passed by value to tor_x509_cert_free() so ret cannot be set to NULL there? And later in the test subroutine, we free ret again?
It seems odd to me to call a "free" anything (memory/records/etc) without returning a success or fail code, or some other status that can be reacted to...then you know when you NULL ret it has indeed been successfully free'd first... maybe we do not care if we NULL ret even if it was not successfully free'd?
Ah, ok... If I understand the short of it; with bleeding edge OpenSSL, ret is passed by value to tor_x509_cert_free() so ret cannot be set to NULL there? And later in the test subroutine, we free ret again?
Yes.
It seems odd to me to call a "free" anything (memory/records/etc) without returning a success or fail code, or some other status that can be reacted to...then you know when you NULL ret it has indeed been successfully free'd first... maybe we do not care if we NULL ret even if it was not successfully free'd?
Well, we're done with this instance of the object and we're not going to need it so we're freeing it. The lifecycle is over. We shouldn't worry about free() failing as it shouldn't happen.