Last friday I was assigned to look into an issue where the application is not able write into files, once it is up for more than one week. It is a 32-bit application running on Solaris (SPARC platform) and the error message says, too many open files. With little effort, we came to know that all those errors are due to the calls to fopen(), from the application.A little background on stdio's fopen():fopen() is part of stdio API. For a 32-bit application, a stdio library FILE structure represents the underlying file descriptor as an unsigned char...
Thursday, 26 May 2005
Friday, 20 May 2005
Behavior of Sun C++ Compiler While Compiling Templates
Posted on 17:46 by Unknown
When the C++ compiler finds a template declaration in a header (.h) file, the compiler needs the definition of the template to allow compilations to proceed faster (on average), because template definitions that are not used don't need to be processed. Hence the compiler automatically searches for a .cc or .C or .cpp etc file with the same name. If such a file exists, it is automatically included in the current compilation. Note that it is not separately compiled. This compiler behavior means that some source code organizations won't work with...
Thursday, 19 May 2005
Solaris: hijacking a function call (interposing)
Posted on 19:24 by Unknown
Sometimes it is necessary to alter the functionality of a routine, or collect some data from a malfunctioning routine, for debugging. It works well, as long as we have the access to source code. But what if we don't have access to source code or changes to the source code is not feasible? With dynamic libraries, it is very easy to intercept any call to a routine of choice, and can do whatever we wish to do in that routine, including calling the real routine the client intended to call. In simple words, the hacker (who writes the interposing library,...
Wednesday, 18 May 2005
Sun C/C++: Reducing symbol scope with Linker Scoping feature
Posted on 13:51 by Unknown
This article was published on Sun developer's portal at: http://developers.sun.com/tools/cc/articles/symbol_scope.htmlI have been working on this article for more than 3 months, and glad to learn quite a few new things, from the extensive feedback of Lawrence Crowl and Steve Clamage, of Sun C/C++ compiler team.Keywords:Linker Scoping, Global, Symbolic, Hidden, __global, __symbolic, __hidden, __declspec, dllexport, dllimport, xldscope, xldscoperef, linker map fi...
Friday, 13 May 2005
Csh: Arguments too long error
Posted on 21:21 by Unknown
Symptom:C-shell fails to execute commands with arguments using wildcard characters.eg.,% \rm -rf *Arguments too long% ls -l | wc 8462 76151 550202The reason for this failure is that the wildcard has exceeded C-shell limitation(s). The command in this example is evaluating to a very long string. It overwhelmed the csh limit of 1706, for the maximum number of arguments to a command for which filename expansion applies.Workarounds:Use multiple commands OrUse xargs utility% \rm -rf *Arguments too long% ls | xargs rm -rf% ls%Or% \rm -rf *Arguments...
Thursday, 12 May 2005
CPU hog with connections in CLOSE_WAIT
Posted on 15:45 by Unknown
Couple of days back I got a call at our partner's site, to look into an issue where one process (server) is hogging all the processing power with absolutely no load on the server. The server process is running on Solaris 9.% prstat 1 1 PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP 2160 QAtest 941M 886M cpu0 0 0 80:03:57 99% myserver/41 28352 patrol 7888K 6032K sleep 59 0 4:49:37 0.1% bgscollect/1 24720 QAtest 1872K 1656K cpu3 59 0 0:00:00 0.0% prstat/1 59 root 4064K 3288K sleep ...
Saturday, 7 May 2005
Solaris: Mounting a CD-ROM manually
Posted on 15:48 by Unknown
Get the device name in cxtydzsn format, associated with the CD drive% iostat -Enc1t0d0 Soft Errors: 149 Hard Errors: 0 Transport Errors: 0 Vendor: MATSHITA Product: CDRW/DVD UJDA740 Revision: 1.00 Serial No: Size: 0.56GB <555350016 bytes>Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 Illegal Request: 149 Predictive Failure Analysis: 0-E displays all device error statistics & -n shows the names in descriptive format. We are interested in only the logical device name though.slice 0 is the defaultMount the device...
Wednesday, 4 May 2005
C/C++: global const variables, symbol collisions & symbolic scoping
Posted on 17:57 by Unknown
(Most of the following is "generic" C/C++. Sun Studio compilers were used to compile the code and to propose a solution to symbol collision problem)The way C++ handles global const variables is different from C. In C++, a global const variable that is not explicitly declared extern has static linkage.In C, global const variables will have extern linkage by default, and global variables can be declared more than once. As long as a single initialization (at most) for the same variable is used, the linker resolves all the repeated declarations into...
Monday, 2 May 2005
C/C++: Printing Stack Trace with printstack() on Solaris
Posted on 01:23 by Unknown
libc on Solaris 9 and later, provides a useful function called printstack, to print a symbolic stack trace to the specified file descriptor. This is useful for reporting errors from an application during run-time.If the stack trace appears corrupted, or if the stack cannot be read, printstack() returns -1.Programmatic example:% more printstack.c#include <stdio.h>#include <ucontext.h>int callee(int file) { printstack(file); return (0);}int caller() { int a; a = callee (fileno(stdout)); return (a);}int...
Subscribe to:
Posts (Atom)