Xvnc process at 100% CPU when idle - select

I have a very annyoing problem when running TigerVNC 1.3.1 in a Debian 7 virtual machine. After about one minute doing nothing in the VNC window, the Xvnc process goes up to 100% CPU usage. Once I move my mouse into the VNC window again, the CPU usage returns to normal. I believe that the function call select() is the culprit. Doing an "strace -p " gives me tons of this:
select(256, [0 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74], NULL, NULL, {0, 0}) = 0 (Timeout)
And "strace -c -p ":
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
78.19 0.001760 0 98445 select
21.81 0.000491 0 196889 setitimer
------ ----------- ----------- --------- --------- ----------------
100.00 0.002251 295334 total
I'm not an expert on system function calls, but all other processes I checked with these commands do not show that kind of behavior. Is it a bug in the tigervnc code or is there a way I can fix it?

I'd recommend you reset to default settings to see if everything becomes fine. I was a tightvnc user for a long time, until I switched to RealVNC (free edition). I'd suggest you give a try of it. The settings are almost identical to tightvnc. And it supports real cross machine text copy-and-paste.

Related

Debugging an unnecessary newline character in a Kubernetes secret

I have an environment variable called GOOGLE_MAPS_DIRECTIONS_API_KEY, populated by a Kubernetes secret YAML:
apiVersion: v1
kind: Secret
metadata:
name: google-maps-directions-api-secret
type: Opaque
data:
GOOGLE_MAPS_DIRECTIONS_API_KEY: QUl...QbUpqTHNJ
The secret was created by copy-pasting the result of running echo -n "AIz..." | base64 on my API key. I've provided the beginning and the end of the key in this code snippet, to show that there is no newline in the key included in the secret file.
Here is what I see when I run cat google-maps-directions-api-key-secret.yaml | hexdump -C:
00000000 61 70 69 56 65 72 73 69 6f 6e 3a 20 76 31 0a 6b |apiVersion: v1.k|
00000010 69 6e 64 3a 20 53 65 63 72 65 74 0a 6d 65 74 61 |ind: Secret.meta|
00000020 64 61 74 61 3a 0a 20 20 6e 61 6d 65 3a 20 67 6f |data:. name: go|
00000030 6f 67 6c 65 2d 6d 61 70 73 2d 64 69 72 65 63 74 |ogle-maps-direct|
00000040 69 6f 6e 73 2d 61 70 69 2d 73 65 63 72 65 74 0a |ions-api-secret.|
00000050 74 79 70 65 3a 20 4f 70 61 71 75 65 0a 64 61 74 |type: Opaque.dat|
00000060 61 3a 0a 20 20 47 4f 4f 47 4c 45 5f 4d 41 50 53 |a:. GOOGLE_MAPS|
00000070 5f 44 49 52 45 43 54 49 4f 4e 53 5f 41 50 49 5f |_DIRECTIONS_API_|
00000080 4b 45 59 3a 20 51 55 6c 36 59 56 4e 35 51 7a 68 |KEY: QUl6YVN5Qzh|
...
000000b0 51 62 55 70 71 54 48 4e 4a |QbUpqTHNJ|
000000b9
But! When I step into a Node.JS interpreter inside of the pod, I see the following:
> process.env.GOOGLE_MAPS_DIRECTIONS_API_KEY
'AIz...jLsI\n'
There is an auxiliary newline character appended to the end of the string!
This is, frankly, extremely frustrating. I have several questions on this subject.
Can you spot my error? E.g. at what point in the secret propagation pipeline am I accidentally inserting that newline?
What Unix command should I use to print a newline character to console in such a way that it is interpreted literally (as a \n), so that I can actually see it?
Is it considered bad practice to inject code removing trailing newlines from environment variables into my container image? I know this is not technically correct, but this hurts like hell.
If you previously created the secret without the -n option to echo, verify the Secret persisted in the API (kubectl get secret/google-maps-directions-api-secret -o yaml) matches the secret in your yaml file, and also verify the consuming app has been redeployed since the secret was updated with the correct value
I don't see anything odd with how your secret looks. As you alluded to, the first thing I would do is exec into the pod, drop into bash, and echo out the environment variable to confirm it's propagated incorrectly. After doing a quick test, the newline should show up fine with a printf:
printf '%s' $GOOGLE_MAPS_DIRECTIONS_API_KEY
If it looks fine when printing it from bash, then the issue is with how node is interpreting it. If it looks messed up, then you need to take another look at how you're generating it.
FYI if the result of process.env is actually your API key, you should revoke it ASAP as you just published it in your question.
As for whether it's bad practice to strip newlines, yes. This can cause unexpected issues down the line if an actual piece of secret information contains a newline.

AHK WinWait Memory Usage

I have an ahk script I use to enable the Printer button on a Crystal Reports dialog that for what ever reason is not enabled by default when used in Server 2008 R2. Anyways... the issue I am having is the process when running continues to stack memory each cycle. Its not like I am storing any contents to a variable that happens to not get cleared. What in this process uses memory resources that don't get released and is there anything I can implement to prevent this from happening?
You can see in this listing that the private memory just grows as usage goes on. I ended up having it initiate about 5 times and it went from about 1000k to 2000k.
The top entry is my test version I converted from WinWaitActive that was causing unnecessary CPU usage.
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
58 8 2312 6216 68 0.62 7828 showprinterbutton
55 8 1788 5508 67 32.39 6840 ShowPSPrinter
57 8 1864 6028 79 33.12 7184 ShowPSPrinter
55 8 1396 5084 67 1.29 7604 ShowPSPrinter
55 8 1796 5536 67 36.36 7856 ShowPSPrinter
55 8 1772 5444 67 37.27 9848 ShowPSPrinter
55 8 1740 5424 67 26.33 10300 ShowPSPrinter
55 8 1396 4992 67 0.84 11348 ShowPSPrinter
55 8 1396 5024 67 1.14 11460 ShowPSPrinter
55 8 1736 5604 67 355.93 11676 ShowPSPrinter
55 8 1396 4984 67 1.06 13364 ShowPSPrinter
55 8 1396 5132 67 0.81 13516 ShowPSPrinter
72 9 2048 6500 73 66.36 14072 ShowPSPrinter
55 8 1792 5504 67 59.92 15736 ShowPSPrinter
55 8 1400 4960 67 0.61 16340 ShowPSPrinter
57 8 1496 5848 79 0.98 18516 ShowPSPrinter
57 8 1500 5404 79 0.98 19048 ShowPSPrinter
55 8 1400 5000 67 0.51 22020 ShowPSPrinter
Here is the script contents I have that is then compiled to run as an EXE.
; Version: 1.2
; Dated: 03/31/2015 - Created
; Description: Enable a watch for page setup dialog and activate the print button for crystal reports
; Only allow one instance to run
#SingleInstance force
; Run with out a tray icon
#NoTrayIcon
; Getting loose with not requiring direct title menu values
SetTitleMatchMode, RegEx
; Start active watch for quick post menu
WaitForPS:
WinWait,Page Setup
{
Control,Show,,Button8,Page Setup,(optimize for screen display)
GoSub WaitForPS
}
; End of Script...
Right after the moment the window appears and the loop ran one time, WainWait immediately continues to the next statement because the window already exists, enables the control, and recursively invokes the loop again (gosub), so the code allocated for example 100 stack frames per second thus eventually exhausting the call stack.
Instead use an indefinite loop and before continuing wait for the window to close:
Loop
{
WinWait,Page Setup
Control,Show,,Button8,Page Setup,(optimize for screen display)
WinWaitClose
}

Mac OS - Deployd - mongod fails to start

I'm trying to use Deployd on my Mac. I've installed mongoDB and added it's bin folder to my $PATH - mongod runs perfectly with my user. The problem appears when I try to run Deployd, mongod fails to run.
I runned it with DEBUG=* dpdand the results I've got are:
starting deployd v0.8.0...
mongod starting mongod +0ms
mongod <Buffer 32 30 31 35 2d 30 33 2d 31 32 54 31 39 3a 34 30 3a 34 31 2e 30 36 30 2b 30 31 30 30 20 49 20 43 4f 4e 54 52 4f 4c 20 20 5b 69 6e 69 74 61 6e 64 6c 69 ... > +158ms
mongod <Buffer 32 30 31 35 2d 30 33 2d 31 32 54 31 39 3a 34 30 3a 34 31 2e 30 36 30 2b 30 31 30 30 20 49 20 43 4f 4e 54 52 4f 4c 20 20 5b 69 6e 69 74 61 6e 64 6c 69 ... > +2ms
server started with options {"port":2403,"db":{"host":"127.0.0.1","port":4660,"name":"-deployd"},"env":"development"} +44ms
socket.io:server initializing namespace / +0ms
socket.io:server creating engine.io instance with opts {"log level":0,"path":"/socket.io"} +1ms
socket.io:server attaching client serving req handler +1ms
mongod <Buffer 32 30 31 35 2d 30 33 2d 31 32 54 31 39 3a 34 30 3a 34 31 2e 31 30 36 2b 30 31 30 30 20 49 20 4e 45 54 57 4f 52 4b 20 20 5b 69 6e 69 74 61 6e 64 6c 69 ... > +5ms
internal-resources constructed +10ms
listening on port 2403
type help for a list of commands
dpd > mongod error: 1 +757ms
mongod killing mongod +0ms
Failed to start MongoDB (Make sure 'mongod' are in your $PATH or use dpd --mongod option. Ref: http://docs.deployd.com/docs/basics/cli.html)
The only way I've got deploy to run is with sudo dpd -d. I've changed /data/db's ownership from root to my user. I also changed the ownership of mongod and ./mongodb/bin.
Does someone knows what I'm missing?
Thanks in advance.
Try to pass the path to your mongod executable via the '-m' parameter
dpd -m /path/to/mongod/
as described here http://docs.deployd.com/docs/basics/cli.html
Have you ensured there are no extra mongo.lock and local files in your data folder.
I had the same issue and deleting these extra files solved the problem.
(I think these are generated when mongo is shut down ungracefully).

Crashing with Xcode 4.2 when I click on XIB files

I have been using Xcode 4.2 for the past month without incident. Two days ago I went back into my project to add some navbars to my app. When I clicked on .XIB (Either one) xcode came crashing down.
I tried launching a new project but it ended up with the same exact result. I sudo deleted xcode in its entirety and did a fresh installation. Still the problem persists unfortunately I cannot upgrade to the latest Xcode because the only mac I have access to is a 2006 macbook that is not compatible with Mountain Lion.
Below is my error message when Xcode launches.
It seems to be a cocoa issue but I am at a loss.
ASSERTION FAILURE in
/SourceCache/IDEInterfaceBuilderCocoaTouch/IDEInterfaceBuilderCocoaTouch-933/IBPlugin/Utilities/IBObjectMarshalling.m:179
Details: Interface Builder encountered an error communicating with
the iOS Simulator. "Interface Builder Cocoa Touch Tool" (431) failed
to launch and exited with status (null), signal 5. Please check
Console.app for crash reports for "Interface Builder Cocoa Touch Tool"
for further information. Function:
NSDistantObject
*IBAttachToCocoaTouchTool(IBCocoaTouchTargetRuntime *) Thread: {name = (null), num = 1} Hints: None Backtrace:
0 0x00000000008c184b -[IDEAssertionHandler
handleFailureInFunction:fileName:lineNumber:messageFormat:arguments:]
(in IDEKit) 1 0x0000000000061728 _DVTAssertionHandler (in
DVTFoundation) 2 0x00000000000746db _DVTAssertionFailureHandler (in
DVTFoundation) 3 0x000000001cfb7871 IBAttachToCocoaTouchTool (in
IDEInterfaceBuilderCocoaTouchIntegration) 4 0x000000001cfb7332
IBAskClassInTargetRuntimeForValueForKeyPathUsingResultMarshallerWithContext
(in IDEInterfaceBuilderCocoaTouchIntegration) 5 0x000000001cfb7118
IBAskClassInTargetRuntimeForValueForKeyPathUsingResultMarshallerWithContext
(in IDEInterfaceBuilderCocoaTouchIntegration) 6 0x000000001cfb7087
IBAskClassInTargetRuntimeForValueForKeyPathUsingResultMarshaller (in
IDEInterfaceBuilderCocoaTouchIntegration) 7 0x000000001cfb6b57
IBUserPresentableStringForTargetedDeviceFamily (in
IDEInterfaceBuilderCocoaTouchIntegration) 8 0x000000001cfe5ace
IBIPhoneOSSdkToDeploymentTargetMapping (in
IDEInterfaceBuilderCocoaTouchIntegration) 9 0x000000001cfe5b22
IBIPhoneOSSdkToDeploymentTargetMapping (in
IDEInterfaceBuilderCocoaTouchIntegration) 10 0x000000001cfec7cf
IBUIControlEventTypeToUIControlEventMask (in
IDEInterfaceBuilderCocoaTouchIntegration) 11 0x000000001ca4f44d
-[NSView(IBViewIntegration) ibWarnings:forDocument:withComputationContext:] (in
IDEInterfaceBuilderKit) 12 0x000000001cdec864
-[NSView(IBAppKitViewIntegration) ibSwizzledNSViewWarnings:forDocument:withComputationContext:] (in
IDEInterfaceBuilderCocoaIntegration) 13 0x000000001d00fbb2
IBUIViewSizeToFillView (in IDEInterfaceBuilderCocoaTouchIntegration)
14 0x000000001d01a451 IBMakeBarButtonItemFromPasteboardView (in
IDEInterfaceBuilderCocoaTouchIntegration) 15 0x000000001c9efb44
-[IBDocument rebuildWarnings] (in IDEInterfaceBuilderKit) 16 0x000000001c9efd4a -[IBDocument buildWarningsIfNeeded] (in
IDEInterfaceBuilderKit) 17 0x000000001c9efdae -[IBDocument warnings]
(in IDEInterfaceBuilderKit) 18 0x000000001caa305e -[IBIssueProvider
updateWarningsForOpenDocument:filePath:] (in IDEInterfaceBuilderKit)
19 0x000000001c9c93e7 -[IBIssueProvider updateOpenDocuments] (in
IDEInterfaceBuilderKit) 20 0x000000001caa2e85 __50-[IBIssueProvider
initWithIssueManager:extension:]_block_invoke_051 (in
IDEInterfaceBuilderKit) 21 0x00000000000210de
-[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:] (in DVTFoundation)
22 0x0000000096fe5acb NSKeyValueDidChange (in Foundation) 23
0x0000000096fca2b6 -[NSObject(NSKeyValueObserverNotification)
didChangeValueForKey:] (in Foundation) 24 0x00000000007ec026
-[IDEDocumentController addDocument:] (in IDEKit) 25 0x000000000081104d +[IDEDocumentController retainEditorDocument:] (in
IDEKit) 26 0x0000000000a00375 +[IDEDocumentController
_retainedNewEditorDocumentWithClass:forURL:withContentsOfURL:ofType:extension:error:]
(in IDEKit) 27 0x000000000081f0d0 +[IDEDocumentController
_retainedEditorDocumentForURL:type:error:] (in IDEKit) 28 0x000000000081ef25 +[IDEDocumentController
retainedEditorDocumentForNavigableItem:forUseWithWorkspaceDocument:error:]
(in IDEKit) 29 0x0000000000910acd
IDEUtilitySliceRetainedDocumentsForNavigableItems (in IDEKit) 30
0x00000000007e3cb6 -[IDEUtilityArea _rebuildStackWithNavigableItems:]
(in IDEKit) 31 0x00000000007e30d0 -[IDEUtilityArea
_rebuildCategoriesAndStack] (in IDEKit) 32 0x00000000007e2e23 __41-[IDEUtilityArea initWithNibName:bundle:]_block_invoke_0 (in IDEKit) 33 0x00000000001e7a55 -[DVTDelayedValidator doValidation:]
(in DVTKit) 34 0x0000000096fff86c __NSFirePerformWithOrder (in
Foundation) 35 0x0000000093db2dd2 __CFRunLoopDoObservers (in
CoreFoundation) 36 0x0000000093d6eced __CFRunLoopRun (in
CoreFoundation) 37 0x0000000093d6e3c4 CFRunLoopRunSpecific (in
CoreFoundation) 38 0x0000000093d6e1f1 CFRunLoopRunInMode (in
CoreFoundation) 39 0x0000000090447e04 RunCurrentEventLoopInMode (in
HIToolbox) 40 0x0000000090447af5 ReceiveNextEventCommon (in
HIToolbox) 41 0x0000000090447a3e
BlockUntilNextEventMatchingListInMode (in HIToolbox) 42
0x00000000987c6595 _DPSNextEvent (in AppKit) 43 0x00000000987c5dd6
-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) 44 0x00000000987881f3 -[NSApplication run] (in AppKit) 45
0x0000000098780289 NSApplicationMain (in AppKit) 46
0x0000000000001f3d 47 0x0000000000000002
If you really can't upgrade to xCode 4.4...
Do you use TimeMachine?
Try to rewind your complete system...

Why does my Perl CGI program return a server error?

I recently got into learning cgi and I set up an Ubuntu server in vbox. The first program I wrote was in Python using vim through ssh. Then I installed Eclipse on my Windows 7 station and created the exact same Perl file; just a simple hello world deal.
I tried running it, and I was getting a 500 on it, while the Python code in the same dir (/usr/lib/cgi-bin) was showing up fine. Frustrated, I checked and triple-checked the permissions and that it began with #!/usr/bin/perl. I also checked whether or not AddHandler was set to .pl. Everything was set fine, and on a whim I decided to write the same exact code within the server using vim like I did with the Python file.
Lo and behold, it worked. I compared them, thinking I'd gone mad, and they are exactly the same. So, what's the deal? Why is a file made in Windows 7 on Eclipse different than a file made in Ubuntu server with vim? Do they have different binary headers or something? This can really affect my development environment.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Testing.";
Apache error log:
[Tue Aug 07 12:32:02 2012] [error] [client 192.168.1.8] (2)No such file or directory: exec of '/usr/lib/cgi-bin/test.pl' failed
[Tue Aug 07 12:32:02 2012] [error] [client 192.168.1.8] Premature end of script headers: test.pl
[Tue Aug 07 12:32:02 2012] [error] [client 192.168.1.8] File does not exist: /var/www/favicon.ico
This is the continuing error I get.
I think you have some spurious \r characters on the first line of your Perl script when you write it in Windows.
For example I created the following file on Windows:
#!/usr/bin/perl
code goes here
When viewed with hexdump it shows:
00000000 23 21 2f 75 73 72 2f 62 69 6e 2f 70 65 72 6c 0d |#!/usr/bin/perl.|
00000010 0a 0d 0a 63 6f 64 65 20 67 6f 65 73 20 68 65 72 |...code goes her|
00000020 65 0d 0a |e..|
00000023
Notice the 0d - \r that I've marked out in that. If I try and run this using ./test.pl I get:
zsh: ./test.pl: bad interpreter: /usr/bin/perl^M: no such file or directory
Whereas if I write the same code in Vim on a UNIX machine I get:
00000000 23 21 2f 75 73 72 2f 62 69 6e 2f 70 65 72 6c 0a |#!/usr/bin/perl.|
00000010 0a 63 6f 64 65 20 67 6f 65 73 20 68 65 72 65 0a |.code goes here.|
00000020
You can fix this in one of several ways:
You can probably make your editor save "UNIX line endings" or similar.
You can run dos2unix or similar on the file after saving it
You can use sed: sed -e 's/\r//g' or similar.
Your apache logs should be able to confirm this (If they don't crank up the logging a bit on your development server).
Sure, it can.
One environment might have a module installed that the other might not.
Perl might be installed in different locations in the two environment.
The environments might have different versions of Perl.
The environments might have different operating systems.
The permissions might be setup incorrectly in one of the environments.
etc
But instead of speculating wildly like this, why don't you check the error log for what error you actually got?
No, they are just text files. Of course, it's possible to write unportable programs, trivially by using system() or other similar services which depend on the environment.