Skip to content

Broken on big-endian architectures #47

@hyperair

Description

@hyperair

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions