Code Monkey home page Code Monkey logo

Comments (3)

Artoria2e5 avatar Artoria2e5 commented on July 19, 2024 1

Looks like everything succeeded! Guess it's just the "let's double zero" logical error then.

(The two successes does suggest that it's getting NULL on zero-size allocs, which isn't exactly good for other reasons.)

from lzfse.

Artoria2e5 avatar Artoria2e5 commented on July 19, 2024

Is this the classic malloc(0) problem ubiquitous on a bunch of systems? Would you like to:

  • include the operating system in the report
  • Run a simple snippet to eff with the system:
    #include <stdlib.h>
    #define STRINGIFY(x) #x
    #define TOSTRING(x) STRINGIFY(x)
    #define PEE_ERR(P, S) if(!(P)) perror(S ":" TOSTRING(__LINE__))
    int main(void) {
      void* p = malloc(0);
      PEE_ERR(p, "malloc");
      p = realloc(p, 0);
      PEE_ERR(p, "realloc");
      free(p);
      perror("free");
      return 0;
    }

from lzfse.

RJVB avatar RJVB commented on July 19, 2024

This happens on Ubuntu 14.04.5 ; your eff code prints

eff.c: In function ‘main’:
eff.c:4:32: warning: implicit declaration of function ‘perror’ [-Wimplicit-function-declaration]
 #define PEE_ERR(P, S) if(!(P)) perror(S ":" TOSTRING(__LINE__))
                                ^
eff.c:7:3: note: in expansion of macro ‘PEE_ERR’
   PEE_ERR(p, "malloc");
   ^~~~~~~
realloc:9: Success
free: Success

When I test on Mac OS X (10.9.5) the encoder ends up in an endless loop:

LZFSE encode
Input: empty.diff
Output: stdout
Input size: 0 B
Output buffer was too small, increasing size...
Output buffer was too small, increasing size...
Output buffer was too small, increasing size...
Output buffer was too small, increasing size...
Output buffer was too small, increasing size...
Output buffer was too small, increasing size...

and the eff code prints

eff.c:7:3: warning: implicit declaration of function 'perror' is invalid in C99 [-Wimplicit-function-declaration]
  PEE_ERR(p, "malloc");
  ^
eff.c:4:32: note: expanded from macro 'PEE_ERR'
#define PEE_ERR(P, S) if(!(P)) perror(S ":" TOSTRING(__LINE__))
                               ^
1 warning generated.
free: Undefined error: 0

from lzfse.

Related Issues (20)

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.