fork download
  1. #include "stdio.h"
  2. #include "malloc.h"
  3.  
  4.  
  5. struct rib
  6. {
  7. int from;
  8. int to;
  9. int weight;
  10. };
  11.  
  12. int main(int argc, char const *argv[])
  13. {
  14. struct rib *incidental;
  15.  
  16. for (int i = 0; i < 12; ++i)
  17. {
  18. incidental = NULL;
  19. for (int j = 0; j < 3; ++j)
  20. {
  21. printf("ok %i\n", j);
  22. incidental = (struct rib*)realloc(incidental, sizeof(struct rib));
  23. incidental[j].from = j+1;
  24. incidental[j].to = (j+1)*2;
  25. incidental[j].weight = (j+1)*4;
  26. }
  27.  
  28. for (int k = 0; k < 3; ++k)
  29. {
  30. printf(" %i-%i=%i\n", incidental[k].from, incidental[k].to, incidental[k].weight);
  31. }
  32. }
  33.  
  34.  
  35. }
Runtime error #stdin #stdout #stderr 0s 77120KB
stdin
Standard input is empty
stdout
ok 0
ok 1
ok 2
 1-2=4
 2-4=8
 3-6=12
ok 0
ok 1
stderr
*** Error in `./prog': realloc(): invalid next size: 0x00002ab901db0040 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bcb)[0x2ab900711bcb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76f96)[0x2ab900717f96]
/lib/x86_64-linux-gnu/libc.so.6(+0x79f6c)[0x2ab90071af6c]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0x159)[0x2ab90071c539]
./prog(+0x62b)[0x2ab8ffd5862b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x2ab9006c12b1]
./prog(+0x6ba)[0x2ab8ffd586ba]
======= Memory map: ========
2ab8ffd58000-2ab8ffd59000 r-xp 00000000 fd:00 18063362                   /home/al1ilG/prog
2ab8ffd59000-2ab8ffd5d000 rw-p 00000000 00:00 0 
2ab8ffd66000-2ab8ffd68000 rw-p 00000000 00:00 0 
2ab8fff58000-2ab8fff59000 r--p 00000000 fd:00 18063362                   /home/al1ilG/prog
2ab8fff59000-2ab8fff5a000 rw-p 00001000 fd:00 18063362                   /home/al1ilG/prog
2ab8fff5a000-2ab8fff7d000 r-xp 00000000 fd:00 5431394                    /lib/x86_64-linux-gnu/ld-2.24.so
2ab90017d000-2ab90017e000 r--p 00023000 fd:00 5431394                    /lib/x86_64-linux-gnu/ld-2.24.so
2ab90017e000-2ab90017f000 rw-p 00024000 fd:00 5431394                    /lib/x86_64-linux-gnu/ld-2.24.so
2ab90017f000-2ab900180000 rw-p 00000000 00:00 0 
2ab900180000-2ab900283000 r-xp 00000000 fd:00 5431423                    /lib/x86_64-linux-gnu/libm-2.24.so
2ab900283000-2ab900482000 ---p 00103000 fd:00 5431423                    /lib/x86_64-linux-gnu/libm-2.24.so
2ab900482000-2ab900483000 r--p 00102000 fd:00 5431423                    /lib/x86_64-linux-gnu/libm-2.24.so
2ab900483000-2ab900484000 rw-p 00103000 fd:00 5431423                    /lib/x86_64-linux-gnu/libm-2.24.so
2ab900484000-2ab90049c000 r-xp 00000000 fd:00 5431380                    /lib/x86_64-linux-gnu/libpthread-2.24.so
2ab90049c000-2ab90069b000 ---p 00018000 fd:00 5431380                    /lib/x86_64-linux-gnu/libpthread-2.24.so
2ab90069b000-2ab90069c000 r--p 00017000 fd:00 5431380                    /lib/x86_64-linux-gnu/libpthread-2.24.so
2ab90069c000-2ab90069d000 rw-p 00018000 fd:00 5431380                    /lib/x86_64-linux-gnu/libpthread-2.24.so
2ab90069d000-2ab9006a1000 rw-p 00000000 00:00 0 
2ab9006a1000-2ab900836000 r-xp 00000000 fd:00 5431517                    /lib/x86_64-linux-gnu/libc-2.24.so
2ab900836000-2ab900a35000 ---p 00195000 fd:00 5431517                    /lib/x86_64-linux-gnu/libc-2.24.so
2ab900a35000-2ab900a39000 r--p 00194000 fd:00 5431517                    /lib/x86_64-linux-gnu/libc-2.24.so
2ab900a39000-2ab900a3b000 rw-p 00198000 fd:00 5431517                    /lib/x86_64-linux-gnu/libc-2.24.so
2ab900a3b000-2ab900a3f000 rw-p 00000000 00:00 0 
2ab900a3f000-2ab900a55000 r-xp 00000000 fd:00 5431361                    /lib/x86_64-linux-gnu/libgcc_s.so.1
2ab900a55000-2ab900c54000 ---p 00016000 fd:00 5431361                    /lib/x86_64-linux-gnu/libgcc_s.so.1
2ab900c54000-2ab900c55000 r--p 00015000 fd:00 5431361                    /lib/x86_64-linux-gnu/libgcc_s.so.1
2ab900c55000-2ab900c56000 rw-p 00016000 fd:00 5431361                    /lib/x86_64-linux-gnu/libgcc_s.so.1
2ab901daf000-2ab901dd1000 rw-p 00000000 00:00 0                          [heap]
2ab904000000-2ab904021000 rw-p 00000000 00:00 0 
2ab904021000-2ab908000000 ---p 00000000 00:00 0 
7fffa38ca000-7fffa38eb000 rw-p 00000000 00:00 0                          [stack]
7fffa39ac000-7fffa39ae000 r-xp 00000000 00:00 0                          [vdso]
7fffa39ae000-7fffa39b0000 r--p 00000000 00:00 0                          [vvar]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]