Coder Social home page Coder Social logo

Linux type kind parsing fails about gore HOT 11 CLOSED

goretk avatar goretk commented on August 16, 2024
Linux type kind parsing fails

from gore.

Comments (11)

mattkeenan avatar mattkeenan commented on August 16, 2024 1

From memory this is because Windows malloc() initialises memory to zero, whereas Linux malloc() doesn't.

from gore.

TcM1911 avatar TcM1911 commented on August 16, 2024

Can you share the file?

from gore.

stevemk14ebr avatar stevemk14ebr commented on August 16, 2024

No i cannot unfortunately, i will try to do some reproduction myself to give you more info. This bug seems weird though because i see you are already masking the kind field?

from gore.

TcM1911 avatar TcM1911 commented on August 16, 2024

Does the Go library parse it correctly? You can either use it directly or use redress "https://github.com/goretk/redress/releases" to extract the information. redress -type should print out all types in a format you will find in the source code.

When using the python library, the data is transferred from Go to C to Python. The issue can be anywhere in this chain... I suspect the C layer...

from gore.

stevemk14ebr avatar stevemk14ebr commented on August 16, 2024

i'm trying with the C bindings now. I'll do the same logic as the python script

from gore.

stevemk14ebr avatar stevemk14ebr commented on August 16, 2024

the C library does NOT exhibit this issue with the following code:

include <stdio.h>
#include "libgore.h"

int main(int argc, char** argv)
{
   int v;
   char* fp = argv[1];
   printf("loading: %s", fp);
   v = gore_open(fp);
   struct compilerVersion* c = gore_getCompilerVersion(fp);
   printf("Compiler version: %s\n", c->name);
   struct types* ts = gore_getTypes(fp);
   printf("found %d types\n", ts->length);
   for(int i =0; i < ts->length; i++) {
       struct type* t = ts->types[i];
       if(t->kind > 30) {
           printf("got a bad one\n");
       }
   }
   gore_close(fp);
   return 0;
}

This suggest the python bindings have an issue. Or that the binary in the python package is malformed.

from gore.

mattkeenan avatar mattkeenan commented on August 16, 2024

This is just a complete guess here, but could this be a bignum and/or rounding problem?

x.ref numpy/numpy#8433

from gore.

stevemk14ebr avatar stevemk14ebr commented on August 16, 2024

i've seen stuff like this before when the field being assigned into is wider than the value being assigned and is not zeroed before.

EDIT: I looked, this is the bug. In the python wrapper library an unsigned long is used, but in the c library it's an unsigned int. This causes whatever random upper bits of the unsigned long to be undefined and occasionally these are set giving weird results. Must of been lucky that it only occured on linux

_Type._fields_ = [('kind', c_ulong),

struct type {
    unsigned int kind;

from gore.

stevemk14ebr avatar stevemk14ebr commented on August 16, 2024

Ah cool thanks for sharing that! Also appreciate the library alot.

from gore.

TcM1911 avatar TcM1911 commented on August 16, 2024

I just pushed a new patch update to pypi https://pypi.org/project/pygore. Please let me know if 0.2.3 does not solve the issue.

from gore.

stevemk14ebr avatar stevemk14ebr commented on August 16, 2024

Tested. The bug is resolved.

from gore.

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.