SB-C::REPACK-XREF breaks on an aref with an invalid index

Bug #1648186 reported by Attila Lendvai on 2016-12-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

it happens only sometimes, probably depends on the actual code/symbols loaded.

SBCL is HEAD as of today: 98ae2f63f69fea4a72325734b8013eab71d22b57 (plus a couple of irrelevant changes)

SAVE-LISP-AND-DIE calls SB-C::REPACK-XREF, it breaks into the debugger with an error, i started a swank server, and in this state i can even reproduce it from a slime repl by calling it by hand with:

(SB-C::REPACK-XREF :COMPACT-NAME-COUNT 256 :VERBOSE NIL)

the actual access is this line (inside the lambda returned by index->name):

(aref vector (+ index 1 (- common-count)))

either VECTOR is not what it should be, or it's accessed with the wrong assumptions. maybe using typed structures, or explicit accessor functions would help avoiding this, or at least debugging such errors.

Invalid index 257 for (SIMPLE-VECTOR 2), should be a non-negative integer below 2.
   [Condition of type SB-INT:INVALID-ARRAY-INDEX-ERROR]

Restarts:
 2: RETRY Retry SLIME REPL evaluation request.
 1: *ABORT Return to SLIME's top level.
 0: ABORT abort thread (#<THREAD "repl-thread" RUNNING {1004D8FFA3}>)

Backtrace:
  0: ((SB-IMPL::OPTIMIZED-DATA-VECTOR-REF T) #<unavailable argument> #<unavailable argument>)
  1: ((LAMBDA (SB-INT:INDEX) :IN SB-C::INDEX->NAME) 256)
      Locals:
        SB-C::COMMON-COUNT = 0
        SB-INT:INDEX = 256
        VECTOR = #(#(9 3 1 128 18) SWANK-REPL::OPEN-STREAMS)
  2: (SB-C::MAP-PACKED-XREF-DATA #<CLOSURE (LAMBDA (SB-C::KIND SB-C::NAME NUMBER) :IN SB-C::REPACK-XREF) {1003FD02AB}> #(#(9 3 1 128 18) SWANK-REPL::OPEN-STREAMS))
      Locals:
        DECODER = #<CLOSURE (LAMBDA (INTEGER) :IN SB-C::INDEX-AND-NUMBER-DECODER) {1003FD02FB}>
        FUNCTION = #<CLOSURE (LAMBDA (SB-C::KIND SB-C::NAME NUMBER) :IN SB-C::REPACK-XREF) {1003FD02AB}>
        FUNCTION#1 = #<CLOSURE (LAMBDA (SB-C::KIND SB-C::NAME NUMBER) :IN SB-C::REPACK-XREF) {1003FD02AB}>
        INDEX = 256
        KIND = :CALLS
        KIND-NUMBER = 1
        LOOKUP = #<CLOSURE (LAMBDA (SB-INT:INDEX) :IN SB-C::INDEX->NAME) {1003FD02DB}>
        #:LOOP-REPEAT-28 = 0
        NUMBER = 4
        OFFSET = 5
        PACKED = #(9 3 1 128 18)
        RECORD-COUNT = 1
        XREF-DATA = #(#(9 3 1 128 18) SWANK-REPL::OPEN-STREAMS)
  3: ((LAMBDA (SB-C::NAME SB-C::FUN) :IN SB-C::REPACK-XREF) #<unused argument> #<FUNCTION SWANK-REPL::INITIALIZE-STREAMS-FOR-CONNECTION>)
      Locals:
        SB-C::ALL-UNPACKED = NIL
        SB-C::COUNTS = NIL
        SB-C::COUNTS-BY-NAME = #<HASH-TABLE :TEST EQUAL :COUNT 0 {1003F75B93}>
        SB-C::FUN = #<FUNCTION SWANK-REPL::INITIALIZE-STREAMS-FOR-CONNECTION>
        SB-C::OLD-SIZE = 21
        SB-C::SEEN = #<HASH-TABLE :TEST EQUAL :COUNT 0 {1003FD01E3}>
        SB-C::UNPACKED = NIL
        SB-C::XREFS = #(#(9 3 1 128 18) SWANK-REPL::OPEN-STREAMS)
  4: (SB-C::CALL-WITH-EACH-GLOBALDB-NAME #<CLOSURE (LAMBDA (SB-C::NAME) :IN SB-C::MAP-SIMPLE-FUNS) {1003F75CAB}>)
  5: (SB-C::REPACK-XREF :COMPACT-NAME-COUNT 256 :VERBOSE NIL)
      Locals:
        #:.DEFAULTING-TEMP. = 256
        #:.DEFAULTING-TEMP.#1 = NIL
        ALL-UNPACKED = NIL
        COMPACT-NAME-COUNT = 256
        COUNTS = NIL
        COUNTS-BY-NAME = #<HASH-TABLE :TEST EQUAL :COUNT 0 {1003F75B93}>
        NEW-SIZE = 0
        OLD-SIZE = 21

Jan Moringen (scymtym) on 2016-12-07
Changed in sbcl:
assignee: nobody → Jan Moringen (scymtym)
importance: Undecided → Medium
Jan Moringen (scymtym) on 2016-12-08
Changed in sbcl:
status: New → Fix Committed
assignee: Jan Moringen (scymtym) → nobody
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers