Subject: bug#38772: guile-2.2.6 'prebuilt/32-bit-big-endian' prebuilt bytecode is invalid

From: Sergei Trofimovich <[email-masked]>
Date: Sat, 28 Dec 2019 11:24:46 +0000

In https://bugs.gentoo.org/676468 Gentoo found out that
guile-2.26 release fails to build on 32-bit BE targets:
- powerpc-unknown-linux-gnu
- sparc-unknown-linux-gnu
- hppa-unknown-linux-gnu

The symptom is a SIGSEGV:
    https://bugs.gentoo.org/676468#c10

The workaround is to delete 'prebuilt/32-bit-big-endian'
to regenerate it locally.

After bytecode is rebuilt we can verify that original bytecode
does not look valid:

guile-2.2.3 $
  meta/build-env guile -c '((@ (system vm disassembler) disassemble-file) "prebuilt/32-bit-big-endian.broken/system/foreign.go")'
Disassembly of <unnamed function> at #x98:

Backtrace:
           9 (apply-smob/1 #<catch-closure ef391f00>)
In ice-9/boot-9.scm:
    705:2  8 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8  7 (_ #(#(#<directory (guile-user) ef37c910>)))
In ice-9/command-line.scm:
   181:18  6 (_ #<input: string ef658f50>)
In unknown file:
           5 (eval ((@ (system vm disassembler) disassemble-file) #) #)
In system/vm/disassembler.scm:
    464:4  4 (disassemble-image _ _)
In system/vm/debug.scm:
   121:17  3 (for-each-elf-symbol _ #<procedure ef398be8 at system/v…>)
In system/vm/disassembler.scm:
    475:9  2 (_ _)
   338:16  1 (disassemble-buffer #<output: file /dev/console> # 38 # …)
   291:14  0 (compute-labels #vu8(127 69 76 70 1 2 1 255 0 0 0 0 0 …) …)

system/vm/disassembler.scm:291:14: In procedure compute-labels:
In procedure vector-ref: Value out of range: 3678

I see 2 problems here:
1. 32-bit BE bytecode seems to be invalid. How does it get generated? Via cross-compilation?
2. guile does not validate bytecode when executes it (at least by default) and just SIGSEGVs.

-- 

  Sergei