ScandalousMan / RT

Ray Tracing group project for School 42
0 stars 0 forks source link

Segfault on free_objects #59

Closed Its-Alex closed 6 years ago

Its-Alex commented 6 years ago

With scene adrien-48 I have a segfault in fix-ui-leaks

RT(703,0x7fff936f3380) malloc: *** error for object 0x10290f750: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Process 703 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff5ad2fb66 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff5ad2fb66 <+10>: jae    0x7fff5ad2fb70            ; <+20>
    0x7fff5ad2fb68 <+12>: movq   %rax, %rdi
    0x7fff5ad2fb6b <+15>: jmp    0x7fff5ad26ae9            ; cerror_nocancel
    0x7fff5ad2fb70 <+20>: retq
Target 0: (RT) stopped.
(lldb) fr s 1
frame #1: 0x00007fff5aefa080 libsystem_pthread.dylib`pthread_kill + 333
libsystem_pthread.dylib`pthread_kill:
    0x7fff5aefa080 <+333>: movl   %eax, %r15d
    0x7fff5aefa083 <+336>: cmpl   $-0x1, %r15d
    0x7fff5aefa087 <+340>: jne    0x7fff5aefa091            ; <+350>
    0x7fff5aefa089 <+342>: callq  0x7fff5aefd12c            ; symbol stub for: __error
(lldb) fr s 2
frame #2: 0x00007fff5ac8b1ae libsystem_c.dylib`abort + 127
libsystem_c.dylib`abort:
    0x7fff5ac8b1ae <+127>: movl   $0x2710, %edi             ; imm = 0x2710
    0x7fff5ac8b1b3 <+132>: callq  0x7fff5ac5d728            ; usleep$NOCANCEL
    0x7fff5ac8b1b8 <+137>: callq  0x7fff5ac8b1bd            ; __abort

libsystem_c.dylib`__abort:
    0x7fff5ac8b1bd <+0>:   cmpq   $0x0, 0x38a44fa3(%rip)    ; gCRAnnotations + 7
(lldb) fr s 3
frame #3: 0x00007fff5ad89822 libsystem_malloc.dylib`free + 521
libsystem_malloc.dylib`free:
    0x7fff5ad89822 <+521>: nop
    0x7fff5ad89823 <+522>: nop
    0x7fff5ad89824 <+523>: nop

libsystem_malloc.dylib`szone_size:
    0x7fff5ad89825 <+0>:   pushq  %rbx
(lldb) fr s 4
frame #4: 0x0000000100004427 RT`free_objects(param=0x0000000114fa0000) at key_func.c:46
   43           while (param->objects->limits)
   44           {
   45               l_tmp = param->objects->limits->next;
-> 46               free(param->objects->limits);
   47               param->objects->limits = l_tmp;
   48           }
   49           free(param->objects);
(lldb) fr s 5
frame #5: 0x0000000100064c6e RT`launch_threads(param=0x0000000100429000) at threads.c:127
   124          mprintf(1, "Free param_cpy %d\n", count);
   125          free_path(params[count]->path);
   126          free_lights(params[count]->lights);
-> 127          free_objects(params[count]);
   128          free(params[count]);
   129          ++count;
   130      }
(lldb)
Its-Alex commented 6 years ago

Fixed by https://github.com/ScandalousMan/RT/pull/58/commits/803214a32eebb1ec54f2daee9904f27b476ae167#diff-fb07597d7d7040a6ce130c20f5522ed6R12

Its-Alex commented 6 years ago

Fixed