File: dmalloc.html

package info (click to toggle)
dmalloc 5.5.2-6
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,912 kB
  • ctags: 2,276
  • sloc: ansic: 13,011; makefile: 427; perl: 175; sh: 173; cpp: 36
file content (5327 lines) | stat: -rw-r--r-- 307,008 bytes parent folder | download | duplicates (5)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on May, 14 2007 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Dmalloc Tutorial: Debug Malloc Library</title>

<meta name="description" content="Dmalloc Tutorial: Debug Malloc Library">
<meta name="keywords" content="Dmalloc Tutorial: Debug Malloc Library">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Top"></a>
<a name="SEC_Top"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="settitle">Debug Malloc Library</h1>



<p>The debug memory allocation or <em>dmalloc</em> library has been designed
as a drop in replacement for the system's <code>malloc</code>, <code>realloc</code>,
<code>calloc</code>, <code>free</code> and other memory management routines while
providing powerful debugging facilities configurable at runtime.  These
facilities include such things as memory-leak tracking, fence-post write
detection, file/line number reporting, and general logging of
statistics.
</p>
<p>The library is reasonably portable having been run successfully on at
least the following operating systems: AIX, DGUX, Free/Net/OpenBSD,
GNU/Hurd, HPUX, Irix, Linux, Mac OSX, NeXT, OSF/DUX, SCO, Solaris,
Ultrix, Unixware, MS Windows, and Unicos on a Cray T3E.  It also
provides support for the debugging of threaded programs.  See section <a href="#SEC24">Using the Library with a Thread Package</a>.
</p>
<p>The package includes the library, configuration scripts, debug utility
application, test program, and documentation.  Online documentation as
well as the full source is available at URL <a href="http://dmalloc.com/">http://dmalloc.com/</a>.
Details on the library's mailing list are available there as well.
</p>
<p>Please use the forums at URL <a href="http://dmalloc.com/">http://dmalloc.com/</a> to discuss any
problems or to request features.  If you are still having problems,
the author can be reached via his home page at URL
<a href="http://256.com/gray/">http://256.com/gray/</a> with questions or feedback.  Please
include the version number of the library that you are using, your
machine and operating system types, and the value of the
DMALLOC_OPTIONS environment variable.
</p>
<p>Gray Watson.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC1">1. Library Copying and Licensing Conditions</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     Library copying and licensing conditions.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC2">2. Description of Features and How to Get Started</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    Description of features and how to get started.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC10">3. How to Program with the Library</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                 How to program with the library.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC29">4. Dmalloc Utility Program</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">             How to use the library's utility.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC35">5. Information on the Source Code</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                 Information on the source code.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">             Some solutions to common problems.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC40">Index of Concepts</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">           Index of concepts in the manual.
</td></tr>
</table>


<hr size="1">
<a name="Copying"></a>
<a name="SEC1"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[ &lt;&lt; ]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 1. Library Copying and Licensing Conditions </h1>


<p>Copyright 1992 to 2007 by Gray Watson.
</p>
<p>Permission to use, copy, modify, and distribute this software for any
purpose and without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies, and
that the name of Gray Watson not be used in advertising or publicity
pertaining to distribution of the document or software without specific,
written prior permission.
</p>
<p>Gray Watson makes no representations about the suitability of the
software described herein for any purpose.  It is provided &quot;as is&quot;
without express or implied warranty.
</p>

<hr size="6">
<a name="Overview"></a>
<a name="SEC2"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC1" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC3" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 2. Description of Features and How to Get Started </h1>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                How to install the library.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">             Getting started with the library.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC5">2.3 Basic Description of Terms and Functions</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">           Basic description of terms and functions.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                    General features of the library.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC9">2.5 How the Library Checks Your Program</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                How the library checks your program.
</td></tr>
</table>


<hr size="6">
<a name="Installation"></a>
<a name="SEC3"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC2" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC4" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.1 How to Install the Library </h2>


<p>To configure, compile, and install the library, follow these steps
carefully.
</p>
<ol>
<li> Make sure you have downloaded the latest version of the library
available from the home page at URL <a href="http://dmalloc.com/">http://dmalloc.com/</a>.

</li><li> The release files have a <tt>`.tgz'</tt> file extension which means
that they are a tar'd gzip'd directory of files.  You will need to
ungzip and then untar the release file into your source work
directory.  You may have to rename the file to <tt>`.tar.gz'</tt> to get
some old zip programs to handle the file correctly.

<a name="IDX1"></a>

</li><li> You may want to edit or at least review the settings in
<tt>`settings.dist'</tt> to tune specific features of the library.  The
<tt>`configure'</tt> script will copy this file to <tt>`settings.h'</tt> which
is where you should be adding per-architecture settings.

<a name="IDX2"></a>
<a name="IDX3"></a>
<a name="IDX4"></a>
<a name="IDX5"></a>
<a name="IDX6"></a>

</li><li> Type <kbd>sh ./configure</kbd> to configure the library.  You may want
to first examine the <tt>`config.help'</tt> file for some information about
configure.  You may want to use the <kbd>--disable-cxx</kbd> option if you do
not want the Makefile to build the C++ version of dmalloc.  You may want
to use the <kbd>--enable-threads</kbd> option to build the threaded version
of dmalloc.  You may want to use the <kbd>--enable-shlib</kbd> option to
build the shared versions of the dmalloc libraries.  <kbd>sh ./configure
--help</kbd> lists the available options to configure.  Configure should
generate the <tt>`Makefile'</tt> and configuration files automatically.

</li><li> You may want to examine the <tt>`Makefile'</tt> and <tt>`conf.h'</tt> files
created by configure to make sure it did its job correctly.

<a name="IDX7"></a>

</li><li> You might want to tune the settings in <tt>`settings.h'</tt> file to
tune the library to the local architecture.  This file contains relevant
settings if you are using pthreads or another thread library.
See section <a href="#SEC24">Using the Library with a Thread Package</a>.  The <tt>`configure'</tt> script created this
file from the <tt>`settings.dist'</tt> file.  Any permanent changes to these
settings should made to the <tt>`settings.dist'</tt> file.  You then can run
<tt>`config.status'</tt> to re-create the <tt>`settings.h'</tt> file.

<a name="IDX8"></a>

</li><li> The <code>DMALLOC_SIZE</code> variable gets auto-configured in
<tt>`dmalloc.h.2'</tt> but it may not generate correct settings for all
systems.  You may have to alter the definitions in this file to get
things to stop complaining when you go to compile about the size
arguments to malloc routines.  Comments on this please.

</li><li> Typing <kbd>make</kbd> should be enough to build <tt>`libdmalloc.a'</tt>,
and <tt>`dmalloc'</tt> program.  If it does not work, please see if there
are any notes in the contrib directory about your system-type.  If not
and you figure your problem out, please send me some notes so future
users can profit from your experiences.

<a name="IDX9"></a>

<p><em>NOTE</em>: You may experience some errors compiling some of the
<tt>`return.h'</tt> assembly macros which attempt to determine the callers
address for logging purposes.  See section <a href="#SEC38">Issues Important for Porting the Library</a>.  You may want to
first try disabling any compiler optimization flags.  If this doesn't
work then you may need to disable the <samp>`USE_RETURN_MACROS'</samp>
variable in the <tt>`settings.h'</tt> file.
</p>
<a name="IDX10"></a>

<p><em>NOTE</em>: The code is dependent on an ANSI-C compiler.  If the
configure script gives the <samp>`WARNING'</samp> that you do not have an ANSI-C
compiler, you may still be able to add some sort of option to your
compiler to make it ANSI.  If there such is an option, please send it to
the author so it can be added to the configure script.
</p>
</li><li> If you use threads and did not add the <kbd>--enable-threads</kbd>
argument to configure, typing <kbd>make threads</kbd> should be enough to
build <tt>`libdmallocth.a'</tt> which is the threaded version of the
library.  This may or may not work depending on the configuration
scripts ability to detect your local thread functionality.  Feel free to
send me mail with improvements.

<p>See the section of the manual on threads for more information about
the operation of the library with your threaded program.  See section <a href="#SEC24">Using the Library with a Thread Package</a>.
</p>
</li><li> If you have a C++ compiler installed, the library should have
automatically built <tt>`libdmallocxx.a'</tt> which is the C++ version of
the library.  If it was not done automatically, you can build it by
typing <kbd>make cxx</kbd>.  You should link this library into your C++
programs instead of <tt>`libdmalloc.a'</tt>.  See the <tt>`dmallocc.cc'</tt> C++
file which contains basic code to overload the <code>new</code>, <code>new[]</code>,
<code>delete</code>, and <code>delete[]</code> C++ operators.  My apologies on the
minimal C++ support.  I am still living in a mostly C world.  Any help
improving this interface without sacrificing portability would be
appreciated.

<a name="IDX11"></a>
<a name="IDX12"></a>

</li><li> Typing <kbd>make light</kbd> should build and run the <tt>`dmalloc_t'</tt> test
program through a set of light trials.  By default this will execute
<tt>`dmalloc_t'</tt> 5 times - each time will execute 10,000 malloc
operations in a very random manner.  Anal folks can type <kbd>make
heavy</kbd> to up the ante.  Use <kbd>dmalloc_t --usage</kbd> for the list of all
<tt>`dmalloc_t'</tt> options.

</li><li> Typing <kbd>make install</kbd> should install the <tt>`libdmalloc.a'</tt>
library in <tt>`/usr/local/lib'</tt>, the <tt>`dmalloc.h'</tt> include file in
<tt>`/usr/local/include'</tt>, and the <tt>`dmalloc'</tt> utility in
<tt>`/usr/local/bin'</tt>.  You may also want to type <kbd>make installth</kbd>
to install the thread library into place and/or <kbd>make installcc</kbd> to
install the C++ library into place.

<p>You may have specified a <samp>`--prefix=PATH'</samp> option to configure in
which case <samp>`/usr/local'</samp> will have been replaced with <samp>`PATH'</samp>.
</p>
</li></ol>

<p>See the &quot;Getting Started&quot; section to get up and running with the
library.  See section <a href="#SEC4">Getting Started with the Library</a>.
</p>

<hr size="6">
<a name="Getting-Started"></a>
<a name="SEC4"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC3" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC5" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.2 Getting Started with the Library </h2>


<p>This section should give you a quick idea on how to get going.
Basically, you need to do the following things to make use of the
library:
</p>
<ol>
<li> Make sure you have downloaded the latest version of the library
available from the home page at URL <a href="http://dmalloc.com/">http://dmalloc.com/</a>.

</li><li> Follow the installation instructions on how to configure,
make, and install the library (i.e. type: <kbd>make install</kbd>).
See section <a href="#SEC3">How to Install the Library</a>.

<a name="IDX13"></a>
<a name="IDX14"></a>
<a name="IDX15"></a>
<a name="IDX16"></a>
<a name="IDX17"></a>

</li><li> You need to make sure that the library configuration and
build process above was able to locate one of the <code>on_exit</code>
function, <code>atexit</code> function, or had compiler destructor support.
If one of these functions or support is available then the dmalloc
library should be able to automatically shut itself down when the
program exits.  This causes the memory statistics and unfreed
information to be dumped to the log file.  However, if your system has
none of the above, then you will need to call <code>dmalloc_shutdown</code>
yourself before your program exits.

<a name="IDX18"></a>
<a name="IDX19"></a>
<a name="IDX20"></a>
<a name="IDX21"></a>

</li><li> To get the dmalloc utility to work you need to add an alias for
dmalloc to your shell's runtime configuration file if supported.  The
idea is to have the shell capture the dmalloc program's output and
adjust the environment.  

<p>After you add the alias to the shell config file you need to log out
and log back in to have it take effect, or you can execute the
appropriate command below on the command line directly.  After you
setup the alias, if you enter <kbd>dmalloc runtime</kbd> and see any output
with DMALLOC_OPTIONS in it then the alias did not take effect.
</p>
<p>Bash, ksh, and zsh (<a href="http://www.zsh.org/">http://www.zsh.org/</a>) users should add the
following to their <tt>`.bashrc'</tt>, <tt>`.profile'</tt>, or <tt>`.zshrc'</tt>
file respectively (notice the <kbd>-b</kbd> option for bourne shell
output):
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">function dmalloc { eval `command dmalloc -b $*`; }
</pre></td></tr></table>
<p>If your shell does not support the <code>command</code> function then try:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">function dmalloc { eval `\dmalloc -b $*`; }
</pre></td></tr></table><p>or
</p><table><tr><td>&nbsp;</td><td><pre class="example">function dmalloc { eval `/usr/local/bin/dmalloc -b $*`; }
</pre></td></tr></table>
<a name="IDX22"></a>
<a name="IDX23"></a>

<p>If you are still using csh or tcsh, you should add the following to
your <tt>`.cshrc'</tt> file (notice the <kbd>-C</kbd> option for c-shell
output):
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">alias dmalloc 'eval `\dmalloc -C \!*`'
</pre></td></tr></table>
<a name="IDX24"></a>

<p>If you are using rc shell, you should add the following to your
<tt>`.rcrc'</tt> file (notice the <kbd>-R</kbd> option for rc-shell output):
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">fn dmalloc {eval `{/usr/local/bin/dmalloc $*}}
</pre></td></tr></table>
</li><li> Although not necessary, you may want to include <tt>`dmalloc.h'</tt>
in your C files and recompile.  This will allow the library to report
the file/line numbers of calls that generate problems.  See section <a href="#SEC11">Macros Providing File and Line Information</a>.  It should be inserted at the <em>bottom</em> of your include
files as to not conflict with wother includes.  You may want to ifdef it
as well and compile with <kbd>cc -DDMALLOC &hellip;</kbd>:

<table><tr><td>&nbsp;</td><td><pre class="example">/* other includes above ^^^ */

#ifdef DMALLOC
#include &quot;dmalloc.h&quot;
#endif
</pre></td></tr></table>
<a name="IDX25"></a>
</li><li> Another optional task is to compile all of your source with the
<tt>`dmalloc.h'</tt> with the <code>DMALLOC_FUNC_CHECK</code> compilation flag.
This willallow the library to check all of the arguments of a number
of common string and utility routines.  See section <a href="#SEC13">Checking of Function Arguments</a>.

<table><tr><td>&nbsp;</td><td><pre class="example">cc -DDMALLOC -DDMALLOC_FUNC_CHECK file.c
</pre></td></tr></table>
</li><li> Link the dmalloc library into your program.  The dmalloc library
should probably be placed at or near the end of the library list.

</li><li> Enable the debugging features by typing <kbd>dmalloc -l logfile
-i 100 low</kbd> (for example).  You should not see any messages printed by
the dmalloc utility (see NOTE below).  This will:

<ul>
<li> Set the malloc logfile name to <tt>`logfile'</tt> (<kbd>-l logfile</kbd>).
For programs which change directories, you may want to specify the
full path to your logfile.

</li><li> Have the library check itself every 100 iterations (<kbd>-i 100</kbd>).
This controls how fast your program will run.  Larger numbers check
the heap less and so it will run faster.  Lower numbers will be more
likely to catch memory problems.

</li><li> Enable a number of debug features (<kbd>low</kbd>).  You can
also try <kbd>runtime</kbd> for minimal checking or <kbd>medium</kbd> or
<kbd>high</kbd> for more extensive heap verification.

</li><li> By default, the low, medium, and high values enable the
<code>error-abort</code> token which will cause the library to abort and
usually dump core immediately upon seeing an error.  See section <a href="#SEC14">Generating a Core File on Errors</a>.  You can disable this feature by entering <kbd>dmalloc -m
error-abort</kbd> (-m for minus) to remove the <code>error-abort</code> token and
your program will just log errors and continue.

</li></ul>

<p><kbd>dmalloc --usage</kbd> will provide verbose usage info for the dmalloc
program.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
<p>You may also want to install the <tt>`dmallocrc'</tt> file in your home
directory as <tt>`.dmallocrc'</tt>.  This allows you to add your own
combination of debug tokens.  See section <a href="#SEC34">Format of the Runtime Configuration File</a>.
</p>
<p><em>NOTE</em>: The output from the dmalloc utility should be captured by
your shell.  If you see a bunch of stuff which includes the string
<code>DMALLOC_OPTIONS</code> then the alias you should have created above is
not working and he environmental variables are not being set.  Make
sure you've logged out and back in to have the alias take effect.
</p>
</li><li> Run your program, examine the logfile that should have been
created by <code>dmalloc_shutdown</code>, and use its information to help
debug your program.

</li></ol>


<hr size="6">
<a name="Allocation-Basics"></a>
<a name="SEC5"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC4" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC6" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.3 Basic Description of Terms and Functions </h2>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC6">2.3.1 General Memory Terms and Concepts</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">           General memory terms and concepts.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">            Functionality supported by all malloc libs.
</td></tr>
</table>


<hr size="6">
<a name="Basic-Definitions"></a>
<a name="SEC6"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC5" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC7" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 2.3.1 General Memory Terms and Concepts </h3>


<p>Any program can be divided into 2 logical parts: text and data.  Text is
the actual program code in machine-readable format and data is the
information that the text operates on when it is executing.  The data,
in turn, can be divided into 3 logical parts according to where it is
stored: <em>static</em>, <em>stack</em>, and <em>heap</em>.
</p>
<a name="IDX26"></a>

<p>Static data is the information whose storage space is compiled into the
program.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">/* global variables are allocated as static data */
int numbers[10];

main()
{
        &hellip;
}
</pre></td></tr></table>
<a name="IDX27"></a>

<p>Stack data is data allocated at runtime to hold information used inside
of functions.  This data is managed by the system in the space called
stack space.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">void foo()
{
        /* this local variable is stored on the stack */
        float total;
        &hellip;
}

main()
{
        foo();
}
</pre></td></tr></table>
<a name="IDX28"></a>

<p>Heap data is also allocated at runtime and provides a programmer with
dynamic memory capabilities.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">main()
{
        /* the address is stored on the stack */
        char * string;
        &hellip;

        /*
         * Allocate a string of 10 bytes on the heap.  Store the
         * address in string which is on the stack.
         */
        string = (char *)malloc(10);
        &hellip;

        /* de-allocate the heap memory now that we're done with it */
        (void)free(string);
        &hellip;
}
</pre></td></tr></table>
<p>It is the heap data that is managed by this library.
</p>
<p>Although the above is an example of how to use the malloc and free
commands, it is not a good example of why using the heap for runtime
storage is useful.
</p>
<p>Consider this: You write a program that reads a file into memory,
processes it, and displays results.  You would like to handle files with
arbitrary size (from 10 bytes to 1.2 megabytes and more).  One problem,
however, is that the entire file must be in memory at one time to do the
calculations.  You don't want to have to allocate 1.2 megabytes when you
might only be reading in a 10 byte file because it is wasteful of system
resources.  Also, you are worried that your program might have to handle
files of more than 1.2 megabytes.
</p>
<p>A solution: first check out the file's size and then, using the
heap-allocation routines, get enough storage to read the entire file
into memory.  The program will only be using the system resources
necessary for the job and you will be guaranteed that your program can
handle any sized file.
</p>

<hr size="6">
<a name="Malloc-Functions"></a>
<a name="SEC7"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC6" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 2.3.2 Functionality Supported by All Malloc Libraries </h3>


<p>All malloc libraries support 4 basic memory allocation commands.  These
include <em>malloc</em>, <em>calloc</em>, <em>realloc</em>, and <em>free</em>.  For
more information about their capabilities, check your system's manual
pages - in unix, do a <code>man 3 malloc</code>.
</p>
<a name="IDX29"></a>
<dl>
<dt><u>Function:</u> void <b>*malloc</b><i> ( unsigned int <var>size</var> )</i>
<a name="IDX30"></a>
</dt>
<dd><p>Usage: <code>pnt = (type *)malloc(size)</code>
</p>
<p>The malloc routine is the basic memory allocation routine.  It allocates
an area of <code>size</code> bytes.  It will return a pointer to the space
requested.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> void <b>*calloc</b><i> ( unsigned int <var>number</var>, unsigned int<var>size</var> )</i>
<a name="IDX31"></a>
</dt>
<dd><a name="IDX32"></a>
<a name="IDX33"></a>
<a name="IDX34"></a>

<p>Usage: <code>pnt = (type *)calloc(number, size)</code>
</p>
<p>The calloc routine allocates a certain <code>number</code> of items, each of
<code>size</code> bytes, and returns a pointer to the space.  It is
appropriate to pass in a <code>sizeof(type)</code> value as the size argument.
</p>
<p>Also, calloc nulls the space that it returns, assuring that the memory
is all zeros.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> void <b>*realloc</b><i> ( void *<var>old_pnt</var>, unsigned int <var>new_size</var> )</i>
<a name="IDX35"></a>
</dt>
<dd><a name="IDX36"></a>

<p>Usage: <code>new_pnt = (type *)realloc(old_pnt, new_size)</code>
</p>
<p>The realloc function expands or shrinks the memory allocation in
<code>old_pnt</code> to <code>new_size</code> number of bytes.  Realloc copies as
much of the information from <code>old_pnt</code> as it can into the
<code>new_pnt</code> space it returns, up to <code>new_size</code> bytes.  If there
is a problem allocating this memory, 0L will be returned.
</p>
<p>If the <code>old_pnt</code> is 0L then realloc will do the equivalent of a
<code>malloc(new_size)</code>.  If <code>new_size</code> is 0 and <code>old_pnt</code> is
not 0L, then it will do the equivalent of <code>free(old_pnt)</code> and will
return 0L.
</p>
</dd></dl>
<dl>
<dt><u>Function:</u> void <b>free</b><i> ( void *<var>pnt</var> )</i>
<a name="IDX37"></a>
</dt>
<dd><a name="IDX38"></a>

<p>Usage: <code>free(pnt)</code>
</p>
<p>The free routine releases allocation in <code>pnt</code> which was returned by
malloc, calloc, or realloc back to the heap.  This allows other parts of
the program to re-use memory that is not needed anymore.  It guarantees
that the process does not grow too big and swallow a large portion of
the system resources.
</p>
</dd></dl>

<p><em>WARNING</em>: there is a quite common myth that all of the space that
is returned by malloc libraries has already been cleared.  <em>Only</em>
the <code>calloc</code> routine will zero the memory space it returns.
</p>

<hr size="6">
<a name="Features"></a>
<a name="SEC8"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC7" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC9" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.4 General Features of the Library </h2>


<p>The debugging features that are available in this debug malloc library
can be divided into a couple basic classifications:
</p>
<dl compact="compact">
<dt> file and line number information</dt>
<dd><a name="IDX39"></a>
<a name="IDX40"></a>
<p>One of the nice things about a good debugger is its ability to provide
the file and line number of an offending piece of code.  This library
attempts to give this functionality with the help of <em>cpp</em>, the C
preprocessor.  See section <a href="#SEC11">Macros Providing File and Line Information</a>.
</p>
</dd>
<dt> return-address information</dt>
<dd><a name="IDX41"></a>
<p>To debug calls to the library from external sources (i.e. those files
that could not use the allocation macros), some facilities have been
provided to supply the caller's address.  This address, with the help of
a debugger, can help you locate the source of a problem.  See section <a href="#SEC12">Getting Caller Address Information</a>.
</p>
</dd>
<dt> fence-post (i.e. bounds) checking</dt>
<dd><a name="IDX42"></a>
<a name="IDX43"></a>
<a name="IDX44"></a>
<p><em>Fence-post</em> memory is the area immediately above or below memory
allocations.  It is all too easy to write code that accesses above or
below an allocation - especially when dealing with arrays or strings.
The library can write special values in the areas around every
allocation so it will notice when these areas have been overwritten.
See section <a href="#SEC22">Diagnosing Fence-Post Overwritten Memory</a>.
</p>
<p><em>NOTE</em>: The library cannot notice when the program <em>reads</em>
from these areas, only when it writes values.  Also, fence-post checking
will increase the amount of memory the program allocates.
</p>
</dd>
<dt> heap-constancy verification</dt>
<dd><a name="IDX45"></a>
<p>The administration of the library is reasonably complex.  If any of the
heap-maintenance information is corrupted, the program will either crash
or give unpredictable results.
</p>
<p>By enabling heap-consistency checking, the library will run through its
administrative structures to make sure all is in order.  This will mean
that problems will be caught faster and diagnosed better.
</p>
<p>The drawback of this is, of course, that the library often takes quite a
long time to do this.  It is suitable to enable this only during
development and debugging sessions.
</p>
<p><em>NOTE</em>: the heap checking routines cannot guarantee that the tests
will not cause a segmentation-fault if the heap administration
structures are properly (or improperly if you will) overwritten.  In
other words, the tests will verify that everything is okay but may not
inform the user of problems in a graceful manner.
</p>
</dd>
<dt> logging statistics</dt>
<dd><a name="IDX46"></a>
<a name="IDX47"></a>
<a name="IDX48"></a>
<a name="IDX49"></a>
<p>One of the reasons why the debug malloc library was initially developed
was to track programs' memory usage - specifically to locate
<em>memory leaks</em> which are places where allocated memory is never
getting freed.  See section <a href="#SEC21">Tracking Down Non-Freed Memory</a>.
</p>
<p>The library has a number of logging capabilities that can track un-freed
memory pointers as well as runtime memory usage, memory transactions,
administrative actions, and final statistics.
</p>
</dd>
<dt> examining freed memory</dt>
<dd><a name="IDX50"></a>
<a name="IDX51"></a>
<p>Another common problem happens when a program frees a memory pointer but
goes on to use it again by mistake.  This can lead to mysterious crashes
and unexplained problems.
</p>
<p>To combat this, the library can write special values into a block of
memory after it has been freed.  This serves two purposes: it will make
sure that the program will get garbage data if it trying to access the
area again, and it will allow the library to verify the area later for
signs of overwriting.
</p></dd>
</dl>

<p>If any of the above debugging features detect an error, the library will
try to recover.  If logging is enabled then an error will be logged with
as much information as possible.
</p>
<p>The error messages that the library displays are designed to give the
most information for developers.  If the error message is not
understood, then it is most likely just trying to indicate that a part
of the heap has been corrupted.
</p>
<a name="IDX52"></a>
<a name="IDX53"></a>
<p>The library can be configured to quit immediately when an error is
detected and to dump a core file or memory-image.  This can be
examined with a debugger to determine the source of the problem.  The
library can either stop after dumping core or continue running.
See section <a href="#SEC14">Generating a Core File on Errors</a>.
</p>
<a name="IDX54"></a>
<a name="IDX55"></a>
<p><em>NOTE</em>: do not be surprised if the library catches problems with
your system's routines.  It took me hours to finally come to the
conclusion that the localtime call, included in SunOS release 4.1,
overwrites one of its fence-post markers.
</p>

<hr size="6">
<a name="How-It-Works"></a>
<a name="SEC9"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC8" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.5 How the Library Checks Your Program </h2>

<p>This is one of the newer sections of the library implying that it is
incomplete.  If you have any questions or issues that you'd like to see
handled here, please let me know.
</p>
<p>The dmalloc library replaces the heap library calls normally found in
your system libraries with its own versions.  When you make a call to
malloc (for example), you are calling dmalloc's version of the memory
allocation function.  When you allocate memory with these functions, the
dmalloc library keeps track of a number of pieces of debugging
information about your pointer including: where it was allocated,
exactly how much memory was requested, when the call was made, etc..
This information can then be verified when the pointer is freed or
reallocated and the details can be logged on any errors.
</p>
<p>Whenever you reallocate or free a memory address, the dmalloc library
always performs a number of checks on the pointer to make sure that it
is valid and has not been corrupted.  You can configure the library to
perform additional checks such as detected fence-post writing.  The
library can also be configured to overwrite memory with non-zeros (only
if calloc is not called) when it is allocated and erase the memory when
the pointers are freed.
</p>
<a name="IDX56"></a>
<p>In addition to per-pointer checks, you can configure the library to
perform complete heap checks.  These complete checks verify all
internal heap structures and include walking all of the known
allocated pointers to verify each one in turn.  You need this level of
checking to find random pointers in your program which got corrupted
but that won't be freed for a while.  To turn on these checks, you
will need to enable the <code>check-heap</code> debug token.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.  By default this will cause the heap to be fully checked each
and every time dmalloc is called whether it is a malloc, free,
realloc, or another dmalloc overloaded function.
</p>
<p>Performing a full heap check can take a good bit of CPU and it may be
that you will want to run it sporadically.  This can be accomplished in
a couple different ways including the '-i' interval argument to the
dmalloc utility.  See section <a href="#SEC29">Dmalloc Utility Program</a>.  This will cause the check to
be run every N-th time.  For instance, 'dmalloc -i 3' will cause the
heap to be checked before every 3rd call to a memory function.  Values
of 100 or even 1000 for high memory usage programs are more useful than
smaller ones.
</p>
<a name="IDX57"></a>
<a name="IDX58"></a>
<a name="IDX59"></a>
<p>You can also cause the program to start doing detailed heap checking
after a certain point.  For instance, with 'dmalloc -s 1000' option, you
can tell the dmalloc library to enable the heap checks after the 1000th
memory call.  Examine the dmalloc log file produced and use the
iteration count if you have <code>LOG_ITERATION_COUNT</code> enabled in your
<tt>`settings.h'</tt> file.
</p>
<p>The start option can also have the format <samp>`file:line'</samp>.  For
instance, if it is set to <samp>`dmalloc_t.c:126'</samp>, dmalloc will start
checking the heap after it sees a dmalloc call from the
<tt>`dmalloc_t.c'</tt> file, line number 126.  If you use
<samp>`dmalloc_t.c:0'</samp>, with a 0 line number, then dmalloc will start
checking the heap after it sees a call from anywhere in the
<tt>`dmalloc_t.c'</tt> file.
</p>

<hr size="6">
<a name="Programming"></a>
<a name="SEC10"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC9" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 3. How to Program with the Library </h1>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">          Macros providing file and line information.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC12">3.2 Getting Caller Address Information</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">             Getting caller address information.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC13">3.3 Checking of Function Arguments</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">          Checking of function arguments.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">               Generating a core file on errors for debugging.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                 Additional non-standard routines.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                Description of the internal error numbers.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC17">3.7 How to Disable the library</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">      How to disable the library.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC18">3.8 Using the Library with C++</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">             Using the library with C++.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC19">3.9 Using Dmalloc With a Debugger</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">      Using a debugger with the library.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC24">3.10 Using the Library with a Thread Package</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">         Using the library with a thread package.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">         Debugging memory in a server or cgi-bin process.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC27">3.13 Explanation of the Logfile Output</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC28">3.14 Various Other Hints That May Help</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                Various other hints that may help.
</td></tr>
</table>


<hr size="6">
<a name="Allocation-Macros"></a>
<a name="SEC11"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC10" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC12" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.1 Macros Providing File and Line Information </h2>


<p>By including <tt>`dmalloc.h'</tt> in your C files, your calls to malloc,
calloc, realloc, recalloc, memalign, valloc, strdup, and free are
replaced with calls to _dmalloc_malloc, _dmalloc_realloc, and
_dmalloc_free with various flags.  Additionally the library replaces
calls to xmalloc, xcalloc, xrealloc, xrecalloc, xmemalign, xvalloc,
xstrdup, and xfree with associated calls.
</p>
<p>These macros use the c-preprocessor <code>__FILE__</code> and <code>__LINE__</code>
macros which get replaced at compilation time with the current file and
line-number of the source code in question.  The routines use this
information to produce verbose reports on memory problems.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">not freed: '0x38410' (22 bytes) from 'dmalloc_t.c:92'
</pre></td></tr></table>
<p>This line from a log file shows that memory was not freed from file
<tt>`dmalloc_t.c'</tt> line 92.  See section <a href="#SEC21">Tracking Down Non-Freed Memory</a>.
</p>
<a name="IDX60"></a>
<a name="IDX61"></a>
<a name="IDX62"></a>
<a name="IDX63"></a>

<p>You may notice some non standard memory allocation functions in the
above list.  Recalloc is a routine like realloc that reallocates
previously allocated memory to a new size.  If the new memory size is
larger than the old, recalloc initializes the new space to all zeros.
This may or may not be supported natively by your operating system.
Memalign is like malloc but should insure that the returned pointer is
aligned to a certain number of specified bytes.  Currently, the memalign
function is not supported by the library.  It defaults to returning
possibly non-aligned memory for alignment values less than a block-size.
Valloc is like malloc but insures that the returned pointer will be
aligned to a page boundary.  This may or may not be supported natively
by your operating system but is fully supported by the library.  Strdup
is a string duplicating routine which takes in a null terminated string
pointer and returns an allocated copy of the string that will need to be
passed to free later to deallocate.
</p>
<p>The X versions of the standard memory functions (xmalloc, xfree, etc.)
will print out an error message to standard error and will stop if the
library is unable to allocate any additional memory.  It is useful to
use these routines instead of checking everywhere in your program for
allocation routines returning NULL pointers.
</p>
<p><em>WARNING</em>: If you are including the <tt>`dmalloc.h'</tt> file in your
sources, it is recommended that it be at the end of your include file
list because dmalloc uses macros and may try to change declarations of
the malloc functions if they come after it.
</p>

<hr size="6">
<a name="Return-Address"></a>
<a name="SEC12"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC11" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.2 Getting Caller Address Information </h2>


<p>Even though the allocation macros can provide file/line information for
some of your code, there are still modules which either you can't
include <tt>`dmalloc.h'</tt> (such as library routines) or you just don't
want to.  You can still get information about the routines that call
dmalloc function from the return-address information.  To accomplish
this, you must be using this library on one of the supported
architecture/compilers.  See section <a href="#SEC38">Issues Important for Porting the Library</a>.
</p>
<a name="IDX64"></a>

<p>The library attempts to use some assembly hacks to get the
return-address or the address of the line that called the dmalloc
function.  If you have unfreed memory that does not have associated file
and line information, you might see the following non-freed memory
messages.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">not freed: '0x38410' (22 bytes) from 'ra=0xdd2c'
not freed: '0x38600' (10232 bytes) from 'ra=0x10234d'
not freed: '0x38220' (137 bytes) from 'ra=0x82cc'
</pre></td></tr></table>
<a name="IDX65"></a>
<p>With the help of a debugger, these return-addresses (or ra) can then be
identified.  I've provided a <tt>`ra_info.pl'</tt> perl script in the
<tt>`contrib/'</tt> directory with the dmalloc sources which seems to work
well with gdb.  You can also use manual methods for gdb to find the
return-address location.  See section <a href="#SEC23">Translating Return Addresses into Code Locations</a>.
</p>

<hr size="6">
<a name="Argument-Checking"></a>
<a name="SEC13"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC12" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC14" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.3 Checking of Function Arguments </h2>


<p>One potential problem with the library and its multitude of checks and
diagnoses is that they only get performed when a dmalloc function is
called.  One solution this is to include <tt>`dmalloc.h'</tt> and compile
your source code with the <code>DMALLOC_FUNC_CHECK</code> flag defined and
enable the <code>check-funcs</code> token.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">cc -DDMALLOC -DDMALLOC_FUNC_CHECK file.c
</pre></td></tr></table>
<p><em>NOTE</em>: Once you have compiled your source with DMALLOC_FUNC_CHECK
enabled, you will have to recompile with it off to disconnect the
library.  See section <a href="#SEC17">How to Disable the library</a>.
</p>
<p><em>WARNING</em>: You should be sure to have <tt>`dmalloc.h'</tt> included at
the end of your include file list because dmalloc uses macros and may
try to change declarations of the checked functions if they come after
it.
</p>
<p>When this is defined dmalloc will override a number of functions and
will insert a routine which knows how to check its own arguments and
then call the real function.  Dmalloc can check such functions as
<code>bcopy</code>, <code>index</code>, <code>strcat</code>, and <code>strcasecmp</code>.  For
the full list see the end of <tt>`dmalloc.h'</tt>.
</p>
<p>When you call <code>strlen</code>, for instance, dmalloc will make sure the
string argument's fence-post areas have not been overwritten, its file
and line number locations are good, etc.  With <code>bcopy</code>, dmalloc
will make sure that the destination string has enough space to store the
number of bytes specified.
</p>
<p>For all of the arguments checked, if the pointer is not in the heap then
it is ignored since dmalloc does not know anything about it.
</p>

<hr size="6">
<a name="Dumping-Core"></a>
<a name="SEC14"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC13" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC15" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.4 Generating a Core File on Errors </h2>


<p>If the <code>error-abort</code> debug token has been enabled, when the
library detects any problems with the heap memory, it will immediately
attempt to dump a core file.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.  Core files are a
complete copy of the program and it's state and can be used by a
debugger to see specifically what is going on when the error occurred.
See section <a href="#SEC19">Using Dmalloc With a Debugger</a>.  By default, the low, medium, and high
arguments to the library utility enable the <code>error-abort</code> token.
You can disable this feature by entering <kbd>dmalloc -m error-abort</kbd>
(-m for minus) to remove the <code>error-abort</code> token and your program
will just log errors and continue.  You can also use the
<code>error-dump</code> token which tries to dump core when it sees an error
but still continue running.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.
</p>
<a name="IDX66"></a>
<a name="IDX67"></a>
<a name="IDX68"></a>
<a name="IDX69"></a>
<a name="IDX70"></a>

<p>When a program dumps core, the system writes the program and all of
its memory to a file on disk usually named <tt>`core'</tt>.  If your
program is called <tt>`foo'</tt> then your system may dump core as
<tt>`foo.core'</tt>.  If you are not getting a <tt>`core'</tt> file, make sure
that your program has not changed to a new directory meaning that it
may have written the core file in a different location.  Also insure
that your program has write privileges over the directory that it is
in otherwise it will not be able to dump a core file.  Core dumps are
often security problems since they contain all program memory so
systems often block their being produced.  You will want to check your
user and system's core dump size ulimit settings.
</p>
<a name="IDX71"></a>
<a name="IDX72"></a>
<a name="IDX73"></a>

<p>The library by default uses the <code>abort</code> function to dump core
which may or may not work depending on your operating system.  If the
following program does not dump core then this may be the problem.
See <code>KILL_PROCESS</code> definition in <tt>`settings.dist'</tt>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">main()
{
  abort();
}
</pre></td></tr></table>
<p>If <code>abort</code> does work then you may want to try the following
setting in <tt>`settings.dist'</tt>.  This code tries to generate a
segmentation fault by dereferencing a <code>NULL</code> pointer.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">#define KILL_PROCESS    { int *_int_p = 0L; *_int_p = 1; }
</pre></td></tr></table>

<hr size="6">
<a name="Extensions"></a>
<a name="SEC15"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC14" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC16" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.5 Additional Non-standard Routines </h2>


<p>The library has a number of variables that are not a standard part of
most malloc libraries:
</p>

<a name="IDX74"></a>
<a name="IDX75"></a>
<a name="IDX76"></a>

<dl>
<dt><u>Variable:</u> int <b>dmalloc_errno</b>
<a name="IDX77"></a>
</dt>
<dd><p>This variable stores the internal dmalloc library error number like errno
does for the system calls.  It can be passed to <code>dmalloc_strerror()</code>
(see below) to get a string version of the error.  It will have a value
of zero if the library has not detected any problems.
</p>
</dd></dl>


<a name="IDX78"></a>
<a name="IDX79"></a>

<dl>
<dt><u>Variable:</u> char* <b>dmalloc_logpath</b>
<a name="IDX80"></a>
</dt>
<dd><p>This variable can be used to set the dmalloc log filename.  The env
variable <code>DMALLOC_LOGFILE</code> overrides this variable.
</p>

</dd></dl>

<p>Additionally the library provides a number of non-standard malloc
routines:
</p>

<a name="IDX81"></a>
<a name="IDX82"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_shutdown</b><i> ( void )</i>
<a name="IDX83"></a>
</dt>
<dd><a name="IDX84"></a>
<a name="IDX85"></a>

<p>This function shuts the library down and logs the final statistics and
information especially the non-freed memory pointers.  The library has
code to support auto-shutdown if your system has the <code>on_exit()</code>
call, <code>atexit()</code> call, or compiler destructor support (see
<tt>`conf.h'</tt>).  If you do not have these, then <code>dmalloc_shutdown</code>
should be called right before <code>exit()</code> or as the last function in
<code>main()</code>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">main()
{
        &hellip;
        dmalloc_shutdown();
        exit(0);
}
</pre></td></tr></table></dd></dl>


<a name="IDX86"></a>
<a name="IDX87"></a>
<a name="IDX88"></a>

<dl>
<dt><u>Function:</u> int <b>dmalloc_verify</b><i> ( char * <var>pnt</var> )</i>
<a name="IDX89"></a>
</dt>
<dd><p>This function verifies individual memory pointers that are suspect of
memory problems.  To check the entire heap pass in a NULL or 0 pointer.
The routine returns DMALLOC_VERIFY_ERROR or DMALLOC_VERIFY_NOERROR.
</p>
<p><em>NOTE</em>: <samp>`dmalloc_verify()'</samp> can only check the heap with the
functions that have been enabled.  For example, if fence-post checking
is not enabled, <samp>`dmalloc_verify()'</samp> cannot check the fence-post
areas in the heap.
</p></dd></dl>


<a name="IDX90"></a>
<a name="IDX91"></a>
<a name="IDX92"></a>

<dl>
<dt><u>Function:</u> unsigned-int <b>dmalloc_debug</b><i> ( const unsigned int <var>flags</var> )</i>
<a name="IDX93"></a>
</dt>
<dd><p>This routine sets the debug functionality flags and returns the
previous flag value.  It is helpful in server or cgi-bin programs
where environmental variables cannot be used.  See section <a href="#SEC26">Debugging Memory in a Server or Cgi-Bin Process</a>.  For instance, if debugging should never be enabled for a
program, a call to <code>dmalloc_debug(0)</code> as the first call in
<code>main()</code> will disable all the memory debugging from that point
on.
</p>
<p><em>NOTE</em>: you cannot add or remove certain flags such as signal
handlers since they are setup at initialization time only.
</p>
<p><em>NOTE</em>: you can also use <code>dmalloc_debug_setup</code> below.
</p>
</dd></dl>


<a name="IDX94"></a>
<a name="IDX95"></a>

<dl>
<dt><u>Function:</u> unsigned-int <b>dmalloc_debug_current</b><i> ( void )</i>
<a name="IDX96"></a>
</dt>
<dd><p>This routine returns the current debug functionality value value.  This
allows you to save a copy of the debug dmalloc settings to be changed
and then restored later.
</p>
</dd></dl>


<a name="IDX97"></a>
<a name="IDX98"></a>
<a name="IDX99"></a>
<a name="IDX100"></a>
<a name="IDX101"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_debug_setup</b><i> ( const char * <var>options_str</var> )</i>
<a name="IDX102"></a>
</dt>
<dd><p>This routine sets the global debugging functionality as an option
string.  Normally this would be passed in in the DMALLOC_OPTIONS
environmental variable.  This is here to override the env or for
circumstances where modifying the environment is not possible or does
not apply such as servers or cgi-bin programs.  See section <a href="#SEC26">Debugging Memory in a Server or Cgi-Bin Process</a>.
</p>
<p>Some examples:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">/*
 * debug tokens high, threaded lock-on at 20,
 * log to dmalloc.%p (pid)
 */
dmalloc_debug_setup(&quot;debug=0x4f46d03,lockon=20,log=dmalloc.%p&quot;);

/*
 * turn on some debug tokens directly and log to the
 * file 'logfile'
 */
dmalloc_debug_setup(
  &quot;log-stats,log-non-free,check-fence,log=logfile&quot;);
</pre></td></tr></table>
</dd></dl>


<a name="IDX103"></a>
<a name="IDX104"></a>
<a name="IDX105"></a>

<dl>
<dt><u>Function:</u> int <b>dmalloc_examine</b><i> ( const DMALLOC_PNT <var>pnt</var>, DMALLOC_SIZE * <var>user_size_p</var>, DMALLOC_SIZE * <var>total_size_p</var>, char ** <var>file_p</var>, int * <var>line_p</var>, DMALLOC_PNT * <var>ret_addr_p</var>, unsigned long * <var>user_mark_p</var>, unsigned long * <var>seen_p</var> )</i>
<a name="IDX106"></a>
</dt>
<dd><a name="IDX107"></a>
<p>This function returns the size of a pointer's allocation as well as the
total size given including administrative overhead, file and line or the
return-address from where it was allocated, the last pointer when the
pointer was &quot;used&quot;, and the number of times the pointer has been &quot;seen&quot;.
It will return DMALLOC_NOERROR or DMALLOC_ERROR depending on whether pnt
is good or not.
</p>
<p><em>NOTE</em>: This function is <em>certainly</em> not provided by most if
not all other malloc libraries.
</p>
</dd></dl>


<a name="IDX108"></a>
<a name="IDX109"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_track</b><i> ( const dmalloc_track_t <var>track_func</var> )</i>
<a name="IDX110"></a>
</dt>
<dd><p>Register an allocation tracking function which will be called each time
an allocation occurs.  Pass in NULL to disable.  To take a look at what
information is provided, see the dmalloc_track_t function typedef in
dmalloc.h.
</p>
</dd></dl>


<a name="IDX111"></a>
<a name="IDX112"></a>
<a name="IDX113"></a>
<a name="IDX114"></a>
<a name="IDX115"></a>
<a name="IDX116"></a>

<dl>
<dt><u>Function:</u> unsigned-long <b>dmalloc_mark</b><i> ( void )</i>
<a name="IDX117"></a>
</dt>
<dd><p>Return to the caller the current &quot;mark&quot; which can be used later to log
the pointers which have changed since this mark with the
<code>dmalloc_log_changed</code> function.  Multiple marks can be saved and
used.
</p>
<p>This is very useful when using the library with a server which does
not exit.  You can then save a mark before a transaction or event
happens and then check to see what has changed using the
<code>dmalloc_log_changed</code> function below.  See section <a href="#SEC26">Debugging Memory in a Server or Cgi-Bin Process</a>.
</p>
<p>If you <code>LOG_ITERATION</code> enabled in your <tt>`settings.h'</tt> file then
the entries in the log file will be prepended with the number of memory
transactions that the library has handled so far.  You can also enable
<code>LOG_PNT_ITERATION</code> in <tt>`settings.h'</tt> to store the memory
transaction number with each pointer.
</p>
</dd></dl>


<a name="IDX118"></a>
<a name="IDX119"></a>
<a name="IDX120"></a>

<dl>
<dt><u>Function:</u> unsigned-long <b>dmalloc_memory_allocated</b><i> ( void )</i>
<a name="IDX121"></a>
</dt>
<dd><p>Return to the caller the total number of bytes that have been allocated
by the library.  This is not the current in use but the total number of
bytes returned by allocation functions.
</p>
</dd></dl>


<a name="IDX122"></a>
<a name="IDX123"></a>

<dl>
<dt><u>Function:</u> unsigned-int <b>dmalloc_page_size</b><i> ( void )</i>
<a name="IDX124"></a>
</dt>
<dd><p>Return to the caller the memory page-size being used by the library.
This should be the same value as the one returned by the
<code>getpagesize()</code> function, if available.
</p>
</dd></dl>


<a name="IDX125"></a>
<a name="IDX126"></a>
<a name="IDX127"></a>

<dl>
<dt><u>Function:</u> unsigned-long <b>dmalloc_count_changed</b><i> ( const unsigned long <var>mark</var>, const int <var>not_freed_b</var>, const int <var>free_b</var> )</i>
<a name="IDX128"></a>
</dt>
<dd><p>Count the pointers that have changed since the mark which was returned by
<code>dmalloc_mark</code>.  If <code>not_freed_b</code> is set to non-0 then count the
pointers that have not been freed.  If <code>free_b</code> is set to non-0
then count the pointers that have been freed.
</p>
<p>This can be used in conjunction with the <code>dmalloc_mark()</code>
function to help servers which never exit ensure that transactions or
events are not leaking memory.  See section <a href="#SEC26">Debugging Memory in a Server or Cgi-Bin Process</a>.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">unsigned long mark = dmalloc_mark() ;
&hellip;
assert(dmalloc_count_changed(mark, 1, 0) == 0) ;
</pre></td></tr></table>
</dd></dl>


<a name="IDX129"></a>
<a name="IDX130"></a>
<a name="IDX131"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_log_stats</b><i> ( void )</i>
<a name="IDX132"></a>
</dt>
<dd><p>This routine outputs the current dmalloc statistics to the log file.
</p></dd></dl>


<a name="IDX133"></a>
<a name="IDX134"></a>
<a name="IDX135"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_log_unfreed</b><i> ( void )</i>
<a name="IDX136"></a>
</dt>
<dd><p>This function logs the unfreed-memory information to the log file.
This is also useful to log the currently allocated points to the log
file to be compared against another dump later on.
</p>
</dd></dl>


<a name="IDX137"></a>
<a name="IDX138"></a>
<a name="IDX139"></a>
<a name="IDX140"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_log_changed</b><i> ( const unsigned long <var>mark</var>, const int <var>not_freed_b</var>, const int <var>freed_b</var>, const int <var>details_b</var> )</i>
<a name="IDX141"></a>
</dt>
<dd><p>Log the pointers that have changed since the mark which was returned by
<code>dmalloc_mark</code>.  If <code>not_freed_b</code> is set to non-0 then log the
pointers that have not been freed.  If <code>free_b</code> is set to non-0
then log the pointers that have been freed.  If <code>details_b</code> set to
non-0 then log the individual pointers that have changed otherwise just
log the summaries.
</p>
<p>This can be used in conjunction with the <code>dmalloc_mark()</code>
function to help servers which never exit find transactions or events
which are leaking memory.  See section <a href="#SEC26">Debugging Memory in a Server or Cgi-Bin Process</a>.
</p>
</dd></dl>


<a name="IDX142"></a>
<a name="IDX143"></a>
<a name="IDX144"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_vmessage</b><i> ( const char * <var>format</var>, va_list <var>args</var> )</i>
<a name="IDX145"></a>
</dt>
<dd><p>Write a message into the dmalloc logfile using vprintf-like arguments.
</p>
</dd></dl>


<a name="IDX146"></a>
<a name="IDX147"></a>
<a name="IDX148"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_message</b><i> ( const char * <var>format</var>, <var>...</var> )</i>
<a name="IDX149"></a>
</dt>
<dd><p>Write a message into the dmalloc logfile using printf-like arguments.
</p>
</dd></dl>


<a name="IDX150"></a>
<a name="IDX151"></a>
<a name="IDX152"></a>
<a name="IDX153"></a>

<dl>
<dt><u>Function:</u> void <b>dmalloc_get_stats</b><i> ( DMALLOC_PNT * <var>heap_low_p</var>, DMALLOC_PNT * <var>heap_high_p</var>, unsigned long * <var>total_space_p</var>, unsigned long * <var>user_space_p</var>, unsigned long * <var>current_allocated_p</var>, unsigned long * <var>current_pnt_np</var>, unsigned long * <var>max_allocated_p</var>, unsigned long * <var>max_pnt_np</var>, unsigned long * <var>max_one_p</var>)</i>
<a name="IDX154"></a>
</dt>
<dd><p>This function return a number of statistics about the current heap.
The pointers <code>heap_low_p</code> and <code>heap_high_p</code> will be set to
the low and high spots in the heap.  <code>total_space_p</code> will be set
to the total space in the heap including user space, administrative
space, and overhead.  <code>user_space_p</code> will be set to the space
given to the user process (allocated and free space).
<code>current_allocated_p</code> will be set to the current allocated space
given to the user process.  <code>current_pnt_np</code> will be set to the
current number of pointers allocated by the user process.
<code>max_allocated_p</code> will be set to the maximum allocated space
given to the user process.  <code>max_pnt_np</code> will be set to the
maximum number of pointers allocated by the user process.
<code>max_on_p</code> will be set to the maximum space allocated with one
call by the user process.
</p>
</dd></dl>


<a name="IDX155"></a>
<a name="IDX156"></a>
<a name="IDX157"></a>

<dl>
<dt><u>Function:</u> const-char* <b>dmalloc_strerror</b><i> ( const int <var>error_number</var> )</i>
<a name="IDX158"></a>
</dt>
<dd><p>This function returns the string representation of the error value in
<code>error_number</code> (which probably should be dmalloc_errno).  This
allows the logging of more verbose memory error messages.
</p>
<p>You can also display the string representation of an error value by a
call to the <tt>`dmalloc'</tt> program with a <samp>`-e #'</samp> option.
See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
</dd></dl>


<hr size="6">
<a name="Error-Codes"></a>
<a name="SEC16"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC15" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC17" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.6 Description of the Internal Error Codes </h2>


<p>The following error codes are defined in <tt>`error_val.h'</tt>.  They are
used by the library to indicate a detected problem.  They can be caused
by the user (<samp>`ERROR_TOO_BIG'</samp>) or can indicate an internal library
problem (<samp>`ERROR_SLOT_CORRUPT'</samp>).  The <tt>`dmalloc'</tt> utility can
give you the string version of the error with the <code>-e</code> argument:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">$ dmalloc -e 60
dmalloc: dmalloc_errno value '60' = 
   'pointer is not on block boundary'
</pre></td></tr></table>
<p>Here are the error codes set by the library.  They are non contiguous on
purpose because I add and delete codes all of the time and there are
sections for various error-code types.
</p>
<dl compact="compact">
<dd>

<a name="IDX159"></a>
<a name="IDX160"></a>
<a name="IDX161"></a>
<a name="IDX162"></a>

</dd>
<dt> <code>1 (ERROR_NONE) no error</code></dt>
<dd><p>No error.  It is good coding practice to set the no-error code to be
non-0 value because it forces you to set it explicitly.
</p>

<a name="IDX163"></a>
<a name="IDX164"></a>
<a name="IDX165"></a>
<a name="IDX166"></a>
<a name="IDX167"></a>

</dd>
<dt> <code>2 (INVALID_ERROR)</code></dt>
<dd><p>Invalid error number.  If the library outputs this error then your
dmalloc utility may be out of date with the library you linked
against.  This will be returned with all error codes not listed here.
</p>

<a name="IDX168"></a>
<a name="IDX169"></a>
<a name="IDX170"></a>
<a name="IDX171"></a>
<a name="IDX172"></a>

</dd>
<dt> <code>10 (ERROR_BAD_SETUP) initialization and setup failed</code></dt>
<dd><p>Bad setup value.  This is currently unused but it is intended to report
on invalid setup configuration information.
</p>

<a name="IDX173"></a>
<a name="IDX174"></a>
<a name="IDX175"></a>
<a name="IDX176"></a>
<a name="IDX177"></a>
<a name="IDX178"></a>
<a name="IDX179"></a>

</dd>
<dt> <code>11 (ERROR_IN_TWICE) malloc library has gone recursive</code></dt>
<dd><p>Library went recursive.  This usually indicates that you are not using
the threaded version of the library.  Or if you are then you are not
using the <samp>`-o'</samp> &quot;lock-on&quot; option.  See section <a href="#SEC24">Using the Library with a Thread Package</a>.
</p>

<a name="IDX180"></a>
<a name="IDX181"></a>
<a name="IDX182"></a>
<a name="IDX183"></a>
<a name="IDX184"></a>

</dd>
<dt> <code>13 (ERROR_LOCK_NOT_CONFIG) thread locking has not been configured</code></dt>
<dd><p>Thread locking has not been configured.  This indicates that you
attempted to use the <samp>`-o'</samp> &quot;lock-on&quot; option without linking with
the thread version of the library.  You should probably be using
<code>-ldmallocth</code> <em>not</em> <code>-ldmalloc</code> when you are linking.
Or you should include <code>&hellip;/lib/libdmallocth.a</code> on your
compilation line.
</p>

<a name="IDX185"></a>
<a name="IDX186"></a>
<a name="IDX187"></a>
<a name="IDX188"></a>
<a name="IDX189"></a>
<a name="IDX190"></a>
<a name="IDX191"></a>

</dd>
<dt> <code>20 (ERROR_IS_NULL) pointer is null</code></dt>
<dd><p>Pointer is null.  The program passed a NULL (0L) pointer to <code>free</code>
and you have the <code>error-free-null</code> token enabled.
</p>

<a name="IDX192"></a>
<a name="IDX193"></a>
<a name="IDX194"></a>
<a name="IDX195"></a>
<a name="IDX196"></a>
<a name="IDX197"></a>

</dd>
<dt> <code>21 (ERROR_NOT_IN_HEAP) pointer is not pointing to heap data space</code></dt>
<dd><p>Pointer is not pointing to heap data space.  This means that the program
passed an out-of-bounds pointer to <code>free</code> or <code>realloc</code>.  This
could be someone trying to work with a wild pointer or trying to free a
pointer from a different source than <code>malloc</code>.
</p>

<a name="IDX198"></a>
<a name="IDX199"></a>
<a name="IDX200"></a>
<a name="IDX201"></a>
<a name="IDX202"></a>
<a name="IDX203"></a>
<a name="IDX204"></a>
<a name="IDX205"></a>

</dd>
<dt> <code>22 (ERROR_NOT_FOUND) cannot locate pointer in heap</code></dt>
<dd><p>Cannot locate pointer in heap.  The user passed in a pointer which the
heap did not know about.  Either this pointer was allocated by some
other mechanism (like <code>mmap</code> or <code>sbrk</code> directly) or it is a
random invalid pointer.
</p>
<p>In some rare circumstances, sometimes seen with shared libraries, there
can be two separate copies of the dmalloc library in a program.  Each
one does not know about the pointers allocated by the other.
</p>

<a name="IDX206"></a>
<a name="IDX207"></a>
<a name="IDX208"></a>
<a name="IDX209"></a>
<a name="IDX210"></a>

</dd>
<dt> <code>23 (ERROR_IS_FOUND) found pointer the user was looking for</code></dt>
<dd><p>This indicates that the pointer specified in the address part of the
environmental variable was discovered by the library.  See section <a href="#SEC32">Environment Variable Name and Features</a>.  This error is useful so you can put a breakpoint in a
debugger to find where a particular address was allocated.  See section <a href="#SEC19">Using Dmalloc With a Debugger</a>.
</p>

<a name="IDX211"></a>
<a name="IDX212"></a>
<a name="IDX213"></a>
<a name="IDX214"></a>
<a name="IDX215"></a>

</dd>
<dt> <code>24 (ERROR_BAD_FILE) possibly bad .c filename pointer</code></dt>
<dd><p>A possibly invalid filename was discovered in the dmalloc administrative
sections.  This could indicate some corruption of the internal tables.
It also could mean that you have a source file whose name is longer than
100 characters.  See <code>MAX_FILE_LENGTH</code> in the <tt>`settings.dist'</tt>
file.
</p>

<a name="IDX216"></a>
<a name="IDX217"></a>
<a name="IDX218"></a>
<a name="IDX219"></a>
<a name="IDX220"></a>

</dd>
<dt> <code>25 (ERROR_BAD_LINE) possibly bad .c file line-number</code></dt>
<dd><p>A line-number was out-of-bounds in the dmalloc administrative sections.
This could indicate some corruption of the internal tables.  It also
could mean that you have a source file containing more than <code>30000</code>
lines of code.  See <code>MAX_LINE_NUMBER</code> in the <tt>`settings.dist'</tt>
file.
</p>

<a name="IDX221"></a>
<a name="IDX222"></a>
<a name="IDX223"></a>
<a name="IDX224"></a>
<a name="IDX225"></a>

</dd>
<dt> <code>26 (ERROR_UNDER_FENCE) failed UNDER picket-fence magic-number check</code></dt>
<dd><p>This indicates that a pointer had its lower bound picket-fence magic
number overwritten.  If the <code>check-fence</code> token is enabled, the
library writes magic values above and below allocations to protect
against overflow.  Most likely this is because a pointer below it went
past its allocate and wrote into the next pointer's space.
</p>

<a name="IDX226"></a>
<a name="IDX227"></a>
<a name="IDX228"></a>
<a name="IDX229"></a>
<a name="IDX230"></a>

</dd>
<dt> <code>27 (ERROR_OVER_FENCE) failed OVER picket-fence magic-number check</code></dt>
<dd><p>This indicates that a pointer had its upper bound picket-fence magic
space overwritten.  If the <code>check-fence</code> token is enabled, the
library writes magic values above and below allocations to protect
against overflow.  Most likely this is because an array or string
allocation wrote past the end of the allocation.
</p>
<p>Check for improper usage of <code>strcat</code>, <code>sprintf</code>,
<code>strcpy</code>, and any other functions which work with strings and do
not protect themselves by tracking the size of the string.  These
functions should <em>always</em> be replaced with: <code>strncat</code>,
<code>snprintf</code>, <code>strncpy</code>, and others.
</p>

<a name="IDX231"></a>
<a name="IDX232"></a>
<a name="IDX233"></a>
<a name="IDX234"></a>
<a name="IDX235"></a>

</dd>
<dt> <code>28 (ERROR_WOULD_OVERWRITE) use of pointer would exceed allocation</code></dt>
<dd><p>This error is generated by the function pointer checking code usually
enabled with the <code>check-funcs</code> token.  Dmalloc overloads a number of
string and memory copying functions and verifies that the buffers (if
allocated in the heap) would not be overwritten by the function.
</p>

<a name="IDX236"></a>
<a name="IDX237"></a>
<a name="IDX238"></a>
<a name="IDX239"></a>
<a name="IDX240"></a>

</dd>
<dt> <code>30 (ERROR_NOT_START_BLOCK) pointer is not to start of memory block</code></dt>
<dd><p>This indicates that the user passed in a pointer to be freed or
reallocated that was not at the start of the allocation.  You would get
this error, for example, if you allocate and get pointer <code>X</code> but
then try to free <code>X+1</code>.
</p>

<a name="IDX241"></a>
<a name="IDX242"></a>
<a name="IDX243"></a>
<a name="IDX244"></a>
<a name="IDX245"></a>

</dd>
<dt> <code>40 (ERROR_BAD_SIZE) invalid allocation size</code></dt>
<dd><p>This error indicates that a size value in the internal structures of the
library were corrupted.  This could be a random pointer problem, pointer
overflow, or some other corruption.
</p>

<a name="IDX246"></a>
<a name="IDX247"></a>
<a name="IDX248"></a>
<a name="IDX249"></a>
<a name="IDX250"></a>

</dd>
<dt> <code>41 (ERROR_TOO_BIG) largest maximum allocation size exceeded</code></dt>
<dd><p>An allocation asked for memory larger than the configured maximum.  This
is a user configured setting.  See <code>LARGEST_ALLOCATION</code> in the
<tt>`settings.dist'</tt> file.  It is used to protect against wild
allocation sizes.  If you have super large allocation sizes then you
should tune the <code>LARGEST_ALLOCATION</code> value appropriately.
</p>

<a name="IDX251"></a>
<a name="IDX252"></a>
<a name="IDX253"></a>
<a name="IDX254"></a>
<a name="IDX255"></a>

</dd>
<dt> <code>43 (ERROR_ALLOC_FAILED) could not grow heap by allocating memory</code></dt>
<dd><p>The library could not allocate more heap space and the program has run
out of memory.  This could indicate that you've overflowed some system
imposed limit.  On many operation systems, the <code>ulimit</code> call can
tune system defaults.  The library uses a lot more memory compared to
the system malloc library because it stores a lot more information
about the allocated pointers.
</p>
<a name="IDX256"></a>
<a name="IDX257"></a>

<p><em>NOTE</em>: This also may be due to an inability of your operating
system to use the <code>mmap</code> system call to allocate memory.  You may
need to force the <code>USE_MMAP</code> setting to be 0.  Please use the
forums at URL <a href="http://dmalloc.com/">http://dmalloc.com/</a> to report issues with this.
</p>

<a name="IDX258"></a>
<a name="IDX259"></a>
<a name="IDX260"></a>
<a name="IDX261"></a>
<a name="IDX262"></a>
<a name="IDX263"></a>

</dd>
<dt> <code>45 (ERROR_OVER_LIMIT) over user specified allocation limit</code></dt>
<dd><p>The library has allocated more memory than was specified in the
memory-limit environmental variable.  See section <a href="#SEC32">Environment Variable Name and Features</a>.
</p>

<a name="IDX264"></a>
<a name="IDX265"></a>
<a name="IDX266"></a>
<a name="IDX267"></a>
<a name="IDX268"></a>

</dd>
<dt> <code>60 (ERROR_NOT_ON_BLOCK) pointer is not on block boundary</code></dt>
<dd><p>The user tried to free or realloc a pointer that was not pointing to a
block boundary.  You would get this error, for example, if you allocate
and get pointer <code>X</code> but then try to free <code>X+1</code>.
</p>

<a name="IDX269"></a>
<a name="IDX270"></a>
<a name="IDX271"></a>
<a name="IDX272"></a>
<a name="IDX273"></a>

</dd>
<dt> <code>61 (ERROR_ALREADY_FREE) tried to free previously freed pointer</code></dt>
<dd><p>The user tried to free a pointer than has already been freed.  This is a
very common mistake and can lead to serious problems.  It can be because
a destructor is being called twice for some reason.  Although tracking
down the specific source is highly recommended, it is good to set
pointers to NULL (0L) after you free them as a rule.
</p>

<a name="IDX274"></a>
<a name="IDX275"></a>
<a name="IDX276"></a>
<a name="IDX277"></a>
<a name="IDX278"></a>
<a name="IDX279"></a>
<a name="IDX280"></a>

</dd>
<dt> <code>67 (ERROR_FREE_OVERWRITTEN) free space has been overwritten</code></dt>
<dd><p>If either the <code>free-blank</code> or <code>check-blank</code> tokens are enabled
then the library will overwrite memory when it is freed with the
&quot;dmalloc-free&quot; byte (hex 0xdf, octal 0337, decimal 223).  If the
program writes into this space, then the library will detect the write
and trigger this error.  This could indicate that the program is using a
pointer after it has been freed.
</p>

<a name="IDX281"></a>
<a name="IDX282"></a>
<a name="IDX283"></a>
<a name="IDX284"></a>
<a name="IDX285"></a>

</dd>
<dt> <code>70 (ERROR_ADMIN_LIST) bad admin structure list</code></dt>
<dd><p>An internal corruption in the library's administrative structures has
been detected.  This could be a random pointer problem, pointer
overflow, or some other corruption.
</p>

<a name="IDX286"></a>
<a name="IDX287"></a>
<a name="IDX288"></a>
<a name="IDX289"></a>
<a name="IDX290"></a>

</dd>
<dt> <code>72 (ERROR_ADDRESS_LIST) internal address list corruption</code></dt>
<dd><p>An internal corruption in the library's administrative structures has
been detected.  This could be a random pointer problem, pointer
overflow, or some other corruption.
</p>

<a name="IDX291"></a>
<a name="IDX292"></a>
<a name="IDX293"></a>
<a name="IDX294"></a>
<a name="IDX295"></a>

</dd>
<dt> <code>73 (ERROR_SLOT_CORRUPT) internal memory slot corruption</code></dt>
<dd><p>An internal corruption in the library's administrative structures has
been detected.  This could be a random pointer problem, pointer
overflow, or some other corruption.
</p>
</dd>
</dl>


<hr size="6">
<a name="Disabling-the-Library"></a>
<a name="SEC17"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC16" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC18" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.7 How to Disable the library </h2>


<p>If you would like to disable the library's detailed checking features
during a particularly allocation intensive section of code, you can do
something like the following:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">        unsigned int dmalloc_flags;
        &hellip;
        /* turn off all debug flags and save a copy of old value */
        dmalloc_flags = dmalloc_debug(0);

        /* section of a lot of allocations */
        &hellip;
        /* end of section */

        /* restore the dmalloc flag setting */
        dmalloc_debug(dmalloc_flags);
</pre></td></tr></table>
<p>When you are finished with the development and debugging sessions, you
may want to disable the dmalloc library and put in its place either the
system's memory-allocation routines, gnu-malloc, or maybe your own.
Attempts have been made to make this a reasonably painless process.  The
ease of the extraction depends heavily on how many of the library's
features your made use of during your coding.
</p>
<p>Reasonable suggestions are welcome as to how to improve this process
while maintaining the effectiveness of the debugging.
</p>
<ul>
<li>
If you want to <em>totally</em> disable the dmalloc library then you will
need to recompile all the C files that include <tt>`dmalloc.h'</tt> while
defining <code>DMALLOC_DISABLE</code>.  This will cause the dmalloc macros to
not be applied.  See section <a href="#SEC11">Macros Providing File and Line Information</a>.

<table><tr><td>&nbsp;</td><td><pre class="example">cc -g -DDMALLOC_DISABLE file.c
</pre></td></tr></table>
<p>An alternative is to surround the <code>dmalloc.h</code> inclusion or any
direct dmalloc references with an <code>#ifdef DMALLOC</code> and then just
remove the -DDMALLOC.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">#ifdef DMALLOC
#include &quot;dmalloc.h&quot;
#endif

main()
{
  &hellip;

#ifdef DMALLOC
  dmalloc_verify(0L);
#endif
  return 0;
}
</pre></td></tr></table>
<table><tr><td>&nbsp;</td><td><pre class="example">// to get dmalloc information
$ cc -DDMALLOC main.c

// without dmalloc information
$ cc main.c
</pre></td></tr></table>
</li><li>
If you compiled any of your source modules with <code>DMALLOC_FUNC_CHECK</code>
defined then you must first recompile all those modules without the flag
enabled.

<p>If you have disabled dmalloc with the <code>DMALLOC_DISABLED</code> flag or
never included <tt>`dmalloc.h'</tt> in any of your C files, then you will
not need to recompile your sources when you need to disable the library.
</p>
<p>If you get unresolved references like <code>_dmalloc_malloc</code> or
<code>_dmalloc_bcopy</code> then something was not disabled as it should have
been.
</p></li></ul>


<hr size="6">
<a name="Using-With-C_002b_002b"></a>
<a name="SEC18"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC17" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC19" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.8 Using the Library with C++ </h2>


<p>For those people using the C++ language, the library tries to configure
and build <tt>`libdmallocxx.a'</tt> library.  This library should be linked
into your C++ programs instead of <tt>`libdmalloc.a'</tt>.
</p>
<a name="IDX296"></a>
<p>Dmalloc is not as good with C++ as C because the dynamic memory routines
in C++ are <code>new()</code> and <code>delete()</code> as opposed to
<code>malloc()</code> and <code>free()</code>.  Since new and delete are usually not
used as functions but rather as <code>x = new type</code>, there is no easy
way for dmalloc to pass in file and line information unfortunately.  The
<tt>`libdmallocxx.a'</tt> library provides the file <tt>`dmallocc.cc'</tt> which
effectively redirects <code>new</code> to the more familiar <code>malloc</code> and
<code>delete</code> to the more familiar <code>free</code>.
</p>
<p><em>NOTE</em>: The author is not a C++ hacker so feedback in the form of
other hints and ideas for C++ users would be much appreciated.
</p>

<hr size="6">
<a name="Using-With-a-Debugger"></a>
<a name="SEC19"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC18" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC20" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.9 Using Dmalloc With a Debugger </h2>


<p>Here are a number of possible scenarios for using the dmalloc library to
track down problems with your program.
</p>
<p>You should first enable a logfile filename and turn on a set of debug
features.  You can use <kbd>dmalloc -l logfile low</kbd> to accomplish this.
If you are interested in having the error messages printed to your
terminal as well, enable the <code>print-messages</code> token by typing
<kbd>dmalloc -p print-messages</kbd> afterwards.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
<a name="IDX297"></a>
<a name="IDX298"></a>
<p>Now you can enter your debugger (I use the <em>excellent</em> GNU debugger
gdb), and put a break-point in <code>dmalloc_error()</code> which is the
internal error routine for the library.  When your program is run, it
will stop there if a memory problem is detected.
</p>
<p>If you are using GDB, I would recommend adding the contents of
<tt>`dmalloc.gdb'</tt> in the <tt>`contrib'</tt> subdirectory to your
<tt>`.gdbinit'</tt> file in your home directory.  This enables the
<code>dmalloc</code> command which will prompt you for the arguments to the
dmalloc command and will set a break point in <code>dmalloc_error()</code>
automatically.
</p>
<a name="IDX299"></a>
<a name="IDX300"></a>
<p>If you are using shared libraries, you may want to execute the following
commands initially to load in dmalloc and other library symbols:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">(gdb) sharedlibrary
(gdb) add-shared-symbol-files
</pre></td></tr></table>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC20">3.9.1 Diagnosing General Problems with a Debugger</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                Diagnosing general problems with a debugger.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC21">3.9.2 Tracking Down Non-Freed Memory</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                  Tracking down non-freed memory.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC22">3.9.3 Diagnosing Fence-Post Overwritten Memory</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">           Diagnosing fence-post overwritten memory.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC23">3.9.4 Translating Return Addresses into Code Locations</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">    Convert ra return-addresses into a location.
</td></tr>
</table>


<hr size="6">
<a name="General-Errors"></a>
<a name="SEC20"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC19" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC21" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC19" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.9.1 Diagnosing General Problems with a Debugger </h3>


<p>If your program stops at the <code>dmalloc_error()</code> routine then one
of a number of problems could be happening.  Incorrect arguments could
have been passed to a malloc call: asking for negative number of
bytes, trying to realloc a non-heap pointer, etc..  There also could
be a problem with the system's allocations: you've run out of memory,
some other function in your program is using the heap allocation
functions <code>mmap</code> or <code>sbrk</code>, etc..  However, it is most
likely that some code that has been executed was naughty.
</p>
<p>To get more information about the problem, first print via the debugger
the dmalloc_errno variable to get the library's internal error code.
You can suspend your debugger and run <kbd>dmalloc -e
value-returned-from-print</kbd> to get an English translation of the error.
A number of the error messages are designed to indicate specific
problems with the library administrative structures and may not be
user-friendly.
</p>
<p>If the problem was due to the arguments or system allocations then the
source of the problem has been found.  However, if some code did
something wrong, you may have some more work to do to locate the actual
problem.  The <code>check-heap</code> token should be enabled and the interval
setting disabled or set to a low value so that the library can find the
problem as close as possible to its source.  The code that was execute
right before the library halted, can then be examined closely for
irregularities.  See section <a href="#SEC33">Description of the Debugging Tokens</a>, See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
<a name="IDX301"></a>

<p>You may also want to put calls to <code>dmalloc_verify(0)</code> in your code
before the section which generated the error.  This should locate the
problem faster by checking the library's structures at that point.
See section <a href="#SEC15">Additional Non-standard Routines</a>.
</p>

<hr size="6">
<a name="Memory-Leaks"></a>
<a name="SEC21"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC20" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC19" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.9.2 Tracking Down Non-Freed Memory </h3>


<p>So you've run your program, examined the log-file and discovered (to
your horror) some un-freed memory.  Memory leaks can become large
problems since even the smallest and most insignificant leak can starve
the program given the right circumstances.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">not freed: '0x45008' (12 bytes) from 'ra=0x1f8f4'
not freed: '0x45028' (12 bytes) from 'unknown'
not freed: '0x45048' (10 bytes) from 'argv.c:1077'
  known memory not freed: 1 pointer, 10 bytes
unknown memory not freed: 2 pointers, 24 bytes
</pre></td></tr></table>
<p>Above you will see a sample of some non-freed memory messages from the
logfile.  In the first line the <samp>`0x45008'</samp> is the pointer that was
not freed, the <samp>`12 bytes'</samp> is the size of the unfreed block, and the
<samp>`ra=0x1f8f4'</samp> or return-address shows where the allocation
originated from.  See section <a href="#SEC23">Translating Return Addresses into Code Locations</a>.
</p>
<p>The systems which cannot provide return-address information show
<samp>`unknown'</samp> instead, as in the 2nd line in the sample above.
</p>
<p>The <samp>`argv.c:1077'</samp> information from the 3rd line shows the file and
line number which allocated the memory which was not freed.  This
information comes from the calls from C files which included
<tt>`dmalloc.h'</tt>.  See section <a href="#SEC11">Macros Providing File and Line Information</a>.
</p>
<p>At the bottom of the sample it totals the memory for you and breaks it
down to known memory (those calls which supplied the file/line
information) and unknown (the rest).
</p>
<p>Often, you may allocate memory in via <code>strdup()</code> or another
routine, so the logfile listing where in the <code>strdup</code> routine the
memory was allocated does not help locate the true source of the memory
leak - the routine that called <code>strdup</code>.  Without a mechanism to
trace the calling stack, there is no way for the library to see who the
caller of the caller (so to speak) was.
</p>
<a name="IDX302"></a>
<a name="IDX303"></a>
<a name="IDX304"></a>

<p>However, there is a way to track down unfreed memory in this
circumstance.  You need to compile the library with
<code>STORE_SEEN_COUNT</code> defined in <tt>`conf.h'</tt>.  The library will then
record how many times a pointer has been allocated or freed.  It will
display the unfreed memory as:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">not freed: '0x45008|s3' (12 bytes) from 'ra=0x1f8f4'
</pre></td></tr></table>
<p>The <code>STORE_SEEN_COUNT</code> option adds a <samp>`|s#'</samp> qualifier to the
address.  This means that the address in question was seen <samp>`#'</samp> many
times.  In the above example, the address <samp>`0x45008'</samp> was seen
<samp>`3'</samp> times.  The last time it was allocated, it was not freed.
</p>
<p>How can a pointer be &quot;seen&quot; 3 times?  Let say you <code>strdup</code> a
string of 12 characters and get address <samp>`0x45008'</samp> - this is #1
time the pointer is seen.  You then free the pointer (seen #2) but later
<code>strdup</code> another 12 character string and it gets the <samp>`0x45008'</samp>
address from the free list (seen #3).
</p>
<p>So to find out who is allocating this particular 12 bytes the 3rd time,
try <kbd>dmalloc -a 0x45008:3</kbd>.  The library will stop the program the
third time it sees the <samp>`0x45008'</samp> address.  You then enter a
debugger and put a break point at <code>dmalloc_error</code>.  Run the program
and when the breakpoint is reached you can examine the stack frame to
determine who called <code>strdup</code> to allocate the pointer.
</p>
<p>To not bother with the <code>STORE_SEEN_COUNT</code> feature, you can also run
your program with the <code>never-reuse</code> token enabled.  This token will
cause the library to never reuse memory that has been freed.  Unique
addresses are always generated.  This should be used with caution since
it may cause your program to run out of memory.
</p>

<hr size="6">
<a name="Fence_002dPost-Overruns"></a>
<a name="SEC22"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC21" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC23" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC19" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.9.3 Diagnosing Fence-Post Overwritten Memory </h3>


<p>For a definition of fence-posts please see the &quot;Features&quot; section.
See section <a href="#SEC8">General Features of the Library</a>.
</p>
<p>To detect fence-post overruns, you need to enable the <samp>`check-fence'</samp>
token.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.  This pads your allocations with some extra
bytes at the front and the end and watches the space to make sure that
they don't get overwritten.  <em>NOTE:</em> The library cannot detect if
this space gets read, only written.
</p>
<p>If you have encountered a fence-post memory error, the logfile should be
able to tell you the offending address.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">free: failed UNDER picket-fence magic-number checking: 
pointer '0x1d008' from 'dmalloc_t.c:427'
Dump of proper fence-bottom bytes: '\e\253\300\300\e\253\300\300'
Dump of '0x1d008'-8: '\e\253\300\300WOW!\003\001pforger\023\001\123'
</pre></td></tr></table>
<p>The above sample shows that the pointer <samp>`0x1d008'</samp> has had its lower
fence-post area overwritten.  This means that the code wrote below the
bottom of the address or above the address right below this one.  In the
sample, the string that did it was <samp>`WOW!'</samp>.
</p>
<p>The library first shows you what the proper fence-post information
should look like, and then shows what the pointer's bad information was.
If it cannot print the character, it will display the value as
<samp>`\ddd'</samp> where ddd are three octal digits.
</p>
<p>By enabling the <code>check-heap</code> debugging token and assigning the
interval setting to a low number, you should be able to locate
approximately when this problem happened.  See section <a href="#SEC33">Description of the Debugging Tokens</a>,
See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>

<hr size="6">
<a name="Translate-Return-Addresses"></a>
<a name="SEC23"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC22" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC24" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC19" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.9.4 Translating Return Addresses into Code Locations </h3>


<p>The following gdb commands help you translate the return-addresses (ra=)
entries in the logfile into locations in your code.  I've provided a
<tt>`ra_info.pl'</tt> perl script in the <tt>`contrib/'</tt> directory with the
dmalloc sources which seems to work well with gdb.  But, if you need to
do it manually, here are the commands in gdb to use.
</p>
<a name="IDX305"></a>
<a name="IDX306"></a>

<table><tr><td>&nbsp;</td><td><pre class="example"># you may need to add the following commands to load in shared libraries
(gdb) sharedlibrary
(gdb) add-shared-symbol-files

(gdb) x 0x10234d
0x10234d &lt;_findbuf+132&gt;: 0x7fffceb7

(gdb) info line *(0x82cc)
Line 1092 of argv.c starts at pc 0x7540 and ends at 0x7550.
</pre></td></tr></table>
<p>In the above example, gdb was used to find that the two non-freed memory
pointers were allocated in <code>_findbuf()</code> and in file argv.c line
1092 respectively.  The <samp>`x address'</samp> (for examine) can always be
used on the return-addresses but the <samp>`info line *(address)'</samp> will
only work if that file was compiled using the <kbd>-g</kbd> option and has
not been stripped.  This limitation may not be true in later versions of
gdb.
</p>

<hr size="6">
<a name="Using-With-Threads"></a>
<a name="SEC24"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC23" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC25" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.10 Using the Library with a Thread Package </h2>


<p>Threads are special operating system facilities which allow your
programs to have multiple threads of execution (hence the name).  In
effect your program can be doing a number of things &quot;at the same
time&quot;.  This allows you to take full advantage of modern operating
system scheduling and multi-processor hardware.  If I've already lost
you or if any of the terminology below does not make sense, see manuals
about POSIX threads (pthreads) before going any further.  O'Reilly
publishes a pretty good pthreads manual for example.
</p>
<p>To use dmalloc with your threaded program, you will first need to make
sure that you are linking with <tt>`libdmallocth.a'</tt> which is the
threaded version of the library.  The support for threads in dmalloc
should be adequate for most if not all testing scenarios.  It provides
support for mutex locking itself to protect against race conditions that
result in multiple simultaneous execution.  One of the major problems is
that most thread libraries uses malloc themselves.  Since all of
dmalloc's initialization happens when a call to malloc is made, we may
be attempting to initialize or lock the mutex while the thread library
is booting up.  A very bad thing since thread libraries don't expect to
recurse.
</p>
<a name="IDX307"></a>

<p>The solution to this problem is to have the library not initialize or
lock its mutex variable until after a certain number of allocation calls
have been completed.  If the library does not wait before initializing
the locks, the thread library will probably core dump.  If it waits too
long then it can't protect itself from multiple execution and it will
abort or other bad things might happen.  You adjust the number of times
to wait at runtime with the <samp>`lock-on'</samp> option to the dmalloc program
(for example <kbd>dmalloc -o 20</kbd>).  See section <a href="#SEC29">Dmalloc Utility Program</a>.  Times
values between 5 and 30 are probably good although operating systems
will vary significantly.  You know its too low if your program
immediately core dumps and too high if the dmalloc library says its gone
recursive although with low values, you might get either problem.
</p>
<p>An additional complexity is when we are initializing the lock before
mutex locking around the library.  As mentioned, the initialization
itself may generate a malloc call causing the library to go recursive
and the pthread library to possibly core dump. With the THREAD_INIT_LOCK
setting defined in <tt>`settings.h'</tt>, you can tune how many times before
we start locking to try and initialize the mutex lock.  It defaults to 2
which seems to work for me.  If people need to have this runtime
configurable or would like to present an alternative default, please let
me know.
</p>
<p>So to use dmalloc with a threaded program, follow the following steps
carefully.
</p>
<ol>
<li> Follow the installation instructions on how to configure,
make, and install the library but make sure to add the
<kbd>--enable-threads</kbd> argument to configure.  See section <a href="#SEC3">How to Install the Library</a>.

</li><li> Typing <kbd>make</kbd> should be enough to build the threaded versions
of the libraries including <tt>`libdmallocth.a'</tt>.

</li><li> Link the dmalloc threaded library into your program.  The dmalloc
library should probably be placed at or near the end of the library
list.

</li><li> Enable the debugging options that you need by typing
<kbd>dmalloc -l logfile -i 100 low</kbd> (for example).  <kbd>dmalloc
--usage</kbd> will provide verbose usage info for the dmalloc program.
See section <a href="#SEC29">Dmalloc Utility Program</a>.

</li><li> Enable the &quot;lock-on&quot; option (for example <kbd>dmalloc -o 20</kbd>).
As explained above, you may have to try different values before getting
it right.  Values between 5 and 30 are probably good.

</li><li> If you get a dmalloc error #13 <samp>`thread locking has not
been configured'</samp> then you have not compiled you program with the
threaded version of dmalloc or there was a problem building it.

</li><li> If everything works, you should be able to run your program, have
it not immediately crash, and the dmalloc library should not complain
about recursion.

</li></ol>

<p>If you have any specific questions or would like addition information
posted in this section, please let me know.  Experienced thread
programmers only please.
</p>

<hr size="6">
<a name="Using-With-Cygwin"></a>
<a name="SEC25"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC24" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.11 Using the library with Cygwin environment. </h2>


<p>The Cygwin environment is a Linux-like environment for Windows.  It
provides Linux look and feel as well as a programming environment.  See
URL <a href="http://www.cygwin.com/">http://www.cygwin.com/</a> for more details.
</p>
<a name="IDX308"></a>
<a name="IDX309"></a>
<a name="IDX310"></a>

<p>Cygwin uses the <code>GetEnvironmentVariableA</code> function to read in
environmental variables instead of <code>getenv</code>.  This functions are
used to get the value of the <samp>`DMALLOC_OPTIONS'</samp> variable which
sets the debugging options.  See section <a href="#SEC32">Environment Variable Name and Features</a>.
</p>
<a name="IDX311"></a>
<a name="IDX312"></a>

<p>As of right now, dmalloc is not detecting the
<code>GetEnvironmentVariableA</code> function correctly so you may need to
tune the <tt>`conf.h'</tt> file to get it to work.  See the sections on
<code>HAVE_GETENVIRONMENTVARIABLEA</code> and <code>GETENV_SAVE</code> settings.
Feedback is welcome here.
</p>
<p>If you still have problems reading in the environmental variables, you
can work around this issue.  You can add some code into the
<code>main</code> function in your program to initialize the dmalloc flags
yourself.  Here is a code sample:
</p>
<a name="IDX313"></a>

<table><tr><td>&nbsp;</td><td><pre class="example">main(int argc, char **argv)
{
#ifdef DMALLOC
  /*
   * Get environ variable DMALLOC_OPTIONS and pass the settings string
   * on to dmalloc_debug_setup to setup the dmalloc debugging flags.
   */
  dmalloc_debug_setup(getenv(&quot;DMALLOC_OPTIONS&quot;));
#endif

  /* rest of code in main starts here */
  &hellip;
}
</pre></td></tr></table>
<p>The <code>#ifdef</code> is just a good idea.  I means that when debugging with
dmalloc you need to compile your code with <code>-DDMALLOC</code>.  When you
are done debugging you can remove the flag and the call to
<code>dmalloc_debug_setup</code> will be removed.
</p>
<p>Please let me know if there is a better way to do this.
</p>

<hr size="6">
<a name="Debugging-A-Server"></a>
<a name="SEC26"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC25" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC27" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.12 Debugging Memory in a Server or Cgi-Bin Process </h2>


<p>There are some specified challenges when trying to debug allocations
in processes which do not startup, run, and then shutdown.  Server
processes (often called daemons) are those that are started (often at
system boot time) and run perpetually.  Other processes which are
difficult to debug are CGI programs which are spawned by web servers
or when you want to start debugging inside of a child process.
</p>
<ol>
<li> Build your server or cgi-bin program with the dmalloc library
like any other program.  See section <a href="#SEC4">Getting Started with the Library</a>.

</li><li> Add code into your program to enable the library flags to
perform the memory checks that you require.  Since these programs
often do not run from the command line, you cannot use the dmalloc
utility program and modify the process environment.  See section <a href="#SEC29">Dmalloc Utility Program</a>.  The library provides a couple of functions to set the
debugging flags when a program is running.

<a name="IDX314"></a>

</li><li> To set the memory debugging flags, use the
<code>dmalloc_debug_setup</code> function which takes a string in the same
format of the <samp>`DMALLOC_OPTIONS'</samp> environmental variable.
See section <a href="#SEC32">Environment Variable Name and Features</a>.  Use the dmalloc utility with the
<code>-n</code> no-changes argument to see the appropriate settings for the
<samp>`DMALLOC_OPTIONS'</samp> environmental variable.

<table><tr><td>&nbsp;</td><td><pre class="example">&gt; dmalloc -n -l logfile high
Outputed:
DMALLOC_OPTIONS=debug=0x4f4ed03,log=logfile
export DMALLOC_OPTIONS
</pre></td></tr></table>
<p>So if you want to turn on <kbd>high</kbd> debugging and log to the file
<tt>`logfile'</tt> then you would copy the above <samp>`DMALLOC_OPTIONS'</samp>
value into a call to <code>dmalloc_debug_setup</code>.  Notice that I have
surrounded the dmalloc code with an <code>#ifdef DMALLOC</code> so you'll
have to compile using the <code>-DDMALLOC</code> flag.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">main()
{
#ifdef DMALLOC
  /* set the 'high' flags */
  dmalloc_debug_setup(&quot;debug=0x4f47d03,log=logfile&quot;);
#endif
  &hellip;
}
</pre></td></tr></table>
<p><em>Please note</em> that the <code>dmalloc_debug_setup</code> function does
not know about <code>high</code>, <code>low</code>, or other debug tokens but
needs the actual flag values.
</p>
</li><li> For earlier versions of the library (before 5.0.0) without 
<code>dmalloc_debug_setup</code>, the <code>dmalloc_debug</code> function is
available to set the flags directly, but it cannot adjust the logfile
name and the other environment settings.  You can use the dmalloc
utility program to see what the numerical equivalent of the <kbd>high</kbd>
token.

<table><tr><td>&nbsp;</td><td><pre class="example">&gt; dmalloc -n high
Outputed:
DMALLOC_OPTIONS=debug=0x4f4ed03
export DMALLOC_OPTIONS
</pre></td></tr></table>
<p>You can then take the <code>0x4f4ed03</code> hexadecimal number and call
<code>dmalloc_debug</code> with that number.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">main()
{
#ifdef DMALLOC
  /* set the 'high' flags */
  dmalloc_debug(0x4f4ed03);
#endif
  &hellip;
}
</pre></td></tr></table>
</li><li> Even with the settings enabled, you may have problems getting
the logfile to be written if your program is running as <samp>`nobody'</samp>
or another user without permissions for security reasons.  This is
especially true for cgi-bin programs.  In this case you should specify
a full path to your malloc logfile in a world writable directory
(ex. <code>dmalloc_debug_setup(&quot;debug=0x4f47d03,log=/var/tmp/malloc&quot;);</code>).
Watch for programs which change into other directories and which may
cause logfiles specified as relative or local paths to be dropped in
other locations.  You may always want to use a full path logfile.

</li><li> Once you have your settings enabled and your log is being
generated, you may now want to check out how your process is doing in
terms of unfreed memory.  Since it is not shutting down, the automatic
unfreed log entries are not being dropped to the logfile.  By using
the <code>dmalloc_mark</code> and <code>dmalloc_log_changed</code> functions, you
can set a mark point at a certain place inside of your program, and
then later see whether there are any unfreed pointers since the mark.

<table><tr><td>&nbsp;</td><td><pre class="example">main()
{
#ifdef DMALLOC
  /* set the 'high' flags */
  dmalloc_debug_setup(&quot;debug=0x4f47d03,log=logfile&quot;);
#endif

  while (1) {
    /* accept a connection from a client */
    accept_connection();

    while (1) {
#ifdef DMALLOC
      unsigned long mark;
      /* get the current dmalloc position */
      mark = dmalloc_mark() ;
#endif
      /* process the connection */
      if (process_connection() != PROCESS_OK) {
        break;
      }
#ifdef DMALLOC
      /*
       * log unfreed pointers that have been added to
       * the heap since mark
       */
      dmalloc_log_changed(mark,
                          1 /* log unfreed pointers */,
                          0 /* do not log freed pointers */,
                          1 /* log each pnt otherwise summary */);
#endif
    }
    /* close the connection with the client */
    close_connection();
  }
  &hellip;
}
</pre></td></tr></table>
<p>Usually you would set the mark after the initializations and before
each transaction is processed.  Then for each transaction you can use
<code>dmalloc_log_changed</code> to show the unfreed memory.
See section <a href="#SEC15">Additional Non-standard Routines</a>.
</p>
</li><li> You can also use the <code>dmalloc_log_stats</code> function to dump
general information about the heap.  Also, remember that you can use
the <code>dmalloc_message</code> and <code>dmalloc_vmessage</code> routines to
annotate the dmalloc logfile with details to help you debug memory
problems.  See section <a href="#SEC15">Additional Non-standard Routines</a>.

</li></ol>


<hr size="6">
<a name="Logfile-Details"></a>
<a name="SEC27"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC26" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC28" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.13 Explanation of the Logfile Output </h2>


<p>Most of time you will be using the logfile output from library as the
sole information source for diagnosing problems in and getting
statistics for your program.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">1098918225: 3: Dmalloc version 'Version 5.5.2'
1098918225: 3: flags = 0x4f4e503, logfile '/tmp/dmalloc.log'
1098918225: 3: interval = 500, addr = 0, seen # = 0, limit = 0
1098918225: 3: starting time = 1098918225
1098918225: 3: process pid = 32406
1098918226: 4: WARNING: tried to free(0) from foo.c:708'
1098918228: 20: *** free: at 'unknown' pnt '0xed310080|s2': \
            size 12, alloced at 'bar.c:102'
1098918230: 50: ERROR: heap_check: free space was overwritten (err 67)
1098918230: 50: error details: checking free pointer
1098918230: 50: pointer '0x291c5' from 'unknown' prev access 'foo.c:787'
</pre></td></tr></table>
<p>Here is a short example of some logfile information.  Each of the
lines are prefixed by the time (in epoch seconds since 1/1/1970) and
the iteration or call count which is the number of times the library
has been called from malloc, free, verify, etc..  In the above
example, the first 5 log entries where written at epoch 1098918225 or
<samp>`Wed Oct 27 19:03:45 2004 EST'</samp> and they were generated by the 3rd
call to the library.  See the <tt>`settings.dist'</tt> file entries to
tune what elements appear on each line: LOG_TIME_NUMBER,
LOG_ITERATION, LOG_PID, etc..  You can convert the epoch seconds to a
date from the command line with the following perl code: <code>perl -e
'print localtime($ARGV[0]).&quot;\n&quot;;' epoch-seconds-number</code>
</p>
<a name="IDX315"></a>
<p>The first 5 lines of the sample logfile contain header information for
all logfiles.  They show the version number and URL for the library as
well as all of the settings that the library is currently using.
These settings are tuned using the dmalloc utility program.
See section <a href="#SEC29">Dmalloc Utility Program</a>.  The 5th line of is the process-id that
generated the logfile.
</p>
<a name="IDX316"></a>
<p>The 6th line in the above example is what causes the logfile to be
opened and the header to be written.  It is a warning that tells you
that you tried to free a 0L pointer at a certain location.  You can
disable these warnings by setting <samp>`ALLOW_FREE_NULL_MESSAGE'</samp> to 0
in <tt>`settings.dist'</tt>.
</p>
<a name="IDX317"></a>
<p>Line 7 is an example of a transaction log that you get when you enable
the <code>log-trans</code> debug token.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.  This line
shows that a call to free was made from an unknown location.  It is
unknown because the file in question did not include <tt>`dmalloc.h'</tt>
to get file/line-number information.  The call to free was freeing the
pointer address <code>0xed310080</code> which we have &quot;seen&quot; 2 times (s2).
We saw the pointer when it was allocated and then we are seeing it
again when it was freed.  Because the library is reusing pointers
(reclaiming freed memory) the seen count helps to track how many times
a pointer was used.  The last part of the line shows that the pointer
to be freed was allocated by <tt>`bar.c'</tt> line 102.
</p>
<p>Lines 8-10 is the next problem that the library caught and this one is
an error.  It happened 5 seconds from the start of the log
(1098918230) and at the 50th call into the library.  It shows that an
allocation that had been freed then was overwritten.  This may imply
that someone tried to use memory after it was freed or that there was
a loose pointer reference.  The last two lines give more details about
when the error was discovered, the address of the offending pointer,
and when the pointer was previous accessed, in this case freed.  To
discover where this problem is happening, you can use a debugger.
See section <a href="#SEC19">Using Dmalloc With a Debugger</a>.
</p>

<hr size="6">
<a name="Other-Hints"></a>
<a name="SEC28"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC27" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.14 Various Other Hints That May Help </h2>


<p>One of the problems that is often seen is that a program crashes in
the <code>libc</code> memory code and you suspect a heap memory problem but
both dmalloc and maybe valgrind don't show any problems.  One of the
big problems with debugging is that it is very difficult to do it
without effecting how the program is run.  Sometimes errors are due to
subtle race conditions that are only seen when the program is running
at full speed - not slowed down by debugging code.
</p>
<p>This is especially true with threaded code which is often heavily
affected when used with dmalloc and valgrind.  Older versions of
valgrid (maybe current) forced all threads into a single virtual
system by design, which often masks reentrance bugs.
</p>
<p>One way to work through these issues is to run with the library with
very few debugging flags enabled.  Many memory problems are fence-post
areas so start with dmalloc checking just the fence post and error
logging enabled:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">dmalloc -d 0 -l dmalloc.log -p log-stats -p log-non-free -p check-fence -p check-funcs 
</pre></td></tr></table>
<p>This enabled a small number of checks and should cause your program to
run at close to full speed.  The library has never been optimized for
speed so some performance penalties will be felt.
</p>

<hr size="6">
<a name="Dmalloc-Program"></a>
<a name="SEC29"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC28" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC30" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 4. Dmalloc Utility Program </h1>


<p>The dmalloc program is designed to assist in the setting of the
environment variable <samp>`DMALLOC_OPTIONS'</samp>.  See section <a href="#SEC32">Environment Variable Name and Features</a>.  It is designed to print the shell commands necessary to make
the appropriate changes to the environment.  Unfortunately, it cannot
make the changes on its own so the output from dmalloc should be sent
through the <code>eval</code> shell command which will do the commands.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC30">4.1 Using a Shell Alias with the Utility</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                 Using a shell alias with the utility.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">               How to use the dmalloc program.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">        Environment variable name and features.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                Description of the debugging tokens.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                     Format of the runtime configuration file.
</td></tr>
</table>


<hr size="6">
<a name="Shell-Alias"></a>
<a name="SEC30"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC29" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC29" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.1 Using a Shell Alias with the Utility </h2>

<p>The dmalloc program is designed to assist in the setting of the
environment variable <samp>`DMALLOC_OPTIONS'</samp>.  See section <a href="#SEC32">Environment Variable Name and Features</a>.  It is designed to print the shell commands necessary to make
the appropriate changes to the environment.  Unfortunately, it cannot
make the changes on its own so the output from dmalloc should be sent
through the <code>eval</code> shell command which will do the commands.
</p>
<a name="IDX318"></a>
<a name="IDX319"></a>
<a name="IDX320"></a>
<a name="IDX321"></a>

<p>With shells that have aliasing or macro capabilities: csh, bash, ksh,
tcsh, zsh, etc., setting up an alias to dmalloc to do the eval call is
recommended.  Bash, ksh, and zsh users should add the following to their
<tt>`.bashrc'</tt>, <tt>`.profile'</tt>, or <tt>`.zshrc'</tt> file respectively
(notice the <kbd>-b</kbd> option for bourne shell output):
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">function dmalloc { eval `command dmalloc -b $*`; }
</pre></td></tr></table>
<p>If your shell does not support the <code>command</code> function then try:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">function dmalloc { eval `\dmalloc -b $*`; }
</pre></td></tr></table><p>or
</p><table><tr><td>&nbsp;</td><td><pre class="example">function dmalloc { eval `/usr/local/bin/dmalloc -b $*`; }
</pre></td></tr></table>
<a name="IDX322"></a>
<a name="IDX323"></a>

<p>If you are <em>still</em> using csh or tcsh, you should add the following
to your <tt>`.cshrc'</tt> file (notice the <kbd>-C</kbd> option for c-shell
output):
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">alias dmalloc 'eval `\dmalloc -C \!*`'
</pre></td></tr></table>
<p>This allows the user to execute the dmalloc command as <samp>`dmalloc
arguments'</samp>.
</p>
<p>Users of versions of the Bourne shell (usually known as /bin/sh) that
don't have command functions will need to send the output to a temporary
file and the read it back in with the &quot;.&quot; command:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">$  dmalloc -b arguments &hellip; &gt; /tmp/out
$  . /tmp/out
</pre></td></tr></table>
<p>By the way, if you are looking for a shell, I heartily recommend trying
out zsh.  It is a bourne shell written from scratch with much the same
features as tcsh without the csh crap.
</p>
<p><em>NOTE</em>: After you add the alias to the file you need to log out and
log back in to have it take effect, or you can execute the above
appropriate command on the command line.  If you enter <kbd>dmalloc
runtime</kbd> and see any output with DMALLOC_OPTIONS in it then the alias
did not work.
</p>

<hr size="6">
<a name="Utility-Usage"></a>
<a name="SEC31"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC30" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC32" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC29" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.2 How to Use the Dmalloc Program </h2>


<p>The most basic usage for the program is <samp>`dmalloc [-bC] tag'</samp>.  The
<samp>`-b'</samp> or <samp>`-C'</samp> (either but not both flags used at a time) are
for generating Bourne or C shell type commands respectively.  dmalloc
will try and use the <code>SHELL</code> environment variable to determine
whether bourne or C shell commands should be generated but you may want
to explicitly specify the correct flag.
</p>
<p>The <samp>`tag'</samp> argument to dmalloc should match a line from the user's
runtime configuration file or should be one of the built-in tags.
See section <a href="#SEC34">Format of the Runtime Configuration File</a>.  If no tag is specified and no other option-commands
used, dmalloc will display the current settings of the environment
variable.  It is useful to specify one of the verbose options when doing
this.
</p>
<p>To find out the usage for the debug malloc program try <samp>`dmalloc
--usage-long'</samp>.  The standardized usage message that will be displayed is
one of the many features of the argv library included with this package.
</p>
<p>It is available on the web at URL <a href="http://256.com/sources/argv/">http://256.com/sources/argv/</a>.
See the documentation there for more information.
</p>
<p>Here is a detailed list of the flags that can passed to dmalloc:
</p>
<dl compact="compact">
<dt> <code>-a address</code></dt>
<dd><p>Set the <samp>`addr'</samp> part of the <samp>`DMALLOC_OPTIONS'</samp> variable to
address (or alternatively address:number).
</p>
</dd>
<dt> <code>-b</code></dt>
<dd><p>Output Bourne shell type commands.  Usually handled automagically.
</p>
</dd>
<dt> <code>-C</code></dt>
<dd><p>Output C shell type commands.  Usually handled automagically.
</p>
</dd>
<dt> <code>-c</code></dt>
<dd><p>Clear/unset all of the settings not specified with other arguments.  You
can do this automatically when you set to a new tag with the <kbd>-r</kbd>
option.
</p>
<p><em>NOTE</em>: clear will never unset the <samp>`debug'</samp> setting.  Use
<kbd>-d 0</kbd> or a tag to <samp>`none'</samp> to achieve this.
</p>
</dd>
<dt> <code>-d bitmask</code></dt>
<dd><p>Set the <samp>`debug'</samp> part of the <samp>`DMALLOC_OPTIONS'</samp> env variable to
the bitmask value which should be in hex.  This is overridden (and
unnecessary) if a tag is specified.
</p>
</dd>
<dt> <code>-D</code></dt>
<dd><p>List all of the debug-tokens.  Useful for finding a token to be used
with the <kbd>-p</kbd> or <kbd>-m</kbd> options.  Use with <kbd>-v</kbd> or <kbd>-V</kbd>
verbose options.
</p>
</dd>
<dt> <code>-e errno</code></dt>
<dd><p>Print the dmalloc error string that corresponds to the error number
errno.
</p>
</dd>
<dt> <code>-f filename</code></dt>
<dd><p>Use this configuration file instead of the RC file
<tt>`$HOME/.dmallocrc'</tt>.
</p>
</dd>
<dt> <code>-g</code></dt>
<dd><p>Output gdb type commands for using inside of the gdb debugger.
</p>
</dd>
<dt> <code>-h (or --help)</code></dt>
<dd><p>Output a help message for the utility.
</p>
</dd>
<dt> <code>-i number</code></dt>
<dd><a name="IDX324"></a>
<p>Set the checking interval to number.  If the <code>check-heap</code> token is
enabled, this causes the library to only check the heap every Nth time
which can <em>significantly</em> increase the running speed of your
program.  If a problem is found, however, this limits your ability to
determine when the problem occurred.  Try values of 50 or 100 initially.
</p>
</dd>
<dt> <code>-k</code></dt>
<dd><p>Do not reset all of the settings when a tag is specified.  This
specifically overrides the <kbd>-r</kbd> option and is provided here to
override <kbd>-r</kbd> if it has been added to the dmalloc alias.
</p>
</dd>
<dt> <code>-l filename</code></dt>
<dd><p>Write the debugging output and other log-file information to the
filename.  Filename can include some of the following patterns which get
expanded into strings:
</p>
<dl compact="compact">
<dd>
<a name="IDX325"></a>
<a name="IDX326"></a>
<a name="IDX327"></a>
<a name="IDX328"></a>
</dd>
<dt> <code>%h</code></dt>
<dd><p>Gets expanded into the hostname if the <code>gethostname()</code> function is
available.
</p>
<a name="IDX329"></a>
<a name="IDX330"></a>
</dd>
<dt> <code>%i</code></dt>
<dd><p>Gets expanded into the thread-id if the library has been configure to be
used with threads.  See section <a href="#SEC24">Using the Library with a Thread Package</a>.  See the end of the
<tt>`settings.dist'</tt> file for settings which return the thread-id and
convert it into a string.
</p>
<a name="IDX331"></a>
<a name="IDX332"></a>
<a name="IDX333"></a>
<a name="IDX334"></a>
</dd>
<dt> <code>%p</code></dt>
<dd><p>Gets expanded into the process-id if the <code>getpid()</code> function is
available.
</p>
<a name="IDX335"></a>
<a name="IDX336"></a>
<a name="IDX337"></a>
</dd>
<dt> <code>%t</code></dt>
<dd><p>Gets expanded into the time value in seconds if the <code>time()</code>
function is available.
</p>
<a name="IDX338"></a>
<a name="IDX339"></a>
<a name="IDX340"></a>
<a name="IDX341"></a>
</dd>
<dt> <code>%u</code></dt>
<dd><p>Gets expanded into the user-id number if the <code>getuid()</code> function is
available.
</p>
</dd>
</dl>

<p>Some examples:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example"># logfile produced with pid extension:
#   logfile.8412  or  logfile.31451
dmalloc -l logfile.%p

# hostname and time extensions:
#   dmalloc-box1.foo.com-1055213240
dmalloc -l dmalloc-%h-%t

# if threads enabled, have thread-id extension:  log.thread32
dmalloc -l log.thread%i
</pre></td></tr></table>
</dd>
<dt> <code>-L</code></dt>
<dd><p>Write the debug-value into the environment not in hex but by
individual debug-tokens in long form.
</p>
</dd>
<dt> <code>-m token(s)</code></dt>
<dd><p>Remove (minus) the debug capabilities of token(s) from the current debug
setting or from the selected tag (or <kbd>-d</kbd> value).  Multiple <kbd>-m</kbd>
options can be specified.
</p>
<a name="IDX342"></a>
<a name="IDX343"></a>
</dd>
<dt> <code>-M limit</code></dt>
<dd><p>Set the memory allocation limit which will abort the program if the
total memory allocations exceed this number of bytes.  The limit can
be a number with a k, m, or g at the end to indicate kilobyte,
megabyte, and gigabyte respectively.  Ex: 100k, 200m, 1g.  If the
limit is exceeded, this will generate an <code>ERROR_OVER_LIMIT</code>
error.  See section <a href="#SEC16">Description of the Internal Error Codes</a>.
</p>
</dd>
<dt> <code>-n</code></dt>
<dd><p>Without changing the environment, output the commands resulting from the
supplied options.
</p>
<a name="IDX344"></a>
</dd>
<dt> <code>-o times</code></dt>
<dd><p>Set the &quot;lock-on&quot; period which dictates to the threaded version of
the library to not initialize or lock the mutex lock around the library
until after a certain number of allocation calls have been made.  Some
number between 2 and 30 is probably good.  See the &quot;Using With
Threads&quot; section for more information about the operation of the
library with threads.  See section <a href="#SEC24">Using the Library with a Thread Package</a>.
</p>
</dd>
<dt> <code>-p token(s)</code></dt>
<dd><p>Add (plus) the debug capabilities of token(s) to the current debug
setting or to the selected tag (or <kbd>-d</kbd> value).  Multiple <kbd>-p</kbd>
options can be specified.
</p>
</dd>
<dt> <code>-r</code></dt>
<dd><p>Remove (unset) all settings when using a tag.  This is useful when you
are returning to a standard development tag and want the logfile,
address, and interval settings to be cleared automatically.  If you want
this behavior by default, this can be put into the dmalloc alias.
</p>
</dd>
<dt> <code>-R</code></dt>
<dd><p>Output rc shell type commands.  This is not for the runtime
configuration file but for the rc shell program.
</p>
<a name="IDX345"></a>
<a name="IDX346"></a>
</dd>
<dt> <code>-s file:line</code></dt>
<dd><p>Set the <samp>`start'</samp> part of the <samp>`DMALLOC_OPTIONS'</samp> env variable to
a file-name and line-number location in the source where the library
should begin more extensive heap checking.  The file and line numbers
for heap transactions must be working for this option to be obeyed.
This is used if you are trying to locate a problem and you want the
extensive checking to not happen initially because it's too slow.
</p>
<a name="IDX347"></a>
<a name="IDX348"></a>
<a name="IDX349"></a>
<a name="IDX350"></a>
<a name="IDX351"></a>
<a name="IDX352"></a>
<a name="IDX353"></a>
</dd>
<dt> <code>-S number</code></dt>
<dd><p>Set the <samp>`start'</samp> part of the <samp>`DMALLOC_OPTIONS'</samp> env variable to
an dmalloc mark number.  The library will begin more extensive heap
checking after this number of memory transactions.  If you
<code>LOG_ITERATION</code> enabled in your <tt>`settings.h'</tt> file then
the entries in the log file will be prepended with the number of memory
transactions that the library has handled so far.  This number can be
used to delay the start of the fine grained heap checking which can be
very slow.
</p>
<a name="IDX354"></a>
<a name="IDX355"></a>
</dd>
<dt> <code>--start-size size</code></dt>
<dd><p>Set the <samp>`start'</samp> part of the <samp>`DMALLOC_OPTIONS'</samp> env variable to
a number of bytes.  The library will begin more extensive heap checking
after this amount of memory has been allocated by the library.  This
allows you to start the slow and detailed checking of the library later
in the program execution.  You can use patterns like 250m, 1g, or 102k
to mean 250 megabytes, 1 gigabyte, and 102 kilobytes respectively.
</p>
</dd>
<dt> <code>-t</code></dt>
<dd><p>List all of the tags in the rc-file.  Use with <kbd>-v</kbd> or <kbd>-V</kbd>
verbose options.
</p>
</dd>
<dt> <code>-u (or --usage)</code></dt>
<dd><p>Output the usage information for the utility.
</p>
</dd>
<dt> <code>-v</code></dt>
<dd><p>Give verbose output.  Especially useful when dumping current settings or
listing all of the tags.
</p>
</dd>
<dt> <code>-V</code></dt>
<dd><p>Give very verbose output for outputting even more details about
settings.
</p>
<a name="IDX356"></a>
<a name="IDX357"></a>
<a name="IDX358"></a>
</dd>
<dt> <code>--version</code></dt>
<dd><p>Output the version string for the utility.  <em>Please note</em> that
the version of the library that is installed or has been linked into
your application may be different from the utility version.
</p>
</dd>
</dl>

<p>If no arguments are specified, dmalloc dumps out the current settings
that you have for the environment variable.  For example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">Debug-Flags  '0x40005c7' (runtime)
Address      0x1f008, count = 3
Interval     100
Logpath      'malloc'
Start-File   not-set
</pre></td></tr></table>
<p>With a -v option and no arguments, dmalloc dumps out the current
settings in a verbose manner.  For example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">Debug-Flags  '0x40005c7' (runtime)
   log-stats, log-non-free, log-bad-space, check-fence, catch-null
Address      0x1f008, count = 10
Interval     100
Logpath      'malloc'
Start-File   not-set
</pre></td></tr></table>
<p>Here are some examples of dmalloc usage:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example"># start tough debugging, check the heap every 100 times,
# send the log information to file 'logfile'
dmalloc high -i 100 -l logfile

# find out what error code 20 is (from the logfile)
dmalloc -e 20

# cause the library to halt itself when it sees the address 0x34238
# for the 6th time.
dmalloc -a 0x34238:6

# send the log information to file 'logfile' with the time in seconds
# as an extension.
dmalloc -l logfile.%t

# return to the normal 'runtime' settings and clear out all
# other settings
dmalloc -c runtime

# enable basic 'low' settings plus (-p) the logging of
# transactions (log-trans) to file 'logfile'
dmalloc low -p log-trans -l logfile

# print out the current settings with Very-verbose output
dmalloc -V

# list the available debug malloc tokens with Very-verbose output
dmalloc -DV

# list the available tags from the rc file with verbose output
dmalloc -tv
</pre></td></tr></table>

<hr size="6">
<a name="Environment-Variable"></a>
<a name="SEC32"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC31" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC33" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC29" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.3 Environment Variable Name and Features </h2>


<p>An <em>environment variable</em> is a variable that is part of the user's
working environment and is shared by all the programs.  The
<samp>`DMALLOC_OPTIONS'</samp> variable is used by the dmalloc library to
enable or disable the memory debugging features, at runtime.
<em>NOTE:</em> you can also use the <code>dmalloc_debug_setup</code> function
to set the option string.  It can be set either by hand or with the
help of the dmalloc program.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
<a name="IDX359"></a>

<a name="IDX360"></a>
<a name="IDX361"></a>
<a name="IDX362"></a>
<a name="IDX363"></a>
<a name="IDX364"></a>
<p>To set it by hand, Bourne shell (sh, bash, ksh, or zsh) users should use:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">DMALLOC_OPTIONS=value
export DMALLOC_OPTIONS
</pre></td></tr></table>
<a name="IDX365"></a>
<a name="IDX366"></a>
<a name="IDX367"></a>
<p>C shell (csh or tcsh) users need to invoke:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">setenv DMALLOC_OPTIONS value
</pre></td></tr></table>
<p>The value in the above examples is a comma separated list of tokens each
having a corresponding value.  The tokens are described below:
</p>
<dl compact="compact">
<dt> <code>debug</code></dt>
<dd><a name="IDX368"></a>
<p>This should be set to a value in hexadecimal which corresponds to the
functionality token values added together.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.  For
instance, if the user wanted to enable the logging of memory
transactions (value <samp>`0x008'</samp>) and wanted to check fence-post memory
(value <samp>`0x400'</samp>) then <samp>`debug'</samp> should be set to <samp>`0x408'</samp>
(<samp>`0x008'</samp> + <samp>`0x400'</samp>).
</p>
<p><em>NOTE</em>: You don't have to worry about remembering all the hex
values of the tokens because the dmalloc program automates the setting
of this variable especially.
</p>
<a name="IDX369"></a>

<p><em>NOTE</em>: You can also specify the debug tokens directly, separated
by commas.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.  If <samp>`debug'</samp> and the tokens are
both used, the token values will be added to the debug value.
</p>
</dd>
<dt> <code>lockon</code></dt>
<dd><a name="IDX370"></a>
<p>Set this to a number which is the &quot;lock-on&quot; period.  This dictates
to the threaded version of the library to not initialize or lock the
mutex lock around the library until after a certain number of allocation
calls have been made.  See the &quot;Using With Threads&quot; section for more
information about the operation of the library with threads.
See section <a href="#SEC24">Using the Library with a Thread Package</a>.
</p>
</dd>
<dt> <code>log</code></dt>
<dd><a name="IDX371"></a>
<a name="IDX372"></a>
<p>Set this to a filename so that if <samp>`debug'</samp> has logging enabled, the
library can log transactions, administration information, and/or errors
to the file so memory problems and usage can be tracked.
</p>
<p>To get different logfiles for different processes, you can assign
<samp>`log'</samp> to a string with <code>%d</code> in it (for instance
<samp>`logfile.%d'</samp>).  This will be replaced with the pid of the running
process (for instance <samp>`logfile.2451'</samp>).
</p>
<p><em>WARNING</em>: it is easy to core dump any program with dmalloc, if
you send in a format with arguments other than the one <code>%d</code>.
</p>
</dd>
<dt> <code>addr</code></dt>
<dd><a name="IDX373"></a>
<a name="IDX374"></a>
<a name="IDX375"></a>
<p>When this is set to a hex address (taken from the dmalloc log-file for
instance) dmalloc will abort when it finds itself either allocating or
freeing that address.
</p>
<p>The address can also have an <samp>`:number'</samp> argument.  For instance, if
it was set it to <samp>`0x3e45:10'</samp>, the library will kill itself the 10th
time it sees address <samp>`0x3e45'</samp>.  By setting the number argument to
0, the program will never stop when it sees the address.  This is useful
for logging all activity on the address and makes it easier to track
down specific addresses not being freed.
</p>
<p>This works well in conjunction with the <code>STORE_SEEN_COUNT</code> option.
See section <a href="#SEC21">Tracking Down Non-Freed Memory</a>.
</p>
<p><em>NOTE</em>: dmalloc will also log all activity on this address along
with a count.
</p>
</dd>
<dt> <code>inter</code></dt>
<dd><a name="IDX376"></a>
<p>By setting this to a number X, dmalloc will only check the heap every X
times.  This means a number of debugging features can be enabled while
still running the program within a finite amount of time.
</p>
<p>A setting of <samp>`100'</samp> works well with reasonably memory intensive
programs.  This of course means that the library will not catch errors
exactly when they happen but possibly 100 library calls later.
</p>
</dd>
<dt> <code>start</code></dt>
<dd><a name="IDX377"></a>
<p>Set this to a number X and dmalloc will begin checking the heap after X
times.  This means the intensive debugging can be started after a
certain point in a program.
</p>
<p><samp>`start'</samp> also has the format <samp>`file:line'</samp>.  For instance, if it
is set to <samp>`dmalloc_t.c:126'</samp> dmalloc will start checking the heap
after it sees a dmalloc call from the <tt>`dmalloc_t.c'</tt> file, line
number 126.  If you use <samp>`dmalloc_t.c:0'</samp>, with a 0 line number, then
dmalloc will start checking the heap after it sees a call from anywhere
in the <tt>`dmalloc_t.c'</tt> file.
</p>
<p>This allows the intensive debugging to be started after a certain
routine or file has been reached in the program.
</p></dd>
</dl>

<p>Some examples are:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example"># turn on transaction and stats logging and set
# 'logfile' as the log-file
setenv DMALLOC_OPTIONS log-trans,log-stats,log=logfile

# enable debug flags 0x1f as well as heap-checking and
# set the interval to be 100
setenv DMALLOC_OPTIONS debug=0x1f,check-heap,inter=100

# enable 'logfile' as the log-file, watch for
# address '0x1234', and start checking when we see
# file.c line 123
setenv DMALLOC_OPTIONS log=logfile,addr=0x1234,start=file.c:123
</pre></td></tr></table>

<hr size="6">
<a name="Debug-Tokens"></a>
<a name="SEC33"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC32" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC34" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC29" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.4 Description of the Debugging Tokens </h2>


<p>The below tokens and their corresponding descriptions are for the
setting of the debug library setting in the environment variable.
See section <a href="#SEC32">Environment Variable Name and Features</a>.  They should be specified in the user's
<tt>`.dmallocrc'</tt> file.  See section <a href="#SEC34">Format of the Runtime Configuration File</a>.
</p>
<p>Each token, when specified, enables a specific debugging feature.  For
instance, if you have the <code>log-stats</code> token enabled, the library
will log general statistics to the logfile.
</p>
<p>To get this information on the fly, use <kbd>dmalloc -DV</kbd>.  This will
print out the Debug tokens in Very-verbose mode.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
<dl compact="compact">
<dd><a name="IDX378"></a>
</dd>
<dt> <code>none</code></dt>
<dd><p>No debugging functionality
</p>
<a name="IDX379"></a>
</dd>
<dt> <code>log-stats</code></dt>
<dd><p>Log general statistics when dmalloc_shutdown or dmalloc_log_stats is
called.
</p>
<a name="IDX380"></a>
</dd>
<dt> <code>log-non-free</code></dt>
<dd><p>Log non-freed memory pointers when dmalloc_shutdown or dmalloc_log_unfreed
is called.
</p>
<a name="IDX381"></a>
</dd>
<dt> <code>log-known</code></dt>
<dd><p>Log only known memory pointers that have not been freed.  Pointers which
do not have file/line or return-address information will not be logged.
</p>
<a name="IDX382"></a>
</dd>
<dt> <code>log-trans</code></dt>
<dd><p>Log general memory transactions (quite verbose).
</p>
<a name="IDX383"></a>
</dd>
<dt> <code>log-admin</code></dt>
<dd><p>Log administrative information (quite verbose).
</p>
<a name="IDX384"></a>
</dd>
<dt> <code>log-bad-space</code></dt>
<dd><p>Log actual bytes in and around bad pointers.
</p>
<a name="IDX385"></a>
</dd>
<dt> <code>log-nonfree-space</code></dt>
<dd><p>Log actual bytes in non-freed pointers.
</p>
<a name="IDX386"></a>
</dd>
<dt> <code>log-elapsed-time</code></dt>
<dd><p>Log elapsed-time for allocated pointers (see <tt>`conf.h'</tt>).
</p>
<a name="IDX387"></a>
</dd>
<dt> <code>log-current-time</code></dt>
<dd><p>Log current-time for allocated pointers (see <tt>`conf.h'</tt>).
</p>
<a name="IDX388"></a>
</dd>
<dt> <code>check-fence</code></dt>
<dd><p>Check fence-post memory areas.
</p>
<a name="IDX389"></a>
</dd>
<dt> <code>check-heap</code></dt>
<dd><p>Verify heap administrative structure.
</p>
<a name="IDX390"></a>
</dd>
<dt> <code>check-blank</code></dt>
<dd><p>Check to see if space that was blanked when a pointer was allocated or
when it was freed has been overwritten.  If this is enabled then it
will enable <code>free-blank</code> and <code>alloc-blank</code> automatically.
</p>
<a name="IDX391"></a>
</dd>
<dt> <code>check-funcs</code></dt>
<dd><p>Check the arguments of some functions (mostly string operations) looking
for bad pointers.
</p>
<a name="IDX392"></a>
</dd>
<dt> <code>check-shutdown</code></dt>
<dd><p>Check all of the pointers in the heap when the program exits.
</p>
<a name="IDX393"></a>
<a name="IDX394"></a>
<a name="IDX395"></a>
<a name="IDX396"></a>
<a name="IDX397"></a>
<a name="IDX398"></a>
<a name="IDX399"></a>
<a name="IDX400"></a>
<a name="IDX401"></a>
</dd>
<dt> <code>catch-signals</code></dt>
<dd><p>Shutdown the library automatically on SIGHUP, SIGINT, or SIGTERM.  This
will cause the library to dump its statistics (if requested) when you
press control-c on the program (for example).
</p>
<a name="IDX402"></a>
</dd>
<dt> <code>realloc-copy</code></dt>
<dd><p>Always copy data to a new pointer when realloc.
</p>
<a name="IDX403"></a>
<a name="IDX404"></a>
<a name="IDX405"></a>
<a name="IDX406"></a>
<a name="IDX407"></a>
<a name="IDX408"></a>
<a name="IDX409"></a>
<a name="IDX410"></a>
<a name="IDX411"></a>
<a name="IDX412"></a>
<a name="IDX413"></a>
<a name="IDX414"></a>
<a name="IDX415"></a>
<a name="IDX416"></a>
</dd>
<dt> <code>free-blank</code></dt>
<dd><p>Write special &quot;dmalloc-free&quot; byte (hexadecimal <code>0xdf</code>, octal
<code>0337</code>, decimal <code>223</code>) into space when it is freed.  You can
set this to be something else in the <tt>`settings.dist'</tt> file.  This
ensures that your program is not using memory after it has been freed.
You can check to see if areas have been improperly overwritten with
the <code>check-blank</code> token.  If the free space has been overwritten,
then <code>ERROR_FREE_OVERWRITTEN</code> is triggered.  See section <a href="#SEC16">Description of the Internal Error Codes</a>.
</p>
<a name="IDX417"></a>
<a name="IDX418"></a>
<a name="IDX419"></a>
</dd>
<dt> <code>error-abort</code></dt>
<dd><p>Abort the program (and dump core) on errors.  See <code>error-dump</code>
below.  See section <a href="#SEC14">Generating a Core File on Errors</a>.
</p>
<a name="IDX420"></a>
<a name="IDX421"></a>
<a name="IDX422"></a>
<a name="IDX423"></a>
<a name="IDX424"></a>
<a name="IDX425"></a>
<a name="IDX426"></a>
<a name="IDX427"></a>
<a name="IDX428"></a>
<a name="IDX429"></a>
<a name="IDX430"></a>
<a name="IDX431"></a>
<a name="IDX432"></a>
</dd>
<dt> <code>alloc-blank</code></dt>
<dd><p>Write special &quot;dmalloc-alloc&quot; byte (hexadecimal <code>0xda</code>, octal
<code>0332</code>, decimal <code>218</code>) into space when it is allocated.  You
can set this to be something else in the <tt>`settings.dist'</tt> file.
If you are not using <code>calloc</code> this will overwrite the user space
with the special bytes ensuring that your program is initializing its
dynamic memory appropriately.  Also, if you ask for 35 bytes and the
library has to give you a block of 64 because of rounding issues, it
will overwrite the extra memory with the special byte.  You can then
check to see if the extra areas have been improperly overwritten by
enabling the <code>check-blank</code> token.
</p>
<a name="IDX433"></a>
</dd>
<dt> <code>print-messages</code></dt>
<dd><p>Log any errors and messages to the screen via standard-error.
</p>
<a name="IDX434"></a>
<a name="IDX435"></a>
<a name="IDX436"></a>
</dd>
<dt> <code>catch-null</code></dt>
<dd><p>Abort the program immediately if the library fails to get more heap
space from the heap allocation routine <code>mmap</code> or <code>sbrk</code>.
</p>
<a name="IDX437"></a>
</dd>
<dt> <code>never-reuse</code></dt>
<dd><p>Have the heap never use space that has been used before and freed.
See section <a href="#SEC21">Tracking Down Non-Freed Memory</a>.  <em>WARNING</em>: This should be used with caution
since you may run out of heap space.
</p>
<a name="IDX438"></a>
<a name="IDX439"></a>
<a name="IDX440"></a>
</dd>
<dt> <code>error-dump</code></dt>
<dd><p>Dump core on error and then continue.  Later core dumps overwrite
earlier ones if the program encounters more than one error.  See
<code>error-abort</code> above.  See section <a href="#SEC14">Generating a Core File on Errors</a>.
</p>
<p><em>NOTE</em>: This will only work if your system supports the <code>fork</code>
system call and the configuration utility was able to fork without going
recursive.
</p>
<a name="IDX441"></a>
<a name="IDX442"></a>
<a name="IDX443"></a>

</dd>
<dt> <code>error-free-null</code></dt>
<dd><p>By default the library will not generate an error when a program tries
to free a NULL pointer.  By enabling this token, you can change this
behavior so an error is reported.  See also the ALLOW_FREE_NULL and
ALLOW_FREE_NULL_MESSAGE settings in the <tt>`settings.h'</tt> file to change
the default behavior.
</p>
</dd>
</dl>


<hr size="6">
<a name="RC-File"></a>
<a name="SEC34"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC33" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC29" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.5 Format of the Runtime Configuration File </h2>


<p>By using a <em>RC File</em> (or runtime configuration file) you can alias
tags to combinations of debug tokens.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.
</p>
<p><em>NOTE</em>: For beginning users, the dmalloc program has a couple of
tags built into it so it is not necessary for you to setup a RC file:
</p>
<dl compact="compact">
<dd><a name="IDX444"></a>
<a name="IDX445"></a>
</dd>
<dt> <code>runtime</code></dt>
<dd><p>Enables basic runtime tests including fence-post checking, null handling,
and logging of any errors.
</p>
<a name="IDX446"></a>
<a name="IDX447"></a>
</dd>
<dt> <code>low</code></dt>
<dd><p>Runtime settings plus minimal checking of heap structures and
overwriting of allocated and freed space.
</p>
<a name="IDX448"></a>
<a name="IDX449"></a>
</dd>
<dt> <code>medium</code></dt>
<dd><p>Low settings plus checking of all heap structures on each memory call,
always relocates block on realloc, and aborts on errors.  You may want
to use <kbd>-i</kbd> option to the dmalloc utility.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
<a name="IDX450"></a>
<a name="IDX451"></a>
</dd>
<dt> <code>high</code></dt>
<dd><p>Medium settings plus checking of overwritten freed and allocated
memory and checking of arguments to a number of common functions. You
may want to use <kbd>-i</kbd> option to the dmalloc utility.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
</p>
</dd>
</dl>

<p>For expert users, a sample <tt>`dmallocrc'</tt> file has been provided but
you are encouraged to roll your own combinations.  The name of default
rc-file is <tt>`$HOME/.dmallocrc'</tt>.  The <samp>`$HOME'</samp> environment
variable should be set by the system to point to your home-directory.
</p>
<p>The file should contain lines in the general form of:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">tag     token1, token2, &hellip;
</pre></td></tr></table>
<p><samp>`tag'</samp> is to be matched with the tag argument passed to the dmalloc
program, while <samp>`token1, token2, &hellip;'</samp> are debug capability
tokens.  See section <a href="#SEC29">Dmalloc Utility Program</a>, <a href="#SEC33">Description of the Debugging Tokens</a>.
</p>
<p>A line can be finished with a <samp>`\'</samp> meaning it continues onto the
next line.  Lines beginning with <samp>`#'</samp> are treated as comments and
are ignored along with empty lines.
</p>
<p>Here is an example of a <tt>`.dmallocrc'</tt> file:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">#
# Dmalloc runtime configuration file for the debug malloc library
#

# no debugging
none    none

# basic debugging
debug1  log-stats, log-non-free, check-fence

# more logging and some heap checking
debug2  log-stats, log-non-free, log-trans, \
        check-fence, check-heap, error-abort

# good utilities
debug3  log-stats, log-non-free, log-trans, \
        log-admin, check-fence, check-heap, realloc-copy, \
        free-blank, error-abort

&hellip;
</pre></td></tr></table>
<p>For example, with the above file installed, you can type <code>dmalloc
debug1</code> after setting up your shell alias.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
This enables the logging of statistics, the logging of non-freed memory,
and the checking of fence-post memory areas.
</p>
<p>Enter <code>dmalloc none</code> to disable all memory debugging features.
</p>

<hr size="6">
<a name="Source-Code"></a>
<a name="SEC35"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC34" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC36" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC29" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC39" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 5. Information on the Source Code </h1>


<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC36">5.1 Definition of Terms and other Information</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                 Definition of terms and other information.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC37">5.2 General Compatibility Concerns</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">               General compatibility concerns.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">                 Issues important for porting the library.
</td></tr>
</table>


<hr size="6">
<a name="Definitions"></a>
<a name="SEC36"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC35" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC35" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC39" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 5.1 Definition of Terms and other Information </h2>


<p>Here are a couple definitions and other information for those interested
in &quot;picking the brain&quot; of the library.  The code is a little ugly here
and there and it conforms to the Gray-Watson handbook of coding
standards only.
</p>
<dl compact="compact">
<dt> <em>bblock</em></dt>
<dd><p>basic block containing 2 ^ BASIC_BLOCK bytes of info
</p>
</dd>
<dt> <em>bblock_adm</em></dt>
<dd><p>administration for a set of basic blocks
</p>
</dd>
<dt> <em>dblock</em></dt>
<dd><p>divided block containing some base 2 number of blocks smaller than a
basic block.
</p>
</dd>
<dt> <em>dblock_adm</em></dt>
<dd><p>administration for a set of divided blocks
</p>
</dd>
<dt> <em>chunk</em></dt>
<dd><p>some anonymous amount of memory
</p></dd>
</dl>

<p>For more information about administration structures, see the code and
comments from <tt>`chunk_loc.h'</tt>.
</p>

<hr size="6">
<a name="Compatibility"></a>
<a name="SEC37"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC36" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC38" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC35" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC39" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 5.2 General Compatibility Concerns </h2>


<ul>
<li>
Realloc() backwards compatibility with being able to realloc from the
last freed block is <em>not</em> supported.  The author is interested to
know who is using this (cough, cough) feature and for what reason.

<a name="IDX452"></a>

</li><li>
Realloc() of a NULL pointer is supported in which case the library
will just make a call to malloc().  This can be disabled with the help
of the <code>ALLOW_REALLOC_NULL</code> manual compilation option in the
<tt>`settings.h'</tt> file to adjust the library's default behavior.

<a name="IDX453"></a>

</li><li>
Some systems allow free(0) to not be an error for some reason.  Since
0 is not a valid address returned by the malloc call, it is debatable
that this should be allowed.  See <tt>`settings.h'</tt> for the
<code>ALLOW_FREE_NULL</code> manual compilation option to adjust the
library's default behavior.

</li><li>
Aside from possibly being slower than the system's memory allocation
functions, the library should be fully compatible with the standard
memory routines.  If this is <em>not</em> the case, please bring this to
my attention.
</li></ul>


<hr size="6">
<a name="Portability"></a>
<a name="SEC38"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC37" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC39" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC35" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC39" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 5.3 Issues Important for Porting the Library </h2>


<p>General portability issues center around:
</p>
<ul>
<li>
<a name="IDX454"></a>
<a name="IDX455"></a>
<a name="IDX456"></a>
<a name="IDX457"></a>
mmap, sbrk, or compatible function usages.  The library does support a
preallocated memory chunk heap.  See the <code>INTERNAL_MEMORY_SPACE</code>
define in the <tt>`settings.dist'</tt> file.

</li><li>
<a name="IDX458"></a>
The locating of the caller's address from the dmalloc functions.
This is useful in locating problems from dmalloc functions called from C
files which did not include <tt>`dmalloc.h'</tt>: C library calls for
instance.

<a name="IDX459"></a>
<p>See <tt>`return.h'</tt> for the available architecture/compiler
combinations.  You may want to examine the assembly code from gcc (GNUs
superior c-compiler) version 2+ being run on the following code.  It
should give you a good start on building a hack for your box.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">static char * x;

a()
{
        x = __builtin_return_address(0);
}

main()
{
        a();
}
</pre></td></tr></table>
</li></ul>


<hr size="6">
<a name="Troubleshooting"></a>
<a name="SEC39"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC38" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC35" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 6. Some Solutions to Common Problems </h1>


<p>This section provides some answers to some common problems and
questions.  Please send me mail with any additions to
this list - either problems you are still having or tips that you would
like to pass on.
</p>
<p>When diagnosing a problem, if possible, always make sure you are running
the most up to date version of Dmalloc available from the home page at
URL <a href="http://dmalloc.com/">http://dmalloc.com/</a>.  Problems are often fixed and a new
release can be published before people encounter them.
</p>
<dl compact="compact">
<dd>
<a name="IDX460"></a>
<a name="IDX461"></a>
<a name="IDX462"></a>
<a name="IDX463"></a>
<a name="IDX464"></a>
</dd>
<dt> <samp>`Why does my program run so slow?'</samp></dt>
<dd>
<a name="IDX465"></a>
<p>This library has never been (and maybe never will be) optimized for
space nor speed.  Some of its features make it unable to use some of
the organizational methods of other more efficient heap libraries.
</p>
<p>If you have the <code>check-heap</code> token enabled, your program might
run slow or seem to hang.  This is because by default, the library
will run a full check of the heap with every memory allocation or
free.  You can have the library check itself less frequently by using
the <kbd>-i</kbd> option to the dmalloc utility.  See section <a href="#SEC29">Dmalloc Utility Program</a>.
If you are using the <kbd>high</kbd> token and you need your program to run
faster, try the <kbd>medium</kbd> or <kbd>low</kbd> tokens which don't check as
many heap features and so run faster although they will not catch as
many problems. See section <a href="#SEC34">Format of the Runtime Configuration File</a>.
</p>
<a name="IDX466"></a>
<a name="IDX467"></a>
</dd>
<dt> <samp>`Why was a log-file not produced after I ran my program?'</samp></dt>
<dd>
<p>This could be caused by a number of different problems.
</p>
<ol>
<li> Are you sure you followed all of the items in the &quot;Getting Started&quot;
section?  Please review them if there is any doubt.  See section <a href="#SEC4">Getting Started with the Library</a>.

<a name="IDX468"></a>
<a name="IDX469"></a>
<a name="IDX470"></a>

</li><li> Use the <kbd>env</kbd> or <kbd>printenv</kbd> commands to make sure that
the <samp>`DMALLOC_OPTIONS'</samp> variable is set in your exported environment.
See section <a href="#SEC32">Environment Variable Name and Features</a>.

<a name="IDX471"></a>
<a name="IDX472"></a>

</li><li> Make sure that your program has been compiled correctly with the
dmalloc library.  The <kbd>ident</kbd> program should show chunk.c and other
dmalloc files compiled into your program.  You can also do <kbd>strings
-a your-program | grep chunk.c</kbd> and look for something like <samp>`$Id:
chunk.c,v 1.152 1999/08/25 12:37:01 gray Exp $'</samp> with different versions
and date information.  If this doesn't show up then chances are dmalloc
was not linked into your program.

</li><li> If your program changes its working directory, it may write the
dmalloc log-file somewhere else in the filesystem.  You will need to
check both where the program was started and to where it might change
directory.

</li><li> The logfile is only produced when <code>dmalloc_shutdown()</code> is
called.  By default it will be called when <code>exit()</code> gets called.
If you are running your program and press <kbd>Control-C</kbd> under Unix
the program will stop immediately and <code>dmalloc_shutdown()</code> will
not get called.  You can either setup a signal handler for
<code>SIGINTR</code> and call exit yourself, or you can enable the
<code>catch-signals</code> token.  See section <a href="#SEC33">Description of the Debugging Tokens</a>.

</li><li> If your program is segfaulting or otherwise crashing when it exits, the
<code>exit()</code> routine may not being called.  You will have to resolve
these issues so the dmalloc library can gracefully exit and write its
log file.

</li><li> You may want to call <code>dmalloc_log_stats()</code> and
<code>dmalloc_log_unfreed()</code> (or <code>dmalloc_log_changed()</code>) directly
to have the library write its log file.  Some system modules may not
have shutdown if you call this before <code>exit()</code> so extra unfreed
memory may be reported.

</li></ol>

</dd>
<dt> <samp>`I don't see any information about my non-freed (leaked) memory?'</samp></dt>
<dd>
<p>The library will not (by default) report on &quot;unknown&quot; non-freed
memory.  Unknown means memory that does not have associated file and
line information.
</p>
<p>This will be necessary if you are <em>not</em>
including <tt>`dmalloc.h'</tt> in all of your C files or if you are
interested in tracking leaks in system functions.
</p>
</dd>
<dt> <samp>`Dmalloc is returning the error &quot;malloc library has gone recursive&quot;'</samp></dt>
<dd>
<p>This most likely indicates that you are using the Dmalloc library within
a threaded application and two threads are trying to use the dmalloc
library at once.  Please see the section of the manual about threads for
more information about properly configuring the library.  See section <a href="#SEC24">Using the Library with a Thread Package</a>.
</p>
<p>If you are not using threads, then your program could have caught a
signal while within Dmalloc, which then in turn called a memory
allocation routine.  It is unwise to allocate memory on the heap in most
signal handlers.  Lastly, some functions called by the library may call
memory routines that it does not anticipate.  If you think this the
case, please report the problem and include a stack trace, operating
system version/type, and the version of Dmalloc you are using.
</p>
</dd>
</dl>


<hr size="6">
<a name="Index-of-Concepts"></a>
<a name="SEC40"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC39" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[ &gt; ]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC39" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ &gt;&gt; ]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="unnumbered"> Index of Concepts </h1>

<table><tr><th valign="top">Jump to: &nbsp; </th><td><a href="#SEC40_0" class="summary-letter"><b>%</b></a>
 &nbsp; 
<a href="#SEC40_1" class="summary-letter"><b>-</b></a>
 &nbsp; 
<a href="#SEC40_2" class="summary-letter"><b>.</b></a>
 &nbsp; 
<a href="#SEC40_3" class="summary-letter"><b>0</b></a>
 &nbsp; 
<a href="#SEC40_4" class="summary-letter"><b>1</b></a>
 &nbsp; 
<a href="#SEC40_5" class="summary-letter"><b>2</b></a>
 &nbsp; 
<a href="#SEC40_6" class="summary-letter"><b>3</b></a>
 &nbsp; 
<a href="#SEC40_7" class="summary-letter"><b>4</b></a>
 &nbsp; 
<a href="#SEC40_8" class="summary-letter"><b>6</b></a>
 &nbsp; 
<a href="#SEC40_9" class="summary-letter"><b>7</b></a>
 &nbsp; 
<br>
<a href="#SEC40_10" class="summary-letter"><b>A</b></a>
 &nbsp; 
<a href="#SEC40_11" class="summary-letter"><b>B</b></a>
 &nbsp; 
<a href="#SEC40_12" class="summary-letter"><b>C</b></a>
 &nbsp; 
<a href="#SEC40_13" class="summary-letter"><b>D</b></a>
 &nbsp; 
<a href="#SEC40_14" class="summary-letter"><b>E</b></a>
 &nbsp; 
<a href="#SEC40_15" class="summary-letter"><b>F</b></a>
 &nbsp; 
<a href="#SEC40_16" class="summary-letter"><b>G</b></a>
 &nbsp; 
<a href="#SEC40_17" class="summary-letter"><b>H</b></a>
 &nbsp; 
<a href="#SEC40_18" class="summary-letter"><b>I</b></a>
 &nbsp; 
<a href="#SEC40_19" class="summary-letter"><b>J</b></a>
 &nbsp; 
<a href="#SEC40_20" class="summary-letter"><b>K</b></a>
 &nbsp; 
<a href="#SEC40_21" class="summary-letter"><b>L</b></a>
 &nbsp; 
<a href="#SEC40_22" class="summary-letter"><b>M</b></a>
 &nbsp; 
<a href="#SEC40_23" class="summary-letter"><b>N</b></a>
 &nbsp; 
<a href="#SEC40_24" class="summary-letter"><b>O</b></a>
 &nbsp; 
<a href="#SEC40_25" class="summary-letter"><b>P</b></a>
 &nbsp; 
<a href="#SEC40_26" class="summary-letter"><b>Q</b></a>
 &nbsp; 
<a href="#SEC40_27" class="summary-letter"><b>R</b></a>
 &nbsp; 
<a href="#SEC40_28" class="summary-letter"><b>S</b></a>
 &nbsp; 
<a href="#SEC40_29" class="summary-letter"><b>T</b></a>
 &nbsp; 
<a href="#SEC40_30" class="summary-letter"><b>U</b></a>
 &nbsp; 
<a href="#SEC40_31" class="summary-letter"><b>V</b></a>
 &nbsp; 
<a href="#SEC40_32" class="summary-letter"><b>W</b></a>
 &nbsp; 
<a href="#SEC40_33" class="summary-letter"><b>Z</b></a>
 &nbsp; 
</td></tr></table>
<table border="0" class="index-cp">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_0">%</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX325">%h</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX329">%i</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX331">%p</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX335">%t</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX338">%u</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_1">-</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX3">-disable-cxx</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX5">-enable-shlib</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX4">-enable-threads</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_2">.</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC34">.dmallocrc file</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_3">0</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX428">0332 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX411">0337 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX430">0xda character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX413">0xdf character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_4">1</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX159">1, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX168">10, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX176">11, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX181">13, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_5">2</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX163">2, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX187">20, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX194">21, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX425">218 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX200">22, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX408">223 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX206">23, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX211">24, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX216">25, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX221">26, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX226">27, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX231">28, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_6">3</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX236">30, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX427">332 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX410">337 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_7">4</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX241">40, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX246">41, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX251">43, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX258">45, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_8">6</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX264">60, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX269">61, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX274">67, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_9">7</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX281">70, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX286">72, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX291">73, error code</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_10">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX71">abort</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX289">address list error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX374">address locating</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX373">address setting</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX284">admin list error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX18">alias, shell</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX318">alias, shell</a></td><td valign="top"><a href="#SEC30">4.1 Using a Shell Alias with the Utility</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX254">alloc failed error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX432">alloc-blank</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC5">allocation basics</a></td><td valign="top"><a href="#SEC5">2.3 Basic Description of Terms and Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC11">allocation macros</a></td><td valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX33">Allocation of zeros</a></td><td valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX442">ALLOW_FREE_NULL</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX453">ALLOW_FREE_NULL settings.h option</a></td><td valign="top"><a href="#SEC37">5.2 General Compatibility Concerns</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX316">ALLOW_FREE_NULL_MESSAGE</a></td><td valign="top"><a href="#SEC27">3.13 Explanation of the Logfile Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX443">ALLOW_FREE_NULL_MESSAGE</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX452">ALLOW_REALLOC_NULL settings.h option</a></td><td valign="top"><a href="#SEC37">5.2 General Compatibility Concerns</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX272">already free error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX10">ANSI-C compiler</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC13">argument checking</a></td><td valign="top"><a href="#SEC13">3.3 Checking of Function Arguments</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX64">assembly hacks</a></td><td valign="top"><a href="#SEC12">3.2 Getting Caller Address Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX16">atexit</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX84">atexit function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC_Top">author</a></td><td valign="top"><a href="#SEC_Top">Debug Malloc Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX13">automatic shutdown</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_11">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX283">bad admin structure list</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX214">bad file error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX219">bad line error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX171">bad setup error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX244">bad size error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX19">bash shell</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX319">bash shell</a></td><td valign="top"><a href="#SEC30">4.1 Using a Shell Alias with the Utility</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX362">bash usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC5">basic allocation information</a></td><td valign="top"><a href="#SEC5">2.3 Basic Description of Terms and Functions</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC6">basic definitions</a></td><td valign="top"><a href="#SEC6">2.3.1 General Memory Terms and Concepts</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC4">beginning</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX403">blank space</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX420">blank space</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX404">blanking memory</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX421">blanking memory</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX43">bounds checking</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX360">Bourne shell usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC3">building the library</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_12">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX365">C shell usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC18">c++ usage</a></td><td valign="top"><a href="#SEC18">3.8 Using the Library with C++</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX306">caller address translation</a></td><td valign="top"><a href="#SEC23">3.9.4 Translating Return Addresses into Code Locations</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC12">caller's address</a></td><td valign="top"><a href="#SEC12">3.2 Getting Caller Address Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX32">calloc</a></td><td valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX202">cannot locate pointer in heap</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX436">catch-null</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX393">catch-signals</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">cgi-bin process debugging</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">cgi-bin usage of dmalloc</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX138">changed memory log</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX280">check-blank</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX390">check-blank</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX388">check-fence</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX391">check-funcs</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX56">check-heap</a></td><td valign="top"><a href="#SEC9">2.5 How the Library Checks Your Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX389">check-heap</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX465">check-heap</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX392">check-shutdown</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC13">checking arguments</a></td><td valign="top"><a href="#SEC13">3.3 Checking of Function Arguments</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX44">checking bounds</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX139">checkpoint memory usage</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">child process debugging</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX406">clearing memory</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX423">clearing memory</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX369">comma separated tokens in env variable</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC39">common problems</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC37">compatibility</a></td><td valign="top"><a href="#SEC37">5.2 General Compatibility Concerns</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC3">compiling the library</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX6">conf.h file</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC34">configuration file</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2">configure script</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC3">configuring the library</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX45">constancy verification</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC1">copying</a></td><td valign="top"><a href="#SEC1">1. Library Copying and Licensing Conditions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX53">core dump</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC14">core dump</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX418">core dump</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX439">core dump</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX69">core dump, none</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX66">core file</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX253">could not grow heap by allocating memory</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX125">count changed</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX126">count number of bytes changed since mark</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX40">cpp</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX22">csh shell</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX323">csh shell</a></td><td valign="top"><a href="#SEC30">4.1 Using a Shell Alias with the Utility</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX366">csh usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX95">current debug value</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC25">cygwin</a></td><td valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_13">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX431">da character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">daemon process debugging</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX368">debug setting</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC33">debug tokens</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC14">debugger</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC19">debugger usage with dmalloc</a></td><td valign="top"><a href="#SEC19">3.9 Using Dmalloc With a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">debugging cgi-bin processes</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">debugging child processes</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">debugging daemon processes</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">debugging server processes</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX424">decimal 218 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX407">decimal 223 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX345">delay heap checking</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX347">delay heap checking</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX354">delay heap checking</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX17">destructor</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX414">df character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC20">diagnosing errors</a></td><td valign="top"><a href="#SEC20">3.9.1 Diagnosing General Problems with a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC17">disabling library checking</a></td><td valign="top"><a href="#SEC17">3.7 How to Disable the library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC17">disabling the library</a></td><td valign="top"><a href="#SEC17">3.7 How to Disable the library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC29">dmalloc program</a></td><td valign="top"><a href="#SEC29">4. Dmalloc Utility Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC29">dmalloc utility</a></td><td valign="top"><a href="#SEC29">4. Dmalloc Utility Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC11">dmalloc.h file</a></td><td valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC17">dmalloc_debug</a></td><td valign="top"><a href="#SEC17">3.7 How to Disable the library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX90">dmalloc_debug function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX94">dmalloc_debug_current function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX97">dmalloc_debug_setup</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX314">dmalloc_debug_setup function</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX313">dmalloc_debug_setup usage</a></td><td valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX74">dmalloc_errno number</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX298">dmalloc_error() routine</a></td><td valign="top"><a href="#SEC19">3.9 Using Dmalloc With a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX103">dmalloc_examine function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX25">DMALLOC_FUNC_CHECK</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC13">DMALLOC_FUNC_CHECK flag</a></td><td valign="top"><a href="#SEC13">3.3 Checking of Function Arguments</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX150">dmalloc_get_stats function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX137">dmalloc_log_changed function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX129">dmalloc_log_stats function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX133">dmalloc_log_unfreed function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX78">dmalloc_logpath variable</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX111">dmalloc_mark function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX118">dmalloc_memory_allocated function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX146">dmalloc_message function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC32">DMALLOC_OPTIONS</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX470">DMALLOC_OPTIONS</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX81">dmalloc_shutdown function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX8">DMALLOC_SIZE option</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX155">dmalloc_strerror function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX12">dmalloc_t test program</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX108">dmalloc_track function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX86">dmalloc_verify function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX301">dmalloc_verify() routine</a></td><td valign="top"><a href="#SEC20">3.9.1 Diagnosing General Problems with a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX142">dmalloc_vmessage function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX296">dmallocc.cc</a></td><td valign="top"><a href="#SEC18">3.8 Using the Library with C++</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC18">dmallocc.cc file</a></td><td valign="top"><a href="#SEC18">3.8 Using the Library with C++</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC34">dmallocrc file</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX52">dump core</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC14">dump core</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX417">dump core</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX438">dump core</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_14">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX468">env</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC32">environment variable</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX166">errno value is not valid</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX169">error code 10</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX177">error code 11</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX182">error code 13</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX188">error code 20</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX195">error code 21</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX201">error code 22</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX207">error code 23</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX212">error code 24</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX217">error code 25</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX222">error code 26</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX227">error code 27</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX232">error code 28</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX237">error code 30</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX242">error code 40</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX247">error code 41</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX252">error code 43</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX259">error code 45</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX265">error code 60</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX270">error code 61</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX275">error code 67</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX282">error code 70</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX287">error code 72</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX292">error code 73</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX160">error code, 1</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX164">error code, 2</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC16">error codes</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX157">error message</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX76">error number</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC14">error-abort</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX419">error-abort</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC14">error-dump</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX440">error-dump</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX441">error-free-null</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX185">error-free-null token</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX290">ERROR_ADDRESS_LIST</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX285">ERROR_ADMIN_LIST</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX255">ERROR_ALLOC_FAILED</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX273">ERROR_ALREADY_FREE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX215">ERROR_BAD_FILE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX220">ERROR_BAD_LINE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX172">ERROR_BAD_SETUP</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX245">ERROR_BAD_SIZE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX278">ERROR_FREE_OVERWRITTEN</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX416">ERROR_FREE_OVERWRITTEN</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX179">ERROR_IN_TWICE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX210">ERROR_IS_FOUND</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX191">ERROR_IS_NULL</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX184">ERROR_LOCK_NOT_CONFIG</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX162">ERROR_NONE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX203">ERROR_NOT_FOUND</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX197">ERROR_NOT_IN_HEAP</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX268">ERROR_NOT_ON_BLOCK</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX240">ERROR_NOT_START_BLOCK</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX230">ERROR_OVER_FENCE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX263">ERROR_OVER_LIMIT</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX343">ERROR_OVER_LIMIT</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX295">ERROR_SLOT_CORRUPT</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX250">ERROR_TOO_BIG</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX225">ERROR_UNDER_FENCE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX235">ERROR_WOULD_OVERWRITE</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX104">examine a pointer</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC15">extensions</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_15">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX228">failed over picket-fence magic-number check</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX223">failed under picket-fence magic-number check</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC39">faq</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC8">features</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX42">fence-post checking</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC22">fence-post errors</a></td><td valign="top"><a href="#SEC22">3.9.3 Diagnosing Fence-Post Overwritten Memory</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX39">file/line numbers</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX208">found pointer the user was looking for</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX38">free</a></td><td valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX186">free null token</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX277">free overwritten error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX276">free space has been overwritten</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX279">free-blank</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX415">free-blank</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX50">freed memory</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX51">freed memory</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_16">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX459">gcc</a></td><td valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX297">gdb</a></td><td valign="top"><a href="#SEC19">3.9 Using Dmalloc With a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX300">gdb with shared libraries</a></td><td valign="top"><a href="#SEC19">3.9 Using Dmalloc With a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC20">general errors</a></td><td valign="top"><a href="#SEC20">3.9.1 Diagnosing General Problems with a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC14">generating core dump</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX151">get heap statistics</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX309">getenv, problems with</a></td><td valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX312">GETENV_SAVE conf.h option</a></td><td valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX310">GetEnvironmentVariableA, using with</a></td><td valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX326">gethostname function usage</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX332">getpid function usage</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC4">getting started</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX339">getuid function usage</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_17">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX464">hanging program</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX311">HAVE_GETENVIRONMENTVARIABLEA</a></td><td valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX28">heap memory</a></td><td valign="top"><a href="#SEC6">2.3.1 General Memory Terms and Concepts</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX152">heap statistics function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC39">help</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX429">hexadecimal 0xda character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX412">hexadecimal 0xdf character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX450">high token</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC28">hints that may help</a></td><td valign="top"><a href="#SEC28">3.14 Various Other Hints That May Help</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX327">hostname in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC39">how do i...</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC4">how to begin</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX399">HUP signal</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_18">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX471">ident</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX175">in twice error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX170">initialization and setup failed</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC3">installing the library</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX400">INT signal</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX115">interaction count</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX350">interaction count</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX288">internal address list corruption</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX75">internal error number</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX293">internal memory slot corruption</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX457">INTERNAL_MEMORY_SPACE</a></td><td valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX324">interval setting</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX376">interval setting</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC_Top">introduction</a></td><td valign="top"><a href="#SEC_Top">Debug Malloc Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX243">invalid allocation size</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX165">invalid errno value</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX167">INVALID_ERROR</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX209">is found error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX190">is null error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX58">iteration count</a></td><td valign="top"><a href="#SEC9">2.5 How the Library Checks Your Program</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_19">J</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC4">jump start</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_20">K</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX72">kill process</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX73">KILL_PROCESS</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX20">ksh shell</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX320">ksh shell</a></td><td valign="top"><a href="#SEC30">4.1 Using a Shell Alias with the Utility</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX363">ksh usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_21">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX248">largest maximum allocation size exceeded</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX49">leaking memory</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC21">leaking memory</a></td><td valign="top"><a href="#SEC21">3.9.2 Tracking Down Non-Freed Memory</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC18">libdmallocxx.a</a></td><td valign="top"><a href="#SEC18">3.8 Using the Library with C++</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC1">library permissions</a></td><td valign="top"><a href="#SEC1">1. Library Copying and Licensing Conditions</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC29">library utility</a></td><td valign="top"><a href="#SEC29">4. Dmalloc Utility Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX357">library version</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC1">license</a></td><td valign="top"><a href="#SEC1">1. Library Copying and Licensing Conditions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX307">lock on</a></td><td valign="top"><a href="#SEC24">3.10 Using the Library with a Thread Package</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX344">lock on</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX173">lock-on</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX180">lock-on not configured</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX370">lockon setting</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX140">log memory changes</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX130">log statistics</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX134">log unfreed memory</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX383">log-admin</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX384">log-bad-space</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX387">log-current-time</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX386">log-elapsed-time</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX381">log-known</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX380">log-non-free</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX385">log-nonfree-space</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX379">log-stats</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX382">log-trans</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX114">LOG_ITERATION</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX349">LOG_ITERATION</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX57">LOG_ITERATION_COUNT</a></td><td valign="top"><a href="#SEC9">2.5 How the Library Checks Your Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC27">logfile format</a></td><td valign="top"><a href="#SEC27">3.13 Explanation of the Logfile Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX144">logfile message writer</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX148">logfile message writer</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX79">logfile name</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX466">logfile not produced</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX371">logfile setting</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX372">logging information to disk</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX46">logging statistics</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX446">low token</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_22">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC11">macros, allocation</a></td><td valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC3">making the library</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX29">malloc</a></td><td valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC7">malloc functions</a></td><td valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX178">malloc library has gone recursive</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX352">mark count</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX113">mark memory position</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX448">medium token</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX61">memalign</a></td><td valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX119">memory allocated function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC6">memory definitions</a></td><td valign="top"><a href="#SEC6">2.3.1 General Memory Terms and Concepts</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX48">memory leaks</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC21">memory leaks</a></td><td valign="top"><a href="#SEC21">3.9.2 Tracking Down Non-Freed Memory</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX260">memory limit</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX342">memory limit</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX112">memory position marker</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX55">memory problems in system functions</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX59">memory transaction count</a></td><td valign="top"><a href="#SEC9">2.5 How the Library Checks Your Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX353">memory transaction count</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX70">missing core dump</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX204">mmap</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX256">mmap</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC20">mmap</a></td><td valign="top"><a href="#SEC20">3.9.1 Diagnosing General Problems with a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX434">mmap</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX454">mmap, usage without</a></td><td valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_23">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX328">name of host in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX437">never-reuse</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX68">no core dump</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX161">no error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX467">no logfile produced</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX378">none token</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX198">not found error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX193">not in heap error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX267">not on block boundary error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX239">not start block error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX127">number bytes changed since mark</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX120">number of bytes allocated</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_24">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX426">octal 332 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX409">octal 337 character</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX15">on_exit</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX85">on_exit function</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC28">other hints</a></td><td valign="top"><a href="#SEC28">3.14 Various Other Hints That May Help</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX229">over fence error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX262">over limit error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX261">over user specified allocation limit error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX91">override debug settings</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX98">override debug settings</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC2">overview</a></td><td valign="top"><a href="#SEC2">2. Description of Features and How to Get Started</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX405">overwriting memory</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX422">overwriting memory</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_25">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX122">page size</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC1">permissions of the library</a></td><td valign="top"><a href="#SEC1">1. Library Copying and Licensing Conditions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX333">pid in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX105">pointer information</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX266">pointer is not on block boundary</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX196">pointer is not pointing to heap data space</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX238">pointer is not to start of memory block</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX189">pointer is null error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX199">pointer not found error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX192">pointer not in heap error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX303">pointer seen count</a></td><td valign="top"><a href="#SEC21">3.9.2 Tracking Down Non-Freed Memory</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC38">portability</a></td><td valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX218">possibly bad .c file line-number</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX213">possibly bad .c filename pointer</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX456">preallocated memory heap</a></td><td valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX433">print-messages</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX469">printenv</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC39">problems</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX334">process-id in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX67">program core</a></td><td valign="top"><a href="#SEC14">3.4 Generating a Core File on Errors</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC10">programming</a></td><td valign="top"><a href="#SEC10">3. How to Program with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC24">pthreads</a></td><td valign="top"><a href="#SEC24">3.10 Using the Library with a Thread Package</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_26">Q</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC39">questions</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC4">quick start</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_27">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC12">ra</a></td><td valign="top"><a href="#SEC12">3.2 Getting Caller Address Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX65">ra_info.pl</a></td><td valign="top"><a href="#SEC12">3.2 Getting Caller Address Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC23">ra_info.pl</a></td><td valign="top"><a href="#SEC23">3.9.4 Translating Return Addresses into Code Locations</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC34">rc file</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX24">rc shell</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX308">reading environment, problems with</a></td><td valign="top"><a href="#SEC25">3.11 Using the library with Cygwin environment.</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX36">realloc</a></td><td valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX402">realloc-copy</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX60">recalloc</a></td><td valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX174">recursion</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX153">report heap statistics</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC17">restoring library flags</a></td><td valign="top"><a href="#SEC17">3.7 How to Disable the library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX41">return-address</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC12">return-address</a></td><td valign="top"><a href="#SEC12">3.2 Getting Caller Address Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX458">return-address</a></td><td valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX305">return-address translation</a></td><td valign="top"><a href="#SEC23">3.9.4 Translating Return Addresses into Code Locations</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC12">return.h file</a></td><td valign="top"><a href="#SEC12">3.2 Getting Caller Address Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX444">runtime token</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC34">runtime-config file</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_28">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX205">sbrk</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC20">sbrk</a></td><td valign="top"><a href="#SEC20">3.9.1 Diagnosing General Problems with a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX435">sbrk</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX455">sbrk, usage without</a></td><td valign="top"><a href="#SEC38">5.3 Issues Important for Porting the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX107">seen count</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX304">seen count</a></td><td valign="top"><a href="#SEC21">3.9.2 Tracking Down Non-Freed Memory</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX317">seen count</a></td><td valign="top"><a href="#SEC27">3.13 Explanation of the Logfile Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">server process debugging</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX92">set debug functionality flags</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX99">set debug functionality flags</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1">settings.dist file</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX7">settings.h file</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX100">setup debug flags</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX361">sh usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX299">shared libraries with gdb</a></td><td valign="top"><a href="#SEC19">3.9 Using Dmalloc With a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX359">shell usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX395">shutdown on signal</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX82">shutdown the library</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX14">shutdown, automatic</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX396">SIGHUP</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX397">SIGINT</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX394">signal shutdown</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX398">SIGTERM</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX123">size of memory pages</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX294">slot corrupt error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX460">slow running</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC35">source code</a></td><td valign="top"><a href="#SEC35">5. Information on the Source Code</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC36">source definitions</a></td><td valign="top"><a href="#SEC36">5.1 Definition of Terms and other Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX27">stack memory</a></td><td valign="top"><a href="#SEC6">2.3.1 General Memory Terms and Concepts</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX346">start heap check later</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX348">start heap check later</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX355">start heap check later</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX377">start setting</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX26">static memory</a></td><td valign="top"><a href="#SEC6">2.3.1 General Memory Terms and Concepts</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX47">statistics</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX131">statistics logging</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX302">STORE_SEEN_COUNT conf.h option</a></td><td valign="top"><a href="#SEC21">3.9.2 Tracking Down Non-Freed Memory</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX63">strdup</a></td><td valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX156">string error message</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX101">string of debug tokens</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX472">strings</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX54">system memory problems</a></td><td valign="top"><a href="#SEC8">2.4 General Features of the Library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_29">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX23">tcsh shell</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX322">tcsh shell</a></td><td valign="top"><a href="#SEC30">4.1 Using a Shell Alias with the Utility</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX367">tcsh usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX401">TERM signal</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX11">testing the library</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX183">thread locking has not been configured</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX330">thread-id in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC24">threads</a></td><td valign="top"><a href="#SEC24">3.10 Using the Library with a Thread Package</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX336">time function usage</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX337">time in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX451">token high</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX447">token low</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX449">token medium</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX445">token runtime</a></td><td valign="top"><a href="#SEC34">4.5 Format of the Runtime Configuration File</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC33">tokens, debug</a></td><td valign="top"><a href="#SEC33">4.4 Description of the Debugging Tokens</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX249">too big error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX462">too slow</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX109">track memory calls</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX375">tracking addresses</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX116">transaction count</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX351">transaction count</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX271">tried to free previously freed pointer</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC39">troubleshooting</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC17">turning off library flags</a></td><td valign="top"><a href="#SEC17">3.7 How to Disable the library</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_30">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX340">uid in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX224">under fence error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX135">unfreed memory log</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">usage of dmalloc in a daemon</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">usage of dmalloc in a server</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC26">usage of dmalloc with cgi-bin</a></td><td valign="top"><a href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC31">usage of the utility</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX233">use of pointer would exceed allocation</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX257">USE_MMAP conf.h option</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX9">USE_RETURN_MACROS conf.h option</a></td><td valign="top"><a href="#SEC3">2.1 How to Install the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX341">user-id in logfile path</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC19">using a debugger with dmalloc</a></td><td valign="top"><a href="#SEC19">3.9 Using Dmalloc With a Debugger</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC29">utility program</a></td><td valign="top"><a href="#SEC29">4. Dmalloc Utility Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC31">utility usage</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX356">utility version</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_31">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX62">valloc</a></td><td valign="top"><a href="#SEC11">3.1 Macros Providing File and Line Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC28">various hints</a></td><td valign="top"><a href="#SEC28">3.14 Various Other Hints That May Help</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX87">verify pointers</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX88">verify the heap</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX315">version of library</a></td><td valign="top"><a href="#SEC27">3.13 Explanation of the Logfile Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX358">version of utility</a></td><td valign="top"><a href="#SEC31">4.2 How to Use the Dmalloc Program</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_32">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC4">where to begin</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX463">why hanging</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX461">why running slow</a></td><td valign="top"><a href="#SEC39">6. Some Solutions to Common Problems</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX234">would overwrite error</a></td><td valign="top"><a href="#SEC16">3.6 Description of the Internal Error Codes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX143">write message to logfile</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX147">write message to logfile</a></td><td valign="top"><a href="#SEC15">3.5 Additional Non-standard Routines</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC40_33">Z</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX34">zeros, allocation of</a></td><td valign="top"><a href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX21">zsh shell</a></td><td valign="top"><a href="#SEC4">2.2 Getting Started with the Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX321">zsh shell</a></td><td valign="top"><a href="#SEC30">4.1 Using a Shell Alias with the Utility</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX364">zsh usage</a></td><td valign="top"><a href="#SEC32">4.3 Environment Variable Name and Features</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a href="#SEC40_0" class="summary-letter"><b>%</b></a>
 &nbsp; 
<a href="#SEC40_1" class="summary-letter"><b>-</b></a>
 &nbsp; 
<a href="#SEC40_2" class="summary-letter"><b>.</b></a>
 &nbsp; 
<a href="#SEC40_3" class="summary-letter"><b>0</b></a>
 &nbsp; 
<a href="#SEC40_4" class="summary-letter"><b>1</b></a>
 &nbsp; 
<a href="#SEC40_5" class="summary-letter"><b>2</b></a>
 &nbsp; 
<a href="#SEC40_6" class="summary-letter"><b>3</b></a>
 &nbsp; 
<a href="#SEC40_7" class="summary-letter"><b>4</b></a>
 &nbsp; 
<a href="#SEC40_8" class="summary-letter"><b>6</b></a>
 &nbsp; 
<a href="#SEC40_9" class="summary-letter"><b>7</b></a>
 &nbsp; 
<br>
<a href="#SEC40_10" class="summary-letter"><b>A</b></a>
 &nbsp; 
<a href="#SEC40_11" class="summary-letter"><b>B</b></a>
 &nbsp; 
<a href="#SEC40_12" class="summary-letter"><b>C</b></a>
 &nbsp; 
<a href="#SEC40_13" class="summary-letter"><b>D</b></a>
 &nbsp; 
<a href="#SEC40_14" class="summary-letter"><b>E</b></a>
 &nbsp; 
<a href="#SEC40_15" class="summary-letter"><b>F</b></a>
 &nbsp; 
<a href="#SEC40_16" class="summary-letter"><b>G</b></a>
 &nbsp; 
<a href="#SEC40_17" class="summary-letter"><b>H</b></a>
 &nbsp; 
<a href="#SEC40_18" class="summary-letter"><b>I</b></a>
 &nbsp; 
<a href="#SEC40_19" class="summary-letter"><b>J</b></a>
 &nbsp; 
<a href="#SEC40_20" class="summary-letter"><b>K</b></a>
 &nbsp; 
<a href="#SEC40_21" class="summary-letter"><b>L</b></a>
 &nbsp; 
<a href="#SEC40_22" class="summary-letter"><b>M</b></a>
 &nbsp; 
<a href="#SEC40_23" class="summary-letter"><b>N</b></a>
 &nbsp; 
<a href="#SEC40_24" class="summary-letter"><b>O</b></a>
 &nbsp; 
<a href="#SEC40_25" class="summary-letter"><b>P</b></a>
 &nbsp; 
<a href="#SEC40_26" class="summary-letter"><b>Q</b></a>
 &nbsp; 
<a href="#SEC40_27" class="summary-letter"><b>R</b></a>
 &nbsp; 
<a href="#SEC40_28" class="summary-letter"><b>S</b></a>
 &nbsp; 
<a href="#SEC40_29" class="summary-letter"><b>T</b></a>
 &nbsp; 
<a href="#SEC40_30" class="summary-letter"><b>U</b></a>
 &nbsp; 
<a href="#SEC40_31" class="summary-letter"><b>V</b></a>
 &nbsp; 
<a href="#SEC40_32" class="summary-letter"><b>W</b></a>
 &nbsp; 
<a href="#SEC40_33" class="summary-letter"><b>Z</b></a>
 &nbsp; 
</td></tr></table>

<hr size="6">
<a name="SEC_Contents"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>Table of Contents</h1>
<div class="contents">

<ul class="toc">
  <li><a name="TOC1" href="#SEC1">1. Library Copying and Licensing Conditions</a></li>
  <li><a name="TOC2" href="#SEC2">2. Description of Features and How to Get Started</a>
  <ul class="toc">
    <li><a name="TOC3" href="#SEC3">2.1 How to Install the Library</a></li>
    <li><a name="TOC4" href="#SEC4">2.2 Getting Started with the Library</a></li>
    <li><a name="TOC5" href="#SEC5">2.3 Basic Description of Terms and Functions</a>
    <ul class="toc">
      <li><a name="TOC6" href="#SEC6">2.3.1 General Memory Terms and Concepts</a></li>
      <li><a name="TOC7" href="#SEC7">2.3.2 Functionality Supported by All Malloc Libraries</a></li>
    </ul></li>
    <li><a name="TOC8" href="#SEC8">2.4 General Features of the Library</a></li>
    <li><a name="TOC9" href="#SEC9">2.5 How the Library Checks Your Program</a></li>
  </ul></li>
  <li><a name="TOC10" href="#SEC10">3. How to Program with the Library</a>
  <ul class="toc">
    <li><a name="TOC11" href="#SEC11">3.1 Macros Providing File and Line Information</a></li>
    <li><a name="TOC12" href="#SEC12">3.2 Getting Caller Address Information</a></li>
    <li><a name="TOC13" href="#SEC13">3.3 Checking of Function Arguments</a></li>
    <li><a name="TOC14" href="#SEC14">3.4 Generating a Core File on Errors</a></li>
    <li><a name="TOC15" href="#SEC15">3.5 Additional Non-standard Routines</a></li>
    <li><a name="TOC16" href="#SEC16">3.6 Description of the Internal Error Codes</a></li>
    <li><a name="TOC17" href="#SEC17">3.7 How to Disable the library</a></li>
    <li><a name="TOC18" href="#SEC18">3.8 Using the Library with C++</a></li>
    <li><a name="TOC19" href="#SEC19">3.9 Using Dmalloc With a Debugger</a>
    <ul class="toc">
      <li><a name="TOC20" href="#SEC20">3.9.1 Diagnosing General Problems with a Debugger</a></li>
      <li><a name="TOC21" href="#SEC21">3.9.2 Tracking Down Non-Freed Memory</a></li>
      <li><a name="TOC22" href="#SEC22">3.9.3 Diagnosing Fence-Post Overwritten Memory</a></li>
      <li><a name="TOC23" href="#SEC23">3.9.4 Translating Return Addresses into Code Locations</a></li>
    </ul></li>
    <li><a name="TOC24" href="#SEC24">3.10 Using the Library with a Thread Package</a></li>
    <li><a name="TOC25" href="#SEC25">3.11 Using the library with Cygwin environment.</a></li>
    <li><a name="TOC26" href="#SEC26">3.12 Debugging Memory in a Server or Cgi-Bin Process</a></li>
    <li><a name="TOC27" href="#SEC27">3.13 Explanation of the Logfile Output</a></li>
    <li><a name="TOC28" href="#SEC28">3.14 Various Other Hints That May Help</a></li>
  </ul></li>
  <li><a name="TOC29" href="#SEC29">4. Dmalloc Utility Program</a>
  <ul class="toc">
    <li><a name="TOC30" href="#SEC30">4.1 Using a Shell Alias with the Utility</a></li>
    <li><a name="TOC31" href="#SEC31">4.2 How to Use the Dmalloc Program</a></li>
    <li><a name="TOC32" href="#SEC32">4.3 Environment Variable Name and Features</a></li>
    <li><a name="TOC33" href="#SEC33">4.4 Description of the Debugging Tokens</a></li>
    <li><a name="TOC34" href="#SEC34">4.5 Format of the Runtime Configuration File</a></li>
  </ul></li>
  <li><a name="TOC35" href="#SEC35">5. Information on the Source Code</a>
  <ul class="toc">
    <li><a name="TOC36" href="#SEC36">5.1 Definition of Terms and other Information</a></li>
    <li><a name="TOC37" href="#SEC37">5.2 General Compatibility Concerns</a></li>
    <li><a name="TOC38" href="#SEC38">5.3 Issues Important for Porting the Library</a></li>
  </ul></li>
  <li><a name="TOC39" href="#SEC39">6. Some Solutions to Common Problems</a></li>
  <li><a name="TOC40" href="#SEC40">Index of Concepts</a></li>
</ul>
</div>
<hr size="1">
<a name="SEC_About"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>About This Document</h1>
<p>
  This document was generated by <em>Gray Watson</em> on <em>May, 14 2007</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
</p>
<p>
  The buttons in the navigation panels have the following meaning:
</p>
<table border="1">
  <tr>
    <th> Button </th>
    <th> Name </th>
    <th> Go to </th>
    <th> From 1.2.3 go to</th>
  </tr>
  <tr>
    <td align="center"> [ &lt; ] </td>
    <td align="center">Back</td>
    <td>previous section in reading order</td>
    <td>1.2.2</td>
  </tr>
  <tr>
    <td align="center"> [ &gt; ] </td>
    <td align="center">Forward</td>
    <td>next section in reading order</td>
    <td>1.2.4</td>
  </tr>
  <tr>
    <td align="center"> [ &lt;&lt; ] </td>
    <td align="center">FastBack</td>
    <td>beginning of this chapter or previous chapter</td>
    <td>1</td>
  </tr>
  <tr>
    <td align="center"> [ Up ] </td>
    <td align="center">Up</td>
    <td>up section</td>
    <td>1.2</td>
  </tr>
  <tr>
    <td align="center"> [ &gt;&gt; ] </td>
    <td align="center">FastForward</td>
    <td>next chapter</td>
    <td>2</td>
  </tr>
  <tr>
    <td align="center"> [Top] </td>
    <td align="center">Top</td>
    <td>cover (top) of document</td>
    <td> &nbsp; </td>
  </tr>
  <tr>
    <td align="center"> [Contents] </td>
    <td align="center">Contents</td>
    <td>table of contents</td>
    <td> &nbsp; </td>
  </tr>
  <tr>
    <td align="center"> [Index] </td>
    <td align="center">Index</td>
    <td>index</td>
    <td> &nbsp; </td>
  </tr>
  <tr>
    <td align="center"> [ ? ] </td>
    <td align="center">About</td>
    <td>about (help)</td>
    <td> &nbsp; </td>
  </tr>
</table>

<p>
  where the <strong> Example </strong> assumes that the current position is at <strong> Subsubsection One-Two-Three </strong> of a document of the following structure:
</p>

<ul>
  <li> 1. Section One
    <ul>
      <li>1.1 Subsection One-One
        <ul>
          <li>...</li>
        </ul>
      </li>
      <li>1.2 Subsection One-Two
        <ul>
          <li>1.2.1 Subsubsection One-Two-One</li>
          <li>1.2.2 Subsubsection One-Two-Two</li>
          <li>1.2.3 Subsubsection One-Two-Three &nbsp; &nbsp;
            <strong>&lt;== Current Position </strong></li>
          <li>1.2.4 Subsubsection One-Two-Four</li>
        </ul>
      </li>
      <li>1.3 Subsection One-Three
        <ul>
          <li>...</li>
        </ul>
      </li>
      <li>1.4 Subsection One-Four</li>
    </ul>
  </li>
</ul>

<hr size="1">
<p>
 <font size="-1">
  This document was generated by <em>Gray Watson</em> on <em>May, 14 2007</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>