Bug 1886548 - segfault at 0 ip 00007f6ac48ac3b2 sp 00007f6a42068650 error 4 in libCPlusPlus.so.4.12.4[7f6ac484a000+c5000]
Summary: segfault at 0 ip 00007f6ac48ac3b2 sp 00007f6a42068650 error 4 in libCPlusPlus...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: qt-creator
Version: 32
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Sandro Mani
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-10-08 18:02 UTC by Alexey Dobriyan
Modified: 2021-05-25 16:51 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-05-25 16:51:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Alexey Dobriyan 2020-10-08 18:02:59 UTC
Description of problem:
segfault parsing linux kernel 


Version-Release number of selected component (if applicable):
qt-creator.x86_64 4.12.4-2.fc32



How reproducible:
100%
Qt Creator restarts and starts to parse the same code only to segfault again.
I have to disable source parsing.


Steps to Reproduce:
This is Linux kernel source slightly converted to C++.
I'm trying to find exact file leading to segfault.


Actual results:
Thread (pooled)[2060469]: segfault at 0 ip 00007f6ac48ac3b2 sp 00007f6a42068650 error 4 in libCPlusPlus.so.4.12.4[7f6ac484a000+c5000]
Code: 41 c7 45 18 00 00 00 00 49 89 45 00 8b 45 1c 8d 50 01 89 55 1c 41 89 45 08 48 c7 04 24 00 00 00 00 e8 d2 33 fa ff 48 8b 3c 24 <48> 8b 07 ff 90 e8 00 00 00 49 8d 55 18 be 22 00 00 00 48 89 ef 49



Additional info:

0000000000189020 <CPlusPlus::Parser::parsePrimaryExpression(CPlusPlus::ExpressionAST*&)@@Base>:

        ...

  1893a9:       e8 d2 33 fa ff          call   12c780 <CPlusPlus::Parser::parseCompoundStatement(CPlusPlus::StatementAST*&)@plt>
  1893ae:       48 8b 3c 24             mov    rdi,QWORD PTR [rsp]
**1893b2: ===>  48 8b 07                mov    rax,QWORD PTR [rdi]   <===
  1893b5:       ff 90 e8 00 00 00       call   QWORD PTR [rax+0xe8]
  1893bb:       49 8d 55 18             lea    rdx,[r13+0x18]
  1893bf:       be 22 00 00 00          mov    esi,0x22
  1893c4:       48 89 ef                mov    rdi,rbp
  1893c7:       49 89 45 10             mov    QWORD PTR [r13+0x10],rax
  1893cb:       e8 f0 7f fa ff          call   1313c0 <CPlusPlus::Parser::match(int, int*)@plt>
  1893d0:       4d 89 2c 24             mov    QWORD PTR [r12],r13
  1893d4:       e9 35 fd ff ff          jmp    18910e <CPlusPlus::Parser::parsePrimaryExpression(CPlusPlus::ExpressionAST*&)@@Base+0xee>

Comment 1 Sandro Mani 2020-10-08 19:14:31 UTC
Can you try with this build?

https://koji.fedoraproject.org/koji/taskinfo?taskID=53017036

Comment 2 Alexey Dobriyan 2020-10-08 20:20:43 UTC
I'll try.


Meanwhile C++ part is irrelevant.

I checkout fully C mainline version and it crashes in the same way:

    commit c85fb28b6f999db9928b841f63f1beeb3074eeca
    Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Code parse correctly just a few days ago.
Should not be too hard to bisect.

Comment 3 Sandro Mani 2020-10-15 21:19:34 UTC
So, does that build help?

Comment 4 Alexey Dobriyan 2020-10-18 17:51:24 UTC
Can't reproduce anymore.

I reinstalled package from scratch, deleted .config/Qt* and kernel is parsed correctly again.

Comment 5 Sandro Mani 2020-10-18 17:54:21 UTC
So you mean you can't reproduce it anymore with 4.12.4-2.fc32?

Comment 6 Alexey Dobriyan 2020-10-19 18:04:13 UTC
> can't reproduce it anymore with 4.12.4-2.fc32?

I can't after clean reinstall with 4.12.4-2.fc32.
But settings were tweaked from default (C++ standard version, etc).

I'll post QtC config if it happens again.

Comment 7 Sandro Mani 2020-10-20 11:02:46 UTC
ok thanks - closing for now

Comment 8 Alexey Dobriyan 2020-10-26 16:44:14 UTC
Steps to reproduce:

1) get clean checkout of kernel tree

    $ git clone -s linux-linus linux-1
    $ cd linux-1

2) prepare kernel for out of tree compiling

    $ mkdir ../obj
    $ make O=../obj ARCH=x86_64 allyesconfig
    $ make O=../obj ARCH=x86_64 prepare

3) execute the following script from kernel top level directory

#!/bin/sh -ex
P=xxx
echo '-std=c17'                 >"$P.cflags"
echo '#define __KERNEL__'       >"$P.config"
echo '[General]'                >"$P.creator"
echo '-std=c++17'               >"$P.cxxflags"
git ls-tree -r HEAD --name-only | sort >"$P.files"
cat <<EOF >"$P.includes"
include
arch/x86/include
../obj/include
EOF

This is roughly what a kernel developer would do to get config option macros and correct includes.

Watch QtC segfault somewhere in the middle of parsing progress.

Deleting "../obj/include" make segfault go away,
but it is needed if you're compiling out-of-tree and want QtC to see through most config options.

As an example, "c task_struct" will open "struct task_struct" definition and CONFIG_SMP should be
defined to "1" if everything works.

Comment 9 Alexey Dobriyan 2020-10-26 16:46:15 UTC
The other way is to get clean checkout, "import project", ignore SCM, quit
and the replace project files with a script (filename list will most certainly be wrong).

Comment 10 Sandro Mani 2020-10-26 16:47:37 UTC
I've resubmitted a scratch build for qt-creator-4.13.2 here [1]. Please test with that version once it's done building.

[1] https://koji.fedoraproject.org/koji/taskinfo?taskID=54260114.

Comment 11 Alexey Dobriyan 2020-10-31 13:14:42 UTC
I've upgraded to F33 with 4.13.2-1.fc33

same pattern, same place in libCPlusPlus.so.4.13.2

Thread (pooled)[14803]: segfault at 0 ip 00007f5067aa2631 sp 00007f502a7f8570 error 4 in libCPlusPlus.so.4.13.2[7f5067a4a000+c2000]
Code: 41 c7 45 18 00 00 00 00 49 89 45 00 8b 45 1c 8d 50 01 89 55 1c 41 89 45 08 48 c7 04 24 00 00 00 00 e8 23 7c fa ff 48 8b 3c 24 <48> 8b 07 ff 90 e8 00 00 00 49 8d 55 18 be 22 00 00 00 48 89 ef 49

Comment 12 Alexey Dobriyan 2020-10-31 13:45:49 UTC
The segfaulting file is

    drivers/net/ethernet/ibm/ibmvnic.c

Comment 13 Alexey Dobriyan 2021-01-21 21:48:25 UTC
I've debugged this stuff more.

The offending code is at drivers/net/ethernet/ibm/ibmvnic.c

  5075  static void ibmvnic_tasklet(struct tasklet_struct *t)
  5076  {
  5077          struct ibmvnic_adapter *adapter = from_tasklet(adapter, t, tasklet);
  5078          struct ibmvnic_crq_queue *queue = &adapter->crq;
  5079          union ibmvnic_crq *crq;
  5080          unsigned long flags;
  5081          bool done = false;
  5082
**5083  #ifdef CONFIG_IBMVNIC
  5084          spin_lock_irqsave(&queue->lock, flags);
  5085          while (!done) {
  5086                  /* Pull all the valid messages off the CRQ */
  5087                  while ((crq = ibmvnic_next_crq(adapter)) != NULL) {
  5088                          ibmvnic_handle_crq(crq, adapter);
  5089                          crq->generic.first = 0;
  5090                  }
  5091
  5092                  /* remain in tasklet until all
  5093                   * capabilities responses are received
  5094                   */
  5095                  if (!adapter->wait_capability)
  5096                          done = true;
  5097          }
  5098          /* if capabilities CRQ's were sent in this tasklet, the following
  5099           * tasklet must wait until all responses are received
  5100           */
  5101          if (atomic_read(&adapter->running_cap_crqs) != 0)
  5102                  adapter->wait_capability = true;
  5103          spin_unlock_irqrestore(&queue->lock, flags);
**5104  #endif
  5105  }

This driver is some PowerPC only driver, it is not compiled on x86_64,
so <asm/...> includes are wrong.

Inserting "#ifdef CONFIG_IBMVNIC" before spin_lock_irqsave() and
after spin_unlock_irqrestore() will make "broken" code disappear to the QT Creator parser.

If spin_lock_irqsave/spin_unlock_irqrestore pair is parsed then the crash appears.

Comment 14 Fedora Admin user for bugzilla script actions 2021-02-17 00:09:08 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.

Comment 15 Fedora Admin user for bugzilla script actions 2021-02-18 00:05:47 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.

Comment 16 Alexey Dobriyan 2021-04-19 18:46:48 UTC
https://bugreports.qt.io/browse/QTCREATORBUG-25606

Comment 17 Fedora Program Management 2021-04-29 16:40:28 UTC
This message is a reminder that Fedora 32 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 32 on 2021-05-25.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '32'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 32 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 18 Ben Cotton 2021-05-25 16:51:32 UTC
Fedora 32 changed to end-of-life (EOL) status on 2021-05-25. Fedora 32 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.