dimanche 31 décembre 2017

Corruption and core dump when using specific parameter

I'm benchmarking the use of Memory Pools, Vector and LinkedList for containing and iterating over a number of objects. I get the number of objects with std::cin and place it in an integer. Up to this point there's no error. Yet when the number I input equals 1000 it gives the next error:

Structure of main:

int main()
{
    std::clock_t start;
    double listAvg = 0.0;
    double poolAvg = 0.0;
    double vecAvg = 0.0;

    int num;
    std::cin >> num;

    for(int i=0; i++ < 30)
    {
        start = std::clock();
        listTest(num);
        listAvg += ((std::clock() - start)/(double)(CLOCKS_PER_SEC/1000));
        start = std::clock();
        poolTest(num);
        poolAvg += ((std::clock() - start)/(double)(CLOCKS_PER_SEC/1000));
        start = std::clock();
        vecTest(num);
        vecAvg += ((std::clock() - start)/(double)(CLOCKS_PER_SEC/1000));
    }
}


    Number of objects: 1000
    * * * Error in `./main': double free or corruption (out): 0x0000000000c86940 * * *
    ======= Backtrace: =========
    /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f6efd4bb7e5]
    /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f6efd4c437a]
    /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f6efd4c853c]
    ./main[0x4024ab]
    ./main[0x402bd1]
    ./main[0x402840]
    ./main[0x40427e]
    ./main[0x4046f9]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f6efd464830]
    ./main[0x401449]
    ======= Memory map: ========
    00400000-00409000 r-xp 00000000 08:06 1876578                            /home/ * /main
    00608000-00609000 r--p 00008000 08:06 1876578                            /home/ * /main
    00609000-0060a000 rw-p 00009000 08:06 1876578                                /home/ * /main
    00c5d000-00c8f000 rw-p 00000000 00:00 0                                  [heap]
    7f6ef8000000-7f6ef8021000 rw-p 00000000 00:00 0 
    7f6ef8021000-7f6efc000000 ---p 00000000 00:00 0 
    7f6efd444000-7f6efd604000 r-xp 00000000 08:05 1834632                    /lib/x86_64-linux-gnu/libc-2.23.so
    7f6efd604000-7f6efd804000 ---p 001c0000 08:05 1834632                    /lib/x86_64-linux-gnu/libc-2.23.so
    7f6efd804000-7f6efd808000 r--p 001c0000 08:05 1834632                    /lib/x86_64-linux-gnu/libc-2.23.so
    7f6efd808000-7f6efd80a000 rw-p 001c4000 08:05 1834632                    /lib/x86_64-linux-gnu/libc-2.23.so
    7f6efd80a000-7f6efd80e000 rw-p 00000000 00:00 0 
    7f6efd80e000-7f6efd824000 r-xp 00000000 08:05 1836566                    /lib/x86_64-linux-gnu/libgcc_s.so.1
    7f6efd824000-7f6efda23000 ---p 00016000 08:05 1836566                    /lib/x86_64-linux-gnu/libgcc_s.so.1
    7f6efda23000-7f6efda24000 rw-p 00015000 08:05 1836566                    /lib/x86_64-linux-gnu/libgcc_s.so.1
    7f6efda24000-7f6efdb2c000 r-xp 00000000 08:05 1834622                    /lib/x86_64-linux-gnu/libm-2.23.so
    7f6efdb2c000-7f6efdd2b000 ---p 00108000 08:05 1834622                    /lib/x86_64-linux-gnu/libm-2.23.so
    7f6efdd2b000-7f6efdd2c000 r--p 00107000 08:05 1834622                    /lib/x86_64-linux-gnu/libm-2.23.so
    7f6efdd2c000-7f6efdd2d000 rw-p 00108000 08:05 1834622                    /lib/x86_64-linux-gnu/libm-2.23.so
    7f6efdd2d000-7f6efde9f000 r-xp 00000000 08:05 656317                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
    7f6efde9f000-7f6efe09f000 ---p 00172000 08:05 656317                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
    7f6efe09f000-7f6efe0a9000 r--p 00172000 08:05 656317                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
    7f6efe0a9000-7f6efe0ab000 rw-p 0017c000 08:05 656317                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
    7f6efe0ab000-7f6efe0af000 rw-p 00000000 00:00 0 
    7f6efe0af000-7f6efe0d5000 r-xp 00000000 08:05 1834593                    /lib/x86_64-linux-gnu/ld-2.23.so
    7f6efe2a4000-7f6efe2a9000 rw-p 00000000 00:00 0 
    7f6efe2d1000-7f6efe2d4000 rw-p 00000000 00:00 0 
    7f6efe2d4000-7f6efe2d5000 r--p 00025000 08:05 1834593                    /lib/x86_64-linux-gnu/ld-2.23.so
    7f6efe2d5000-7f6efe2d6000 rw-p 00026000 08:05 1834593                        /lib/x86_64-linux-gnu/ld-2.23.so
    7f6efe2d6000-7f6efe2d7000 rw-p 00000000 00:00 0 
    7ffea1d71000-7ffea1d93000 rw-p 00000000 00:00 0                          [stack]
    7ffea1dc9000-7ffea1dcb000 r--p 00000000 00:00 0                          [vvar]
    7ffea1dcb000-7ffea1dcd000 r-xp 00000000 00:00 0                          [vdso]
    ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
    Aborted (core dumped)
The asterisk is the path to the main executable.

It works with any other number of objects, even bigger ones.

Aucun commentaire:

Enregistrer un commentaire