Bug 155937 - UITest: frames[0] throws "index out of ranges" in close_doc() on riscv64
Summary: UITest: frames[0] throws "index out of ranges" in close_doc() on riscv64
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
7.6.0.0 beta1+
Hardware: Other Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-20 01:42 UTC by Sakura286
Modified: 2023-08-06 10:04 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sakura286 2023-06-20 01:42:41 UTC
Description:
I am trying to fix a uitest bug on riscv64. All the UI test failed for throwing "IndexError: index out of range" when closing doc. Here is an example:

https://gist.github.com/Sakura286/e216f57c1a81c6dc813ac52f76479293

On x86, "bool(frames)" should be "False" and "frames[0].active" should not be executed in uitest/uitest/test.py::close_doc(). But on riscv64, "bool(frames)" turn out to be "True".

I looked into the code, and find that "frames.__len__()" on x86 changed from 1 to 0, but on riscv64 it changed from 270582939649 to 270582939648.

270582939648 is 0011 1111 0000 0000 0000 0000 0000 0000 0000 0000 in binary form (32 bit zero suffix).

Maybe this is the opening to solve the problem. But I cannot find out where the __len__() function of the pyuno object is defined and cannot track how this weired number value comes from. I would be appreciated if someone provide some tips.

Steps to Reproduce:
1. Run any UI test on riscv64
2. UI test failed for "IndexError: index out of range"

Actual Results:
UItest failed for error

Expected Results:
The doc closed without exception


Reproducible: Always


User Profile Reset: No

Additional Info:
Described above.
Comment 1 Sakura286 2023-06-29 10:38:22 UTC
frames.__len__() calls the fuction PyUNO_len() in pyuno/source/module/pyuno.cxx. 

> int nLen = lcl_detach_getLength( me );
>         if (nLen >= 0)
>             return nLen;

"nlen" is a 32bit int variable. Remember that 0011 1111 0000 0000 0000 0000 0000 0000 0000 0000 has 32bit suffix 0. So the value of "nlen" is right in PyUNO_len(). Thus this bug should be locate between c++ and python environment.
Comment 2 Rene Engelhard 2023-07-10 21:31:17 UTC
it seems that this exhibits when built with -O2 but not with -O0...
Comment 3 Buovjaga 2023-08-06 09:45:18 UTC
https://gerrit.libreoffice.org/c/core/+/154837 was merged without this bug ID in the commit subject line, so this report didn't get the automatic comment. In the patch comments, René says the patch 'doesnt fix all tests but it's not supposed to, it definitely fixes the "index out of range" thingy'. Should this report be kept open or are further fixes planned?
Comment 4 Rene Engelhard 2023-08-06 10:04:27 UTC
I think it can be marked fixed. The description refers exactly that one issue and thus is fixed.

Any new other problem should probably get a new bug anyway :)