Question

I'm coding a Qt 4.8 program (http://code.google.com/p/image-feature-detector/) with NetBeans 7.1 in Kubuntu 12.04 (although with Kubuntu 11.10 the same happens) and I'm getting a maddening error when I try to run the executable compiled. The program compiled and run perfectly but suddenly one day I got this error when, after a proper compilation, I tried to run it.

This's what I got if I run the executable with sudo:

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

If I run the executable without sudo I get:

Segmentation fault (core dumped)

And if I run the executable with kdesudo, after appearing the window by prompting the password, nothing happens.

If I debug the program, the debug stops prior to reach any line of source code at the second line of this disassembled portion of the program that NetBeans shows me:

_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)

I experimented and changed the ownership of /var/tmp/kdecache-myuser/ to root (uid 0). Then I run my executable with sudo and I got a "Segmetation fault" error like if I'd run the program without sudo. Plus, a new /var/tmp/kdecache-looksLikeMd5Number/ folder is created with myuser permissions, when I changed the permissions of the original /var/tmp/kdecache-myuser/ folder.

I'd appreciate any suggestion about how to solve this error which is turning me crazy.

Was it helpful?

Solution 2

Ouh, the mistake was a stupid one. It was in my code, not in KDE (yes, we always tend to think "this can't by my fault!"...) and it hadn't relation with su privileges. As I was suspecting, it was related with pointers. I was just trying to use a function of a null pointer, exactly the function setChecked() from a QAbstractdButton instance. Yes, utterly -.- ... The program compiled rightly, but by running it I obtained a Segmentation fault, logically.

The intriguing thing was the error I got if I run the program with sudo: error /var/tmp/kdecache is owned by uid 1000 instead of uid 0. Currently I get the same error on console if I run the program with sudo, but after it the program runs properly.

OTHER TIPS

This is not an answer, but it may be a simple way to reproduce your problem while demonstrating that it is not a problem with your own code. (The title of your question is where I'm focusing: "Error: "/var/tmp/kdecache-your_user" is owned by uid 1000 instead of uid 0".)

I think you can use kdialog (part of the package kdebase-bin on Ubuntu) to replicate this error. I can do so, and I'm hoping to find a solution (which is how I came upon your question).

Steps:

  1. open a terminal
  2. sudo apt-get install kdebase-bin
  3. still in the terminal, enter:

    kdialog --error "blah blah blah."

  4. Expected result: no errors while executing this kdialog as normal user. And that is my actual result.

  5. sudo -s (enter your password)
  6. repeat the above command:

    kdialog --error "blah blah blah."

  7. expected result - it should work without errors. However, what you will probably see is the same error as in your question.

Here are my actual results:

$ 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.

You might even see a few more errors like this. I have gotten these with various kdialog tests just like the one above.

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top