Hi! We have encountered the following problem with a recent version of GLIBC2.3.3 on Debian/sarge. The short C++ program attached hangs occasionally on calls to new and returns only after minutes of consuming almost 100% cpu time. The program does not make sense for itself. It is a stripped version of a larger research program, but reproduces the bug consistently on our systems.
In addition to the runs on GLIBC2.3.3 we did comparative tests on Debian/woody using a GLIBC2.2.5 where the hang does not occur at all. What we already debugged: 1. We added printing malloc statistics derived through mallinfo() which does not affect the occcurence of the hang, but gives us different output for GLIBC2.3.3 and GLIBC2.2.5 systems. The outputs of both runs are also attached. 2. As the statistics from mallinfo reveiled differences mainly in the top padding size, we experimented with changing the default M_TOP_PAD value. For smaller values the hangs occur more often and for large values (> 1024*1024) they do not occur at all on the GLIBC2.3.3 system. There is no change on the GLIBC2.2.5 system. Overall (real) times for the two runs: GLIBC2.2.5 32.217s GLIBC2.3.3 6m12.788s We haven't found anything on the web concerning this behaviour. Is this a bug only on Debian systems? Unfortunately, we don't have any other distribution installed to test it on. It would be nice to test at least different versions of GLIBC between 2.2.5 and 2.3.3. Cheers, Stephan Kanthak and Andras Zolnay -- _____________________________________________________________________________ Dipl.-Inform. Stephan Kanthak Tel +49 241 8021620 Department of Computer Science VI, RWTH Aachen, Germany Fax +49 241 8022219 Prof. Dr.-Ing. Hermann Ney e-mail: [EMAIL PROTECTED] _____________________________________________________________________________
#include <vector> #include <fstream> #include <cstdio> #include <malloc.h> void readBuffer(int n, float* &buffer) { // Comment out the file creation and it will not hang anymore ... std::fstream f("hang.cc", std::ios::in | std::ios::binary); if (!f.is_open()) printf("Could not open file!!.\n"); // move out the next line after the call tp readBuffer and it does not hang ... buffer = new float[n * 33]; } template<class T> class PointerVector { private: std::vector<T*> pointers_; public: PointerVector(size_t size = 0) : pointers_(size, 0) {} ~PointerVector() { clear(); } void pushBack(T *newObject) { pointers_.push_back(newObject); } void clear() { for(size_t i = 0; i < pointers_.size(); ++ i) delete pointers_[i]; pointers_.clear(); } }; class OneVector { std::vector<float> vector_; public: OneVector() { vector_ = std::vector<float>(33); } OneVector(const std::vector<float> &v) : vector_(v) {} }; class TwoInts { private: int one_; int two_; public: TwoInts() {} }; class Temporary { PointerVector<OneVector> vectors_; PointerVector<TwoInts> twoInts_; public: Temporary() { int n = 300000; float* buffer = 0; readBuffer(n, buffer); for(size_t j = 0; j < n; ++ j) { // increase 33->34 and it does not hang anymore ... vectors_.pushBack(new OneVector(std::vector<float>(33))); // Activate next line and it does not hang anymore ... //vectors_.pushBack(new OneVector(std::vector<float>(33))); twoInts_.pushBack(new TwoInts()); } // Activate the following two lines the hang disappears. // vectors_.clear(); // twoInts_.clear(); delete[] buffer; } }; class Persistent { private: std::vector<float> table_; public: Persistent() { table_.resize(1000000); } }; int main(int argc, char *argv[]) { // we investigated different settings for M_TOP_PAD: // on GLIBC2.2.5 system the program does not hang for any value // on GLIBC2.3.3 system the program hangs more often for smaller values // and definitely never for a size of 1024*1024 // //mallopt(M_TOP_PAD, 0); //mallopt(M_TOP_PAD, 128*1024); // default for GLIBC2.3.3 on debian sarge //mallopt(M_TOP_PAD, 1024*1024); std::vector<Persistent*> p(50); for(size_t i = 0; i < p.size(); ++ i) { printf("Allocation %d.\n", i); Temporary *t = new Temporary(); struct mallinfo tmp = mallinfo(); printf("%d %d %d %d %d %d %d %d %d %d\n", tmp.arena, tmp.ordblks, tmp.smblks, tmp.hblks, tmp.hblkhd, tmp.usmblks, tmp.fsmblks, tmp.uordblks, tmp.fordblks, tmp.keepcost); p[i] = new Persistent(); delete t; } for(size_t i = 0; i < p.size(); ++ i) delete p[i]; return 0; }
hang
Description: Binary data
Allocation 0. 51004460 3 0 2 4202496 0 0 51004108 352 112 Allocation 1. 90473516 4 0 3 8204288 0 0 50871636 39601880 1648 Allocation 2. 94053420 3 0 3 8204288 0 0 54449420 39604000 3872 Allocation 3. 98055212 4 0 3 8204288 0 0 58454460 39600752 568 Allocation 4. 98055212 23 0 1 4001792 0 0 66601676 31453536 1680 Allocation 5. 98055212 22 0 1 4001792 0 0 70601708 27453504 1680 Allocation 6. 98055212 21 0 1 4001792 0 0 74601748 23453464 1680 Allocation 7. 98055212 16 0 1 4001792 0 0 78601796 19453416 1680 Allocation 8. 98055212 17 0 1 4001792 0 0 82601812 15453400 1680 Allocation 9. 98055212 17 0 1 4001792 0 0 86601844 11453368 1680 Allocation 10. 98055212 20 0 1 4001792 0 0 90601852 7453360 1680 Allocation 11. 98055212 25 0 1 4001792 0 0 94601836 3453376 1680 Allocation 12. 98055212 23 0 2 8003584 0 0 94601876 3453336 1680 Allocation 13. 98055212 23 0 3 12005376 0 0 94601908 3453304 1680 Allocation 14. 98055212 24 0 4 16007168 0 0 94601908 3453304 1680 Allocation 15. 98055212 26 0 5 20008960 0 0 94601924 3453288 1680 Allocation 16. 98055212 27 0 6 24010752 0 0 94601940 3453272 1680 Allocation 17. 98055212 26 0 7 28012544 0 0 94601964 3453248 1680 Allocation 18. 98055212 24 0 8 32014336 0 0 94602004 3453208 1680 Allocation 19. 98055212 23 0 9 36016128 0 0 94602020 3453192 1680 Allocation 20. 98055212 21 0 10 40017920 0 0 94602036 3453176 1680 Allocation 21. 98055212 20 0 11 44019712 0 0 94602060 3453152 1680 Allocation 22. 98055212 20 0 12 48021504 0 0 94602076 3453136 1680 Allocation 23. 98055212 22 0 13 52023296 0 0 94602076 3453136 1680 Allocation 24. 98055212 25 0 14 56025088 0 0 94602092 3453120 1680 Allocation 25. 98055212 23 0 15 60026880 0 0 94602116 3453096 1680 Allocation 26. 98055212 23 0 16 64028672 0 0 94602132 3453080 1680 Allocation 27. 98055212 21 0 17 68030464 0 0 94602172 3453040 1680 Allocation 28. 98055212 21 0 18 72032256 0 0 94602180 3453032 1680 Allocation 29. 98055212 28 0 19 76034048 0 0 94602164 3453048 1680 Allocation 30. 98055212 31 0 20 80035840 0 0 94602156 3453056 1680 Allocation 31. 98055212 30 0 21 84037632 0 0 94602188 3453024 1680 Allocation 32. 98055212 29 0 22 88039424 0 0 94602220 3452992 1680 Allocation 33. 98055212 28 0 23 92041216 0 0 94602244 3452968 1680 Allocation 34. 98055212 30 0 24 96043008 0 0 94602276 3452936 1680 Allocation 35. 98055212 30 0 25 100044800 0 0 94602284 3452928 1680 Allocation 36. 98055212 28 0 26 104046592 0 0 94602300 3452912 1680 Allocation 37. 98055212 28 0 27 108048384 0 0 94602316 3452896 1680 Allocation 38. 98055212 27 0 28 112050176 0 0 94602340 3452872 1680 Allocation 39. 98055212 27 0 29 116051968 0 0 94602372 3452840 1680 Allocation 40. 98055212 26 0 30 120053760 0 0 94602388 3452824 1680 Allocation 41. 98055212 26 0 31 124055552 0 0 94602396 3452816 1680 Allocation 42. 98055212 28 0 32 128057344 0 0 94602412 3452800 1680 Allocation 43. 98055212 30 0 33 132059136 0 0 94602404 3452808 1680 Allocation 44. 98055212 34 0 34 136060928 0 0 94602420 3452792 1680 Allocation 45. 98055212 39 0 35 140062720 0 0 94602396 3452816 1680 Allocation 46. 98055212 38 0 36 144064512 0 0 94602428 3452784 1680 Allocation 47. 98055212 38 0 37 148066304 0 0 94602444 3452768 1680 Allocation 48. 98055212 38 0 38 152068096 0 0 94602460 3452752 1680 Allocation 49. 98055212 38 0 39 156069888 0 0 94602476 3452736 1680
Allocation 0. 51007488 2 0 2 4202496 0 0 51007120 368 248 Allocation 1. 90607616 4 0 3 8204288 0 0 51007112 39600504 272 Allocation 2. 94609408 4 0 3 8204288 0 0 55007120 39602288 2104 Allocation 3. 98611200 4 0 3 8204288 0 0 59007144 39604056 3888 Allocation 4. 98611200 4 0 1 4001792 0 0 67201504 31409696 4976 Allocation 5. 98611200 4 0 1 4001792 0 0 71201544 27409656 4976 Allocation 6. 98611200 4 0 1 4001792 0 0 75201528 23409672 4976 Allocation 7. 98611200 3 0 1 4001792 0 0 79201552 19409648 4976 Allocation 8. 98611200 4 0 1 4001792 0 0 83201568 15409632 4976 Allocation 9. 98611200 4 0 1 4001792 0 0 87201656 11409544 4976 Allocation 10. 98611200 4 0 1 4001792 0 0 91201672 7409528 4976 Allocation 11. 98611200 4 0 1 4001792 0 0 95201672 3409528 4976 Allocation 12. 98611200 4 0 2 8003584 0 0 95201712 3409488 4976 Allocation 13. 98611200 4 0 3 12005376 0 0 95201712 3409488 4976 Allocation 14. 98611200 4 0 4 16007168 0 0 95201712 3409488 4976 Allocation 15. 98611200 4 0 5 20008960 0 0 95201752 3409448 4976 Allocation 16. 98611200 3 0 6 24010752 0 0 95201800 3409400 4976 Allocation 17. 98611200 3 0 7 28012544 0 0 95201792 3409408 4976 Allocation 18. 98611200 4 0 8 32014336 0 0 95201840 3409360 4976 Allocation 19. 98611200 4 0 9 36016128 0 0 95201840 3409360 4976 Allocation 20. 98611200 4 0 10 40017920 0 0 95201816 3409384 4976 Allocation 21. 98611200 4 0 11 44019712 0 0 95201872 3409328 4976 Allocation 22. 98611200 4 0 12 48021504 0 0 95201888 3409312 4976 Allocation 23. 98611200 4 0 13 52023296 0 0 95201888 3409312 4976 Allocation 24. 98611200 4 0 14 56025088 0 0 95201856 3409344 4976 Allocation 25. 98611200 3 0 15 60026880 0 0 95201880 3409320 4976 Allocation 26. 98611200 4 0 16 64028672 0 0 95201832 3409368 4976 Allocation 27. 98611200 4 0 17 68030464 0 0 95201920 3409280 4976 Allocation 28. 98611200 3 0 18 72032256 0 0 95201968 3409232 4976 Allocation 29. 98611200 4 0 19 76034048 0 0 95201936 3409264 4976 Allocation 30. 98611200 3 0 20 80035840 0 0 95201976 3409224 4976 Allocation 31. 98611200 4 0 21 84037632 0 0 95201936 3409264 4976 Allocation 32. 98611200 4 0 22 88039424 0 0 95201968 3409232 4976 Allocation 33. 98611200 4 0 23 92041216 0 0 95202032 3409168 4976 Allocation 34. 98611200 4 0 24 96043008 0 0 95202064 3409136 4976 Allocation 35. 98611200 3 0 25 100044800 0 0 95202008 3409192 4976 Allocation 36. 98611200 4 0 26 104046592 0 0 95202048 3409152 4976 Allocation 37. 98611200 4 0 27 108048384 0 0 95202048 3409152 4976 Allocation 38. 98611200 3 0 28 112050176 0 0 95202008 3409192 4976 Allocation 39. 98611200 4 0 29 116051968 0 0 95202040 3409160 4976 Allocation 40. 98611200 4 0 30 120053760 0 0 95202032 3409168 4976 Allocation 41. 98611200 4 0 31 124055552 0 0 95202000 3409200 4976 Allocation 42. 98611200 3 0 32 128057344 0 0 95202072 3409128 4976 Allocation 43. 98611200 4 0 33 132059136 0 0 95202016 3409184 4976 Allocation 44. 98611200 4 0 34 136060928 0 0 95202136 3409064 4976 Allocation 45. 98611200 3 0 35 140062720 0 0 95202072 3409128 4976 Allocation 46. 98611200 4 0 36 144064512 0 0 95202144 3409056 4976 Allocation 47. 98611200 4 0 37 148066304 0 0 95202176 3409024 4976 Allocation 48. 98611200 4 0 38 152068096 0 0 95202152 3409048 4976 Allocation 49. 98611200 4 0 39 156069888 0 0 95202208 3408992 4976