Skip to content

Segfault in MIPS codegen at -O3 #371

Closed

Description

@johnsonjh

Trying to build https://github.com/johnsonjh/lzpack. There are actually a few different LZPACK build configurations possible, but the "simplest" is the in-memory compressor.

Build stubs (using host tooling):

git clone https://github.com/johnsonjh/lzpack.git
cd lzpack
make stubs

Building LZPACK for MIPS with no optimization (same with -O, -O1, and -O2):

/opt/ack/bin/ack -D__ACK__ -mlinuxmips -o lzpack lzpack.c
"ack.ack-7b528104.so", line 2784: relocation offset in ha16[] too big (fatal)

Building LZPACK for MIPS with -O3 optimization:

/opt/ack/bin/ack -D__ACK__ -mlinuxmips -O3 -o lzpack lzpack.c
/opt/ack/bin/ack: /opt/ack/lib/ack/linuxmips/mcg died with signal 11
[2183551.901479] mcg[3191164]: segfault at 10 ip 00000000004018ff sp 00007ffd63b0dd80 error 4 in mcg[18ff,400000+13000] likely on CPU 2 (core 2, socket 0)
[2183551.901494] Code: 4c 89 ee e8 6e ff 00 00 48 85 c0 75 15 49 8d bc 24 88 00 00 00 4c 89 ee e8 59 ff 00 00 48 85 c0 74 15 48 8b 40 08 48 63 53 04 <48> 8b 40 10 48 8b 34 d0 e9 91 00 00 00 8b 53 04 41 8b 75 00 bf df

The Linux/386, Linux/m68k, and Linux/PPC targets all build LZPACK (and it works correctly).

Activity

  1. johnsonjh commented on Jul 16, 2026

    @johnsonjh
    ContributorAuthor

    The "streaming" version of LZPACK does build ...

    /opt/ack/bin/ack -D__ACK__ -O3 -mlinuxmips -DLZPACK_STREAM=1 -DLZPACK_OPT=1 -DHSZ=8192 -DMZXFILE=65535L -o lzpack lzpack.c

    ... but it doesn't actually work:

    ERROR: cannot create temp file LZTMP.$$$
  2. johnsonjh commented on Jul 16, 2026

    @johnsonjh
    ContributorAuthor

    The streaming issue is wrong flags used, I did a quick fix for that but got some other issues. I'll see what I can do.

  3. johnsonjh commented on Jul 16, 2026

    @johnsonjh
    ContributorAuthor

    I actually have some fixes for these issues (along with a workaround in LZPACK itself for one issue I couldn't figure out) which allow LZPACK to build and work with the streaming compressor (any optimization level too), and the full compressor but only without optimization. Using -O3 still fails.

    I'll get the changes into LZPACK and create a PR once I clean it up. It will be a bit better still but by no means perfect. If you have any questions about the changes let me know.

  4. johnsonjh commented on Jul 16, 2026

    @johnsonjh
    ContributorAuthor

    #372 fixes (most of these issues).

    The workaround for a remaining bug in the mcg optimizer is going into the LZPACK repo as soon as my local CI finishes there.

    Unfortunately, I've reached the limits of my skills with this I think, unless I can find a lot more time to sink into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions