2

我正在使用 Kubuntu 12.04 中的 NetBeans 7.1 编写 Qt 4.8 程序(http://code.google.com/p/image-feature-detector/)(尽管在 Kubuntu 11.10 中也会发生同样的情况),我感到很抓狂当我尝试运行已编译的可执行文件时出错。该程序编译并完美运行,但突然有一天,在正确编译后,我尝试运行它时出现此错误。

如果我使用以下命令运行可执行文件,这就是我得到的sudo

error /var/tmp/kdecache-myuser is owned by uid 1000 instead of uid 0

如果我在没有得到的情况下运行可执行文件sudo

Segmentation fault (core dumped)

如果我用 运行可执行文件kdesudo,在提示密码出现窗口后,什么也没有发生。

如果我调试程序,调试会在到达 NetBeans 显示给我的程序反汇编部分的第二行的任何源代码行之前停止:

_ZN15QAbstractButton10setCheckedEb()
Stops here->_ZN15QAbstractButton10setCheckedEb+22: mov    0x8(%rdi),%rbp
_ZN15QAbstractButton10setCheckedEb+26: mov    %esi,%r12d
_ZN15QAbstractButton10setCheckedEb+29: movzbl 0x214(%rbp),%eax
_ZN15QAbstractButton10setCheckedEb+36: test   $0x1,%al
_ZN15QAbstractButton10setCheckedEb+38: je     0x7ffff74a10d0 <_ZN15QAbstractButton10setCheckedEb+192>
_ZN15QAbstractButton10setCheckedEb+44: mov    %eax,%edx
_ZN15QAbstractButton10setCheckedEb+46: shr    %dl
_ZN15QAbstractButton10setCheckedEb+48: and    $0x1,%edx
_ZN15QAbstractButton10setCheckedEb+51: cmp    %sil,%dl
_ZN15QAbstractButton10setCheckedEb+54: je     0x7ffff74a10d0 <_ZN15QAbstractButton10setCheckedEb+192>
_ZN15QAbstractButton10setCheckedEb+60: test   %sil,%sil
_ZN15QAbstractButton10setCheckedEb+63: je     0x7ffff74a1100 <_ZN15QAbstractButton10setCheckedEb+240>
_ZN15QAbstractButton10setCheckedEb+69: mov    %rsp,%rdi
_ZN15QAbstractButton10setCheckedEb+72: mov    %rbx,(%rsp)
_ZN15QAbstractButton10setCheckedEb+76: callq  0x7ffff70bd220 <_ZN11QMetaObject8addGuardEPP7QObject@plt>
_ZN15QAbstractButton10setCheckedEb+81: movzbl 0x214(%rbp),%eax
_ZN15QAbstractButton10setCheckedEb+88: mov    %r12d,%edx
_ZN15QAbstractButton10setCheckedEb+91: and    $0x1,%edx
_ZN15QAbstractButton10setCheckedEb+94: add    %edx,%edx
_ZN15QAbstractButton10setCheckedEb+96: and    $0xfffffffd,%eax
_ZN15QAbstractButton10setCheckedEb+99: or     %edx,%eax
_ZN15QAbstractButton10setCheckedEb+101: test   $0x20,%al
_ZN15QAbstractButton10setCheckedEb+103: mov    %al,0x214(%rbp)
_ZN15QAbstractButton10setCheckedEb+109: je     0x7ffff74a10e8 <_ZN15QAbstractButton10setCheckedEb+216>
_ZN15QAbstractButton10setCheckedEb+111: mov    %rbp,%rdi
_ZN15QAbstractButton10setCheckedEb+114: callq  0x7ffff749f9f0
_ZN15QAbstractButton10setCheckedEb+119: cmpq   $0x0,(%rsp)

我进行了实验并将所有权更改/var/tmp/kdecache-myuser/root(uid 0)。然后我运行我的可执行文件,sudo我得到一个“分段错误”错误,就像我在没有sudo. 另外,当我更改原始文件夹的权限时,/var/tmp/kdecache-looksLikeMd5Number/会创建一个具有权限的新文件夹。myuser/var/tmp/kdecache-myuser/

我很感激任何关于如何解决这个让我发疯的错误的建议。

4

2 回答 2

2

这不是一个答案,但它可能是重现您的问题的简单方法,同时证明这不是您自己的代码的问题。(你的问题的标题是我关注的地方:“错误:“/var/tmp/kdecache-your_user”归 uid 1000 而不是 uid 0 拥有。)

我认为您可以使用 kdialog(Ubuntu 上的包 kdebase-bin 的一部分)来复制此错误。我可以这样做,我希望找到一个解决方案(这就是我遇到你的问题的方式)。

脚步:

  1. 打开一个终端
  2. sudo apt-get install kdebase-bin
  3. 仍在终端中,输入:

    kdialog --error "blah blah blah."

  4. 预期结果:以普通用户身份执行此 kdialog 时没有错误。这就是我的实际结果。

  5. sudo -s (输入你的密码)
  6. 重复上面的命令:

    kdialog --error "blah blah blah."

  7. 预期结果 - 它应该可以正常工作。但是,您可能会看到与您的问题相同的错误。

这是我的实际结果:

$ kdialog --error "blah blah blah"
$ sudo -s
root> kdialog --error "blah blah blah"
Error: "/var/tmp/kdecache-computeruser" is owned by uid 1000 instead of uid 0.

您甚至可能会看到更多这样的错误。我已经通过各种 kdialog 测试得到了这些,就像上面的测试一样。

Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
Error: "/tmp/kde-your_user" is owned by uid 1000 instead of uid 0.
Error: "/tmp/ksocket-your_user" is owned by uid 1000 instead of uid 0.
kdeinit4: Shutting down running client.
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
Error: "/tmp/ksocket-your_user" is owned by uid 1000 instead of uid 0.
Error: "/tmp/kde-your_user" is owned by uid 1000 instead of uid 0.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
kbuildsycoca4 running...
Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0.
Home directory /home/your_user not ours.
于 2012-06-01T15:46:19.273 回答
0

哦,这个错误是一个愚蠢的错误。它在我的代码中,而不是在 KDE 中(是的,我们总是倾向于认为“这不是我的错!”......)而且它与su特权无关。正如我所怀疑的,它与指针有关。我只是想使用一个null指针函数,正是setChecked()来自QAbstractdButton实例的函数。是的,完全 -.- ... 程序编译正确,但是通过运行它,我得到了一个Segmentation fault,合乎逻辑的。

有趣的是,如果我使用sudo:运行程序会出现错误error /var/tmp/kdecache is owned by uid 1000 instead of uid 0。目前,如果我使用 运行程序,我会在控制台上收到相同的错误sudo,但之后程序运行正常。

于 2012-06-18T00:28:30.863 回答