Broken on big-endian architectures

Open
#47 0 comments 0 reactions 0 assignees View on GitHub

@onitake is already working on this.

Since Dec 19, 2025.

  • #61 by @onitake — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start with the failing File transversal, Search for GCode blocks, and binary/ascii conversion tests, then inspect data-file reads in src/LibBGCode/core/core.cpp, including FileHeader::read. Reproduce the failures on a big-endian architecture using the linked Debian build logs as context. Done means the listed tests pass on big-endian systems without disabling the package.

Written by the indexing model from the issue text.

Description

The following tests fail in big-endian architectures:

The following tests FAILED:
	  1 - File transversal (Failed)
	  2 - Search for GCode blocks (Failed)
	  3 - Convert from binary to ascii (Failed)
	  4 - Convert from ascii to binary (Failed)

Downstream bug report in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1062014

Some debugging reveals that this error happens due to mismatched endianness when reading data files.

diff --git a/src/LibBGCode/core/core.cpp b/src/LibBGCode/core/core.cpp
@@ -126,8 +127,10 @@ EResult FileHeader::read(FILE& file, const uint32_t* const max_version)
 {
     if (!read_from_file(file, &magic, sizeof(magic)))
         return EResult::ReadError;
+    printf("data=0x%08x MAGIC=0x%08x\n", magic, MAGICi32);
     if (magic != MAGICi32)
         return EResult::InvalidMagicNumber;

->

File:/build/libbgcode/tests/data/mini_cube_b.bgcode
data=0x47434445 MAGIC=0x45444347

It's likely that there are many more similar problems lurking in the source code.
If this issue can't be fixed, the package should probably be disabled on big endian architectures.

Sample build logs:

Dominant language
G-code
Stars
73
Forks
24
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prusa3d/libbgcode

All issues in prusa3d/libbgcode

Similar issues

More Operating Systems issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.