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.
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
suprivileges. As I was suspecting, it was related with pointers. I was just trying to use a function of anullpointer, exactly the functionsetChecked()from aQAbstractdButtoninstance. Yes, utterly -.- … The program compiled rightly, but by running it I obtained aSegmentation 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 withsudo, but after it the program runs properly.