Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | [kennykb-numerics-branch] * generic/tclStrToD.c: Memory leak. Comment in TclSetBignumIntRep * generic/tclObj.c: indicates that mp_init() is called on the bignumValue argument to clear it, while keeping the digits array transferred to the interp of the Tcl_Obj. The implication is that callers of TclSetBignumIntRep() (and their callers) need not call mp_clear(), but can imagine they've transferred ownership of an mp_int value to Tcl. However, mp_init() doesn't merely re-initialize the fields of an mp_int to hold the value zero. It also allocates a fresh dp array of minimum size governed by MP_PREC. Without a corresponding mp_clear() call somewhere, these dp arrays are leaked. Added some mp_clear() calls to fix the leak, but better fix strategies should still be pursued. Perhaps the best approach is to just invade the mp_int struct and do the necessary surgery ourselves. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | kennykb-numerics-branch |
Files: | files | file ages | folders |
SHA1: |
961337390cc121096a3e25ef6a077cc5 |
User & Date: | dgp 2005-09-23 04:03:43.000 |
Context
2005-09-23
| ||
16:13 |
[kennykb-numerics-branch] * generic/tclStrToD.c: Fixed memory leak. [Bug 1299803]...check-in: 112ace53ab user: dgp tags: kennykb-numerics-branch | |
04:03 |
[kennykb-numerics-branch] * generic/tclStrToD.c: Memory leak. Comment in TclSetBi...check-in: 961337390c user: dgp tags: kennykb-numerics-branch | |
2005-09-20
| ||
14:11 |
[kennykb-numerics-branch] * generic/tclExecute.c: Revise TclIncrObj() to call ...check-in: dd93281cd4 user: dgp tags: kennykb-numerics-branch | |
Changes
Changes to ChangeLog.
1 2 3 4 5 6 7 | 2005-09-20 Don Porter <[email protected]> [kennykb-numerics-branch] * generic/tclExecute.c: Revise TclIncrObj() to call Tcl_GetBignumAndClearObj. | > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 2005-09-23 Don Porter <[email protected]> [kennykb-numerics-branch] * generic/tclStrToD.c: Memory leak. Comment in TclSetBignumIntRep * generic/tclObj.c: indicates that mp_init() is called on the bignumValue argument to clear it, while keeping the digits array transferred to the interp of the Tcl_Obj. The implication is that callers of TclSetBignumIntRep() (and their callers) need not call mp_clear(), but can imagine they've transferred ownership of an mp_int value to Tcl. However, mp_init() doesn't merely re-initialize the fields of an mp_int to hold the value zero. It also allocates a fresh dp array of minimum size governed by MP_PREC. Without a corresponding mp_clear() call somewhere, these dp arrays are leaked. Added some mp_clear() calls to fix the leak, but better fix strategies should still be pursued. Perhaps the best approach is to just invade the mp_int struct and do the necessary surgery ourselves. 2005-09-20 Don Porter <[email protected]> [kennykb-numerics-branch] * generic/tclExecute.c: Revise TclIncrObj() to call Tcl_GetBignumAndClearObj. |
︙ | ︙ |
Changes to generic/tclObj.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | * Copyright (c) 1999 by Scriptics Corporation. * Copyright (c) 2001 by ActiveState Corporation. * Copyright (c) 2005 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * Copyright (c) 1999 by Scriptics Corporation. * Copyright (c) 2001 by ActiveState Corporation. * Copyright (c) 2005 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclObj.c,v 1.72.2.37 2005/09/23 04:03:43 dgp Exp $ */ #include "tclInt.h" #include "tommath.h" #include <float.h> #define BIGNUM_AUTO_NARROW 1 |
︙ | ︙ | |||
2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 | } tooLargeForWide: #endif #endif TclInvalidateStringRep(objPtr); TclFreeIntRep(objPtr); TclSetBignumIntRep(objPtr, bignumValue); } void TclSetBignumIntRep(objPtr, bignumValue) Tcl_Obj *objPtr; mp_int *bignumValue; { | > | 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 | } tooLargeForWide: #endif #endif TclInvalidateStringRep(objPtr); TclFreeIntRep(objPtr); TclSetBignumIntRep(objPtr, bignumValue); mp_clear(bignumValue); } void TclSetBignumIntRep(objPtr, bignumValue) Tcl_Obj *objPtr; mp_int *bignumValue; { |
︙ | ︙ |
Changes to generic/tclStrToD.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | * interconversion among 'double' and 'mp_int' types. * * Copyright (c) 2005 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * interconversion among 'double' and 'mp_int' types. * * Copyright (c) 2005 by Kevin B. Kenny. All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tclStrToD.c,v 1.1.2.38 2005/09/23 04:03:43 dgp Exp $ * *---------------------------------------------------------------------- */ #include <tclInt.h> #include <stdio.h> #include <stdlib.h> |
︙ | ︙ | |||
1017 1018 1019 1020 1021 1022 1023 | } } if (octalSignificandOverflow) { if (signum) { mp_neg(&octalSignificandBig, &octalSignificandBig); } TclSetBignumIntRep(objPtr, &octalSignificandBig); | < | 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | } } if (octalSignificandOverflow) { if (signum) { mp_neg(&octalSignificandBig, &octalSignificandBig); } TclSetBignumIntRep(objPtr, &octalSignificandBig); } break; case ZERO: case DECIMAL: significandOverflow = AccumulateDecimalDigit( 0, numTrailZeros-1, |
︙ | ︙ | |||
1071 1072 1073 1074 1075 1076 1077 | } } if (significandOverflow) { if (signum) { mp_neg(&significandBig, &significandBig); } TclSetBignumIntRep(objPtr, &significandBig); | < | 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 | } } if (significandOverflow) { if (signum) { mp_neg(&significandBig, &significandBig); } TclSetBignumIntRep(objPtr, &significandBig); } break; case FRACTION: case EXPONENT: /* |
︙ | ︙ |