Commit bbd86bf5 authored by Rich Salz's avatar Rich Salz
Browse files

mem functions cleanup



Only two macros CRYPTO_MDEBUG and CRYPTO_MDEBUG_ABORT to control this.
If CRYPTO_MDEBUG is not set, #ifdef out the whole debug machinery.
        (Thanks to Jakob Bohm for the suggestion!)
Make the "change wrapper functions" be the only paradigm.
Wrote documentation!
Format the 'set func' functions so their paramlists are legible.
Format some multi-line comments.
Remove ability to get/set the "memory debug" functions at runtme.
Remove MemCheck_* and CRYPTO_malloc_debug_init macros.
Add CRYPTO_mem_debug(int flag) function.
Add test/memleaktest.
Rename CRYPTO_malloc_init to OPENSSL_malloc_init; remove needless calls.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent 3cb8c326
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -152,6 +152,12 @@

     [Richard Levitte]

  *) Revamped memory debug; only -DCRYPTO_MDEBUG and -DCRYPTO_MDEBUG_ABORT
     are used; the latter aborts on memory leaks (usually checked on exit).
     Some undocumented "set malloc, etc., hooks" functions were removed
     and others were changed.  All are now documented.
     [Rich Salz]

  *) In DSA_generate_parameters_ex, if the provided seed is too short,
     return an error
     [Rich Salz and Ismo Puustinen <ismo.puustinen@intel.com>]
+2 −2
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@
        # -mcpu=ultrasparc
        inherit_from     => [ "solaris-sparcv7-gcc", asm("sparcv9_asm") ],
        cflags           => sub { join(" ","-m32 -mcpu=ultrasparc",@_); },
        debug_cflags     => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL -DPEDANTIC -O -g -pedantic -ansi -Wshadow -Wno-long-long -D__EXTENSIONS__",
        debug_cflags     => "-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -O -g -pedantic -ansi -Wshadow -Wno-long-long -D__EXTENSIONS__",
    },
    "solaris64-sparcv9-gcc" => {
        inherit_from     => [ "solaris-sparcv9-gcc" ],
@@ -150,7 +150,7 @@
        inherit_from     => [ "solaris-common" ],
        cc               => "cc",
        cflags           => sub { join(" ","-xstrconst -Xa -DB_ENDIAN -DBN_DIV2W",@_) },
        debug_cflags     => "-g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG_ALL",
        debug_cflags     => "-g -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG",
        release_cflags   => "-xO5 -xdepend",
        thread_cflag     => "-D_REENTRANT",
        lflags           => sub { join(" ",@_,"-mt -lpthread") },
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
# Minimum warning options... any contributions to OpenSSL should at least get
# past these.

my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DDEBUG_UNUSED";
my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DCRYPTO_MDEBUG -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DDEBUG_UNUSED";

# These are used in addition to $gcc_devteam_warn when the compiler is clang.
# TODO(openssl-team): fix problems and investigate if (at least) the
+4 −10
Original line number Diff line number Diff line
@@ -171,7 +171,6 @@ static int apps_startup()
#ifdef SIGPIPE
    signal(SIGPIPE, SIG_IGN);
#endif
    CRYPTO_malloc_init();
    ERR_load_crypto_strings();
    ERR_load_SSL_strings();

@@ -311,15 +310,8 @@ int main(int argc, char *argv[])
#endif

    p = getenv("OPENSSL_DEBUG_MEMORY");
    if (p == NULL)
        /* if not set, use compiled-in default */
        ;
    else if (strcmp(p, "off") != 0) {
        CRYPTO_malloc_debug_init();
        CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
    } else {
        CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
    }
    if (p != NULL && strcmp(p, "on") == 0)
        CRYPTO_set_mem_debug(1);
    CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
    CRYPTO_set_locking_callback(lock_dbg_cb);

@@ -437,7 +429,9 @@ int main(int argc, char *argv[])
    BIO_free(bio_in);
    BIO_free_all(bio_out);
    apps_shutdown();
#ifdef CRYPTO_MDEBUG
    CRYPTO_mem_leaks(bio_err);
#endif
    BIO_free(bio_err);
    return (ret);
}
+22 −20
Original line number Diff line number Diff line
@@ -160,15 +160,16 @@ cms_env.o: ../include/internal/asn1_int.h ../include/internal/cryptlib.h
cms_env.o: cms_env.c cms_lcl.h
cms_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
cms_err.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
cms_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
cms_err.o: ../../include/openssl/ec.h ../../include/openssl/err.h
cms_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
cms_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
cms_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
cms_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
cms_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
cms_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
cms_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
cms_err.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
cms_err.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
cms_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
cms_err.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
cms_err.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
cms_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cms_err.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
cms_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
cms_err.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
cms_err.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
cms_err.o: cms_err.c
cms_ess.o: ../../e_os.h ../../include/openssl/asn1.h
cms_ess.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
@@ -188,17 +189,18 @@ cms_ess.o: ../../include/openssl/x509v3.h ../include/internal/cryptlib.h
cms_ess.o: cms_ess.c cms_lcl.h
cms_io.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
cms_io.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
cms_io.o: ../../include/openssl/cms.h ../../include/openssl/crypto.h
cms_io.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
cms_io.o: ../../include/openssl/err.h ../../include/openssl/evp.h
cms_io.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
cms_io.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
cms_io.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
cms_io.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
cms_io.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
cms_io.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
cms_io.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
cms_io.o: ../../include/openssl/x509_vfy.h cms_io.c cms_lcl.h
cms_io.o: ../../include/openssl/cms.h ../../include/openssl/conf.h
cms_io.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
cms_io.o: ../../include/openssl/ec.h ../../include/openssl/err.h
cms_io.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
cms_io.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
cms_io.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
cms_io.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
cms_io.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
cms_io.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
cms_io.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
cms_io.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
cms_io.o: ../../include/openssl/x509v3.h cms_io.c cms_lcl.h
cms_kari.o: ../../e_os.h ../../include/openssl/aes.h
cms_kari.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
cms_kari.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
Loading