Git Product home page Git Product logo

Comments (10)

MatthieuDartiailh avatar MatthieuDartiailh commented on July 19, 2024

I will try to have a look either this week-end or next Wednesday night. Feel free to ping me if you do not hear from me.

from bytecode.

IPSW1 avatar IPSW1 commented on July 19, 2024

Alright, thank you. I tried to do a fix in this commit, which is meant to be as general as possible. It resolves the extended arguments and temporarily changes the instruction argument to the resolved value. It seems that the dis module is doing it in this way, which is why the stack effect is computed correctly for the above example.

I did not test any possible side effects. But I also don't think this will make the problem worse, since it does nothing if there are not extended arguments. However, there still remain problems when including EXTENDED_ARG instructions, for example when there are more than 256 names in a code object or if there are long jumps.

from bytecode.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 19, 2024

Can you open a PR with this commit ? Also if you can come up with a bunch of failing unit test it would be helpful to help improve support for EXTENDED_ARG.

from bytecode.

IPSW1 avatar IPSW1 commented on July 19, 2024

I did here #64. Was just worried about my code quality, that's why I hesitated :)

There are also three added test cases, but only one of them is expected to fail. It seems like this has something to do with a split of huge block and a wrong start size for one block, but I am not entirely sure.

EDIT: Looks like this test case only fails for versions from 3.6.

from bytecode.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 19, 2024

I finally found some time to look at this in details. My conclusion is that the issue is that EXTENDED_ARG are propagated to higher level representation of the bytecode namely Bytecode and ControlFlowGraph which should not happen. EXTENDED_ARG is a low-level detail and should be ignored in those high level representation.

I will work to fix the ConcreteBytecode.to_bytecode method to eliminate all EXTENDED_ARG if any is present which should address all issues related to them. For symmetry I will try to add an extended_args to Bytecode.to_concrete_bytecode to allow to generate a ConcreteBytecode with EXTENDED_ARG.

If you have any example that uses EXTENDED_ARG and that fails when doing Bytecode.from_code(code).to_code() please let me know because that would be a different kind of bug and not fixed by the above.

from bytecode.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 19, 2024

I just opened #65 that addresses your issues. All the tests you included in #64 now pass.

from bytecode.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 19, 2024

@IPSW1 I noticed you closed #64. Can you confirm that #65 addresses all your issues ?

from bytecode.

IPSW1 avatar IPSW1 commented on July 19, 2024

TL;DR: Yes, it does.

The thing is I just realized that I wanted to have the benefits of both the concrete and the abstract world, i.e. the EXTENDED_ARG and also the convenience with abstraction. As you described in #65, this would lead to possibly a lot of problems regarding stack size computation (for which my bad hack in #64 is a good example).

So I think your proposed solution is completely reasonable for the issues.

from bytecode.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 19, 2024

@IPSW1 Do you need a new release now that #65 has been merged ?

from bytecode.

IPSW1 avatar IPSW1 commented on July 19, 2024

There is no need for a specific release for me.

Thank you for the fix!

from bytecode.

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.