Git Product home page Git Product logo

Comments (4)

jonblack avatar jonblack commented on September 17, 2024

I suspect that the issue caused by an incorrect use of sizeof:

for (uint32 j = 0; j < sizeof(ri.m_dist); ++j)
    ri.m_dist[j] = m_seq[i] == j ? 1 : 0;

m_dist is declared as follows:

struct MResInfo
{
    ...
    ...
    uint32 m_dist[23];
    ...
    ...
};

sizeof returns the size in bytes of the entire array, not the length as is assumed. This means that the loop exeeds the end of the array, causing the segmentation fault.

Getting the length of an array is notoriously hard (see: http://stackoverflow.com/questions/874169/how-to-get-the-size-of-an-array). The array is created as a fixed size, so the loop should use this to control when it ends.

from hssp.

jonblack avatar jonblack commented on September 17, 2024

This bug was introduced in commit e839fd8 on 01/06/2012.

from hssp.

jonblack avatar jonblack commented on September 17, 2024

This bug only happens when compiled with -O2 (optimisation level 2) is used. When -O0 (no optimisations) is used, the program produces output (whether this is correct is now another question) without crashing.

from hssp.

touwwouter avatar touwwouter commented on September 17, 2024

This is definitely a bug. When using the hard-coded array-length, the output is correct for 1f2i for which the error was raised.

@jonblack Compilation of the bugged code without optimization results in incorrect output for 1f2i as well.

from hssp.

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.