Skip to content

Error for binaries larger than 2Gb #3939

Closed

Description

@lsoica

For final binaries larger than 2Gb, the following exception message is printed out:

struct.error: 'i' format requires -2147483648 <= number <= 2147483647

https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/archive/writers.py#L264

class CTOC(object):
    ENTRYSTRUCT = '!iiiiBB'  # (structlen, dpos, dlen, ulen, flag, typcd) followed by name

Activity

  1. added
    area:bootloaderCaused be or effecting the bootloader
    help wantedSeeking help by somebody with deeper knowledge on this topic.
    on Jan 2, 2019
  2. htgoebel commented on Jan 2, 2019

    @htgoebel
    Member

    A possible solution would be to change this from signed to unigned values (need to be done in the bootloader, too).

    Can you please provide a test-case we can include into the test-suite. Thanks.

  3. added
    pull-request wantedPlease submit a pull-request for this, maintainers will not actively work on this.
    on Jan 7, 2019
  4. lsoica commented on Jan 7, 2019

    @lsoica
    Author

    A possible solution would be to change this from signed to unigned values (need to be done in the bootloader, too).

    Can you please provide a test-case we can include into the test-suite. Thanks.

    The switch from signed to unsigned moves the limit from 2gb to 4gb, right ? Is there a way to go over the 4gb limit ? Basically, could we go with an 8byte specifier ?

    As for a test case, do you need a specific format or just a set of steps ?

  5. htgoebel commented on Jan 7, 2019

    @htgoebel
    Member

    The switch from signed to unsigned moves the limit from 2gb to 4gb, right ?

    Right.

    Is there a way to go over the 4gb limit ? Basically, could we go with an 8byte specifier ?

    Basically we could be, but this required more changes. Also we should keep in mind 32-bit platforms, which might have trouble using 8-byte specifiers.

    As for a test case, do you need a specific format or just a set of steps ?

    Well, this should fit into our test-quite, which uses py-test. The most problematic point is to generate same data which surly ends up to be > 4gb when creating the CTOC.

    I suggest several test-cases, which (as I assume) also ease developing tests:

    • an unit-test for CArchiveWriter and CArchiveReader (testing CTOC and CTOCReader is not of much use IMHO). Shall go into a new file in tests/unit/.
    • an end-to-end test to ensure the created executable actually works.
      This test could create a huge file containing some known data at some relevant positions (e.g. start, just before 2GB, just after 2GB, just before 4GB, just after 4GB), pass it using pyi_args=["--add-data", "xxx:yyy"] and the code should verify the expected data can be read.
      Shall go into tests/function/test_basic.py.
  6. Kenblair1226 commented on Sep 17, 2019

    @Kenblair1226

    The switch from signed to unsigned moves the limit from 2gb to 4gb, right ?

    Right.

    Sorry this might be a dumb question, but how to do it? Change '!iiiiBB' to '!IIIIBB' ?
    how to to this for bootloader for they are all binary files?

  7. Legorooj commented on Feb 26, 2020

    @Legorooj
    Member

    Pinging

  8. Red-Eyed commented on Jul 10, 2020

    @Red-Eyed

    Any news?
    I tried to change datastructure but have no luck

  9. Legorooj commented on Jul 13, 2020

    @Legorooj
    Member

    @Red-Eyed I've added this to my todo-list, and I'll get this in the 4.1 release, maybe even the 4.0 release depending on when that actually gets released.

  10. self-assigned this
    on Jul 13, 2020
  11. sshuair commented on Nov 9, 2020

    @sshuair

    @Legorooj is this fixed now?

  12. Red-Eyed commented on Nov 9, 2020

    @Red-Eyed

    @Legorooj sorry for the annoying comments, but this issue is important to me: Currently I have to do my installer with additional tarballs rather than having just a single large executable.

    So, If you don't mind, I just want to ask a few questions in order to have a better understanding the status of this issue:

    1. Is any kind of work in progress?
    2. Maybe there are some difficulties that doesn't allow to put > 2GB into the CArchive?
    3. How do you think when (if ever) this will be resolved?

    Thanks!

  13. Legorooj commented on Nov 9, 2020

    @Legorooj
    Member

    Ah right. Let me take a lok at this right now - my apologies, I completely forgot about this.

    1. No. There will be within a week though hopefully.
    2. Moving the limit from 2gb to 4gb should be easy enough I think, however I don't know beyond that.
    3. Very soon.
  14. bwoodsend commented on Nov 9, 2020

    @bwoodsend
    Member

    I question the usefulness of this. It'd take a good 30 minutes to pack a 4GB application then a good minute or so to unpack again followed by however long it takes for your antivirus to give it a good sniff which would have to happen every time the user opens the application. I already find ~200MB applications to be annoyingly slow to startup. I think you'd be better off turning your one-dir applications into an installable bundle using NSIS or something equivalent. That way your user only has to unpack it once.

  15. 16 remaining items

  16. sshuair commented on Nov 11, 2020

    @sshuair

    Okay, will do that tomorrow.
    Until then, I would like to ask you:
    could you please confirm that your branch actually unpacks package (that was built in one file mode) larger than 2 GB) ?

    That would be awesome. Thanks!

    Yes! In my case, the libtorch_cuda.so is 900+MB. The package will larger than 2 GB if you add the cuda, cudnn and TensorRT library.

  17. Red-Eyed commented on Nov 11, 2020

    @Red-Eyed

    Okay, will do that tomorrow.
    Until then, I would like to ask you:
    could you please confirm that your branch actually unpacks package (that was built in one file mode) larger than 2 GB) ?
    That would be awesome. Thanks!

    Yes! In my case, the libtorch_cuda.so is 900+MB. The package will larger than 2 GB if you add the cuda, cudnn and TensorRT library.

    Currently I have 6 GB of python environment (pytorch, tensorflow, scipy etc) and pack it into 1.6GB tar.xz archive to get under 2GB limit

    but I want to use zstandard compression (to speed up decompression) but zstandart compresses to 2.6GB which is above of 2GB limit

  18. Red-Eyed commented on Nov 11, 2020

    @Red-Eyed

    Note: I just built bootloader and it works, thank you @rokm !

  19. rokm commented on Nov 11, 2020

    @rokm
    Member

    Here's a further branch, in which 64-bit integers are used: https://github.com/rokm/pyinstaller/tree/large-file-support-v2

    So now in theory, sky's the limit - you can chuck in all your deep learning frameworks, CUDA libraries, pretrained models, ...

    In practice, however, the 5 GB onefile test passes only on linux (tested only 64-bit for now). Windows (even 64-bit) do not seem to support executables larger than 4 GB. On (64-bit) macOS, the macholib used in a signing preparation step in the assembly pipeline seems to assume that the file size can be represented with an unsigned integer, so 4 GB max as well (and this is consistent with macOS signature searching code in the bootloader, which uses 32-bit unsigned integers).

    So really huge onefile executables (> 4 GB) work only on linux. But on all three OSes, this limitation can be worked around by using .spec file and adding append_pkg=False as an extra argument to EXE(). This will give you a small executable (e.g., program) and a single large archive file to go with it (e.g., program.pkg).

  20. sshuair commented on Nov 18, 2020

    @sshuair

    @Legorooj any progress?

  21. Legorooj commented on Nov 18, 2020

    @Legorooj
    Member

    I stopped work on this because by the time I woke up the next morning @rokm had already written everything that needed to be😅. Maybe he could submit a PR?

  22. sshuair commented on Nov 18, 2020

    @sshuair

    I stopped work on this because by the time I woke up the next morning @rokm had already written everything that needed to be😅. Maybe he could submit a PR?

    Nice job!

  23. rokm commented on Nov 18, 2020

    @rokm
    Member

    @sshuair the current plan is to have the changes from those experimental branches submitted and merged gradually - first the endian-handling cleanup, then the file extraction cleanup, then switch to unsigned 32-bit ints, and finally to 64-bit ones.

    In the meantime, if you require this functionality, you can use either of the experimental branches linked above.

  24. Red-Eyed commented on Nov 18, 2020

    @Red-Eyed

    @sshuair
    If u need >2GB just use branch that @rokm published. I just use it and it works on Ubuntu 20.04 and Windows (but before using it, u need to rebuild the bootloader, it's easy, just read the documentation)

  25. sshuair commented on Nov 20, 2020

    @sshuair

    @Red-Eyed the branch that @rokm published seems not work for me. When the file PKG-00.pkg up to 2.7BG, the error appeared again. My OS system is Ubuntu 16.04.

  26. sshuair commented on Nov 20, 2020

    @sshuair

    @Red-Eyed Sorry~~It's my fault, I install the package from master branch but not the large-file-support-v2. Now it works for me.

  27. EricPengShuai commented on Sep 14, 2022

    @EricPengShuai

    @rokm so how to solve the error problem for binaries larger than 4G, my OS system is CentOS Linux release 7.6.1810 (Core)
    the final error information is as follows.

    struct.error: 'I' format requires 0 <= number <= 4294967295
  28. rokm commented on Sep 14, 2022

    @rokm
    Member

    @rokm so how to solve the error problem for binaries larger than 4G, my OS system is CentOS Linux release 7.6.1810 (Core) the final error information is as follows.

    struct.error: 'I' format requires 0 <= number <= 4294967295

    You cannot. If you wanted to generate embedded archive that's larger than 4 GB, you would need to switch the types used by corresponding PyInstaller code (both python and C) to 64-bit integers. While this would work on linux, neither Windows nor macOS support executables larger than 4 GB, so we only extended max size from 2 GB to 4 GB by switching to unsigned 32-bit integers.

  29. locked as resolved and limited conversation to collaborators on Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:bootloaderCaused be or effecting the bootloaderhelp wantedSeeking help by somebody with deeper knowledge on this topic.pull-request wantedPlease submit a pull-request for this, maintainers will not actively work on this.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions