PR# 19449 Wrongly triggered invariant in LINKED_LIST

Problem Report Summary
Submitter: larswi
Category: Compiler
Priority: Medium
Date: 2018/08/20
Class: Bug
Severity: Serious
Number: 19449
Release: 18.07, 18.01, 17.01 ...?
Confidential: No
Status: Closed
Responsible:
Environment: linux
Synopsis: Wrongly triggered invariant in LINKED_LIST

Description
First i got problem with LINKED_LIST and invariant item_corresponds_to_index: (not off) implies (item = i_th (index)) inherited from CHAIN. It triggers somtimes (random?). 
I have created a small program that duplicates the problem (attached). I guess it has something to do with the garbage collector moving objects.



To Reproduce
class APPLICATION

inherit
    LINKED_LIST [STRING]
        rename
            make as make_ll
        end

create
    make

feature

    make
        local
            i, n: INTEGER
            str: STRING
        do
            make_ll
            n := 1_000_000
            from i := 1 until i > n loop
                str := "A"
                extend (str)
                finish
                if item /= i_th (index) then
                    print ("ERROR! count: " + count.out + " index: " + index.out + "%N")
                    print ("item: " + item.out + "%N")
                    print ("i_th: " + i_th (index).out + "%N")
                end
                i := i + 1
            end
        end

end

./application
ERROR! count: 26200 index: 26200
item: A
i_th: A
ERROR! count: 57641 index: 57641
item: A
i_th: A
ERROR! count: 106724 index: 106724
item: A
i_th: A

...
Problem Report Interactions
From:alexk_es    Date:2018/08/25    Status: Closed    Download   
The bug is fixed in rev#102061 of EiffelStudio 18.11 intermediate release.

Unfortunately, there is no reasonable workaround for the issue when using earlier versions of EiffelStudio. Here are the conditions to reproduce the bug:
- finalized mode;
- reference equality test;
- left-hand side of the equality is not a stack-based variable (argument, Result, Current, local, etc.);
- right-hand side of the equality triggers GC.
Satisfying all the conditions above does not necessary lead to the issue, but eliminating any of them avoids it.

From:alexk_es    Date:2018/08/24    Status: Analyzed    Download   
Added test#final126.

From:larswi    Date:2018/08/20    Status: Analyzed    Download   
OS: Ubuntu 17.04 zesty 64bit
Compile: ec -batch -finalize -c_compile -config project.ecf

Attachment: project.ecf     Size:845
From:alexk_es    Date:2018/08/20    Status: Analyzed    Download   
Thank you for the report. Would you provide some more details about compilation:
- melted/workbench/finalized
- assertions turned on/off
- mono-threaded/multi-threaded/SCOOP
etc., or, better, send the corresponding ECF, please?

Also, would you provide additional information about your setup: Linux version, 32/64-bit, anything else that might be relevant?

From:larswi    Date:2018/08/20    Download   
Attachments for problem report #19449

Attachment: application.e     Size:717