Giter Site home page Giter Site logo

segmentation fault in test_avl.c about dslib HOT 3 CLOSED

jarun avatar jarun commented on May 31, 2024
segmentation fault in test_avl.c

from dslib.

Comments (3)

jarun avatar jarun commented on May 31, 2024

A more detailed report from address sanitizer.

Ran the tests under ASan, UBSan, and TSan:

cc -g -fsanitize=address,undefined -Iinclude src/*.c test/test_queue_1.c

ERROR: AddressSanitizer: stack-buffer-overflow
READ of size 4
    #0 0x558e591d44ad in main test/test_queue_1.c:52

The queue returns a garbage value, resulting in a stack overflow during the test.

cc -g -fsanitize=address,undefined -Iinclude src/*.c test/test_stack_1.c

ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #1 0x55a7247d3f48 in get_stack src/stack.c:29
    #2 0x55a7247d72c6 in main test/test_stack_1.c:33

Indirect leak of 8 byte(s) in 1 object(s) allocated from:
    #1 0x55a7247d3f5b in get_stack src/stack.c:31
    #2 0x55a7247d72c6 in main test/test_stack_1.c:33

SUMMARY: AddressSanitizer: 16 byte(s) leaked in 2 allocation(s).

There's a memory leak in the stack. The first head element is somehow lost and never freed.

cc -g -fsanitize=address,undefined -Iinclude src/*.c test/test_avl_1.c

ERROR: AddressSanitizer: heap-use-after-free
READ of size 8
    #0 0x55d69df5ce7c in destroy_queue src/queue.c:82
    #1 0x55d69df58e65 in search_BFS_avl src/avl.c:573
    #2 0x55d69df607ee in main test/test_avl_1.c:50

freed by thread T0 here:
    #1 0x55d69df5cefb in destroy_queue src/queue.c:86
    #2 0x55d69df58708 in search_BFS_avl src/avl.c:533
    #3 0x55d69df607ee in main test/test_avl_1.c:50

previously allocated by thread T0 here:
    #1 0x55d69df5cb5e in get_queue src/queue.c:29
    #2 0x55d69df584a8 in search_BFS_avl src/avl.c:515
    #3 0x55d69df607ee in main test/test_avl_1.c:50

The AVL tree has a use-after-free defect. Queues are being destroyed twice.

from dslib.

jarun avatar jarun commented on May 31, 2024

First 2 fixed on master. Yet to check the 3rd one.

from dslib.

jarun avatar jarun commented on May 31, 2024

Fixed at commit 58fb92c.

from dslib.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.