Coder Social home page Coder Social logo

lexaloffle's People

Contributors

dansanderson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lexaloffle's Issues

pxa: hash heap corruption

Hello Dan, i'm not sure if it makes sense to file an issue here because it's only example code, but I think I found a bug in the pxa compression routine:

When one of the lists in hash_list grows to more than 32768 entries, the code in https://github.com/dansanderson/lexaloffle/blob/main/pxa_compress_snippets.c#L406 tries to reallocate it with a size of 32768 * 2 == 65536, which doesn't fit into the uint16 used to store the allocation size. So the list is effectively reallocated with a size of zero; i.e. the heap_pos is increased by only 2 for the list header.

If any other lists are later reallocated, they will overwrite the affected list.

Here is a cartridge where this happens: https://www.lexaloffle.com/bbs/get_cart.php?cat=7&play_src=2&lid=nerfcooking_in_vegas-2

At input position 63072, the list for hash 3088 grows to more than 32768 entries. It is the reallocated to offset 157716 in the heap. The heap_pos is increased to 157718.
Later, at input position 63433, the list for hash 3032 is reallocated to 157718, overwriting the start of the list for 3088.

I guess this doesn't affect the correctness of the compression, since pxa_find_repeatable_block will never choose one of the corrupted blocks. But it does affect the efficiency: an implementation without this problem compresses the code in above cartridge to 7971b instead of 14348b.

This issue also seems to be present in PICO-8 0.2.5c.

Have a nice day!

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.