alelievr / libft-unit-test

455 stars 88 forks source link

ft_lstdelone segmentation violation #55

Closed andreevgy closed 3 years ago

andreevgy commented 5 years ago

Was testing this function:

#include "libft.h"

void ft_lstdelone(t_list **alst, void (*del)(void *, size_t))
{
    del((*alst)->content, (*alst)->content_size);
    free(*alst);
    *alst = NULL;
}

Tests crashed with this message:

ft_lstdelone:  [OK] [SIGSEGV]: segmentation violation
OMG you crashed my program, please report this bug to @alelievr !
thanks

However jtoty/Libftest works well with it.

I'm running all of this in WSL (Windows Subsystem for Linux) with Ubuntu 18.04. Can provide more info if you need.

alelievr commented 5 years ago

Hi, I can't reproduce the issue on OSX, can you uncomment the -ggdb -fsanitize=address in the Makefile at line 74, make re the test and run./assets/libtests lstdelone ? Thanks for your bug report.

andreevgy commented 5 years ago

There's output

 /~~~\/~~\/~~~\/~~~\/~~\/~~~\                    /~~~\/~~\/~~~\/~~~\/~~\/~~~\
 | /\/ /\/ /\ || /\/ /\/ /\ |                    | /\ \/\ \/\ || /\ \/\ \/\ |
  \ \/ /\/ /\/ /\ \/ /\/ /\/ /     Bonus part     \ \/\ \/\ \/ /\ \/\ \/\ \/ /
   \ \/\ \/\ \/  \ \/\ \/\ \/                      \/ /\/ /\/ /  \/ /\/ /\/ /
,_/\ \/\ \/\ \__/\ \/\ \/\ \______________________/ /\/ /\/ /\__/ /\/ /\/ /\_,
(__/\__/\__/\____/\__/\__/\________________________/\__/\__/\____/\__/\__/\__)

ft_lstdelone:  [OK] AddressSanitizer:DEADLYSIGNAL
=================================================================
==1052==ERROR: AddressSanitizer: SEGV on unknown address 0x7fa900000000 (pc 0x0000005aa6bd bp 0x7fffdccce4d0 sp 0x7fffdccbe0e0 T0)
==1052==The signal is caused by a READ memory access.
    #0 0x5aa6bc  (/mnt/c/Users/gleba/Projects/libft-unit-test/assets/libtests+0x5aa6bc)
    #1 0x513b90  (/mnt/c/Users/gleba/Projects/libft-unit-test/assets/libtests+0x513b90)
    #2 0x5149af  (/mnt/c/Users/gleba/Projects/libft-unit-test/assets/libtests+0x5149af)
    #3 0x7fa9ec9a1b96  (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #4 0x41ac39  (/mnt/c/Users/gleba/Projects/libft-unit-test/assets/libtests+0x41ac39)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/mnt/c/Users/gleba/Projects/libft-unit-test/assets/libtests+0x5aa6bc)
==1052==ABORTING
alelievr commented 5 years ago

Okay, so by seeing this stacktrace, i can tell that it's not you lstdelone that causes the segfault but something at the end of the test (probably in the final display). To verify this i'll need a better stacktrace, sorry to bother you again but can you run the ./assets/libtests lstdelone inside gdb and print the stacktrace as well as the assembly dump when the program is crashed ?

DontPanicKristinaIsHere commented 5 years ago

I also have the same crash: Tested this function (most likely it is not correct) on WSL:

#include "libft.h"

void    ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
    del(*alst, (*alst)->content_size);
}

Get this error:

ft_lstdel:     [FAILED] [SIGSEGV]: segmentation violation
OMG you crashed my program, please report this bug to @alelievr !
thanks
DontPanicKristinaIsHere commented 5 years ago

Oh, it should be ft_lstdelone(), not a ft_lstdel() !!!

alelievr commented 3 years ago

Hello, I fixed a crash in this commit that was happening near the list test functions: https://github.com/alelievr/libft-unit-test/commit/c760077a99a3dbcfb8b5cfbf4b61e589cd8fa92b

I'll close this issue for now but if the crash is still happening, please re-open it :)

OlejnikKristina commented 3 years ago

Thank you @alelievr. Pretty sure it will be helpful for the future generation of 42 students.