Code Monkey home page Code Monkey logo

krusgen's People

Contributors

mazaczysko avatar

Watchers

 avatar  avatar

krusgen's Issues

Segmentation fault after running for a while

I wanted to profile Krusgen and after running for more than an hour it crashed.

$ sudo perf stat -B -e cache-references,cache-misses ./krusgen  -x 65533 -y 1023 > /dev/null
./krusgen: Segmentation fault

 Performance counter stats for './krusgen -x 65533 -y 1023':

   197 639 084 285      cache-references                                            
   118 016 289 503      cache-misses              #   59,713 % of all cache refs    

    4507,111402809 seconds time elapsed

By the way, the 60% cache miss rate isn't great.

Misleading error message

The error messages are misleading:

$ ./krusgen -x -y 9
./krusgen: bad value for -y

Here the value for -x is clearly the invalid one. It works the other way around too:

$ ./krusgen -y -x 9
./krusgen: bad value for -x

Weird error message

I think you broke something again

$ ./krusgen -x
./krusgen: bad value for ./krusgen

Crash on not-permitted file operations

Krusgen crashes when user tries to pick output file he/she doesn't have rights to modify create. Problem affects both -b and -t options, creating and modifying files.
This behavior is likely caused by missing exit() call on lines 95 and 111.

image

Mazes are identical

I cannot use krusgen to generate 100 mazes at once, because all of them turn out to be identical.
To reproduce:

mkdir mazes
for i in {1..100}; do ./krusgen -t mazes/$i.txt -x 15 -y 15; done;

Empty output files

When -t <filename> -h are both passed to Krusgen in that specific order, the output file is created before the help message appears. The output file contains no data, which is an unusual and unexpected behavior. This bug affects -b option too.
image

Things get even worse when both -b and -t options are used. Then program doesn't even output proper error message (krusgen: cannot export to .bmp and .txt files at once) and both files are created.
image

Identical mazes are generated

If I want to generate many labyrinths using a bash for loop, all of them are identical:

for i in {1..10}; do ./krusgen > "out/$i.txt"; done

This makes the program unusable in cases where more than one maze is needed. The program doesn't support multiple files output and produces unsatisfactory results when it's repeatedly called instead.

The memory leaks are still not fixed

Now it leaks even when no maze is generated.

$ ./krusgen -x 100 -y 100
./krusgen: dimensions must be odd!

=================================================================
==3335==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 800 byte(s) in 1 object(s) allocated from:
    #0 0x7f6443c7e639 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x562e620a32b0 in mazeInit (/home/j/Desktop/krusgen/krusgen+0x42b0)
    #2 0x562e620a16e5 in main (/home/j/Desktop/krusgen/krusgen+0x26e5)
    #3 0x7f6443a26b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

Indirect leak of 12400 byte(s) in 100 object(s) allocated from:
    #0 0x7f6443c7e639 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x562e620a32fd in mazeInit (/home/j/Desktop/krusgen/krusgen+0x42fd)
    #2 0x562e620a16e5 in main (/home/j/Desktop/krusgen/krusgen+0x26e5)
    #3 0x7f6443a26b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

SUMMARY: AddressSanitizer: 13200 byte(s) leaked in 101 allocation(s).

Did you actually check if you fixed the leaks or just thought you fixed them?

Crash caused by large dimensions

Krusgen crashes when given maze dimensions are too big. Affects both -x and -y options.
This behavior is likely caused by ignoring calloc errors returned by mazeInit routine.
Also, some reasonable upper maze size limit should be introduced.

image

odd number

who can I take in parameters odd and even size of maze
thanks

Unable to build

The provided makefile just doesn't work

cd libobos && make clean
make[1]: Entering directory '/home/j/Desktop/krusgen/libobos'
rm -rf obj
rm -rf lib
make[1]: Leaving directory '/home/j/Desktop/krusgen/libobos'
rm krusgen
rm: cannot remove 'krusgen': No such file or directory
make: [makefile:35: clean] Error 1 (ignored)
cd libobos && make all
make[1]: Entering directory '/home/j/Desktop/krusgen/libobos'
mkdir obj
mkdir lib
gcc -c src/obos.c -o obj/obos.o
ar -cvq lib/libobos.a obj/obos.o
a - obj/obos.o
ar -t lib/libobos.a
obos.o
make[1]: Leaving directory '/home/j/Desktop/krusgen/libobos'
gcc -o krusgen ./src/*.c -Ilibobos/include -lobos -Llibobos/lib -Wall
/usr/bin/ld: /tmp/ccgrei2I.o:(.bss+0x0): multiple definition of `maze'; /tmp/cckw6CE3.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [makefile:28: all] Error 1

There are memory leaks

Address sanitizer tells me that there are memory leaks in your program. You should probably check that:

$ ./krusgen -x 25 -y 25 > /dev/null

=================================================================
==14318==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 200 byte(s) in 1 object(s) allocated from:
    #0 0x4d9f88 in calloc (/home/j/Projects/C/mess/milosz/krusgen/krusgen+0x4d9f88)
    #1 0x518477 in mazeInit /home/j/Projects/C/mess/milosz/krusgen/./src/maze.c:40:34
    #2 0x51332b in main /home/j/Projects/C/mess/milosz/krusgen/./src/krusgen.c:71:8
    #3 0x7f0ba14e6b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310

Direct leak of 200 byte(s) in 1 object(s) allocated from:
    #0 0x4d9f88 in calloc (/home/j/Projects/C/mess/milosz/krusgen/krusgen+0x4d9f88)
    #1 0x518477 in mazeInit /home/j/Projects/C/mess/milosz/krusgen/./src/maze.c:40:34
    #2 0x512bf3 in main /home/j/Projects/C/mess/milosz/krusgen/./src/krusgen.c:54:8
    #3 0x7f0ba14e6b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310

Indirect leak of 3100 byte(s) in 25 object(s) allocated from:
    #0 0x4d9f88 in calloc (/home/j/Projects/C/mess/milosz/krusgen/krusgen+0x4d9f88)
    #1 0x518615 in mazeInit /home/j/Projects/C/mess/milosz/krusgen/./src/maze.c:42:37
    #2 0x512bf3 in main /home/j/Projects/C/mess/milosz/krusgen/./src/krusgen.c:54:8
    #3 0x7f0ba14e6b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310

Indirect leak of 2500 byte(s) in 25 object(s) allocated from:
    #0 0x4d9f88 in calloc (/home/j/Projects/C/mess/milosz/krusgen/krusgen+0x4d9f88)
    #1 0x518615 in mazeInit /home/j/Projects/C/mess/milosz/krusgen/./src/maze.c:42:37
    #2 0x51332b in main /home/j/Projects/C/mess/milosz/krusgen/./src/krusgen.c:71:8
    #3 0x7f0ba14e6b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310

SUMMARY: AddressSanitizer: 6000 byte(s) leaked in 52 allocation(s).

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.