strstr() in Solaris System


 
Thread Tools Search this Thread
Top Forums Programming strstr() in Solaris System
# 8  
Old 11-30-2012
Also, crashes with malloc() may be because of earlier bugs. If you free() an incorrect pointer, it may corrupt the heap -- causing the program to crash later instead of immediately, if you're unlucky. That can be hard to track down.
# 9  
Old 11-30-2012
I'd say crashes in malloc() and free() are almost ALWAYS because of earlier bugs in the use of dynamically-allocated memory.

That also includes overrunning your allocated memory. If you malloc a memory segment, and write too much data to it, you'll get the same result.

A SEGV, mostly likely.

For example:

Code:
char *ptr = ( char * ) malloc( 1 );
strcpy( ptr, "string" );

Actually, I lied - the above will probably work just fine. Why? Because malloc is required to return a pointer to memory "suitably aligned for any purpose". That means malloc implementations return bytes of memory in chunks of whatever size meets the alignment restrictions on whatever platform you're running - most likely 8 bytes.

So malloc( 1 ) will effectively return a pointer to what's most likely an empty 8-byte space in your heap.

That's just another reason why overrunning a malloc'd buffer sometimes causes problems and sometimes doesn't.
# 10  
Old 12-03-2012
Can any one provide the solution for the problem so that I can get it worked.
Thanks in Advance..
# 11  
Old 12-03-2012
Quote:
Originally Posted by jhon1257
Can any one provide the solution for the problem...
If you want more specific advice, provide more specific information.

Regards,
Alister
# 12  
Old 12-04-2012
Code:
void *mallocX(size_t vintNumberOfBytes)
{
                static const char *strRoutine = "mallocX";
        
                return (malloc(vintNumberOfBytes));
    }

While using the above code am getting the core dump error....
vintNumberOfBytes is the size of structure.
# 13  
Old 12-04-2012
There is no issue with this piece of code (outside the useless strRoutine declaration). The problem is elsewhere. Are you sure you get a bus error and not a segmentation fault ?
# 14  
Old 12-04-2012
Program terminated with signal 11, Segmentation fault.
This was the error i got and from the gdb i got the below error
Code:
#0  0xffffffff75b84d38 in t_splay () from /lib/64/libc.so.1
#1  0xffffffff75b84b9c in t_delete () from /lib/64/libc.so.1
#2  0xffffffff75b84778 in realfree () from /lib/64/libc.so.1
#3  0xffffffff75b850cc in cleanfree () from /lib/64/libc.so.1
#4  0xffffffff75b840d8 in _malloc_unlocked () from /lib/64/libc.so.1
#5  0xffffffff75b83fc8 in malloc () from /lib/64/libc.so.1
#6  0x0000000100016988 in mallocX (vintNumberOfBytes=3312) at Malloc.c:98
#7  0x000000010000f650 in IncreaseAListSize (robjAlist=0x100169440, vlngNewSize=1) at AList.c:1252
#8  0x000000010000fbec in AddToTailAL (robjAlist=0x100169440, vobjElementPtr=0x10031a960) at AList.c:1458
#9  0x0000000100006a9c in _ULOGTemplateList (vobjULOGAnalyzeDb=0x0) at ULOGAlerts.c:228
#10 0x00000001000073b0 in main (argc=6, argv=0xffffffff7fffe938) at ULOGAlerts.c:422


Last edited by Scott; 12-04-2012 at 06:38 AM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Linux/Solaris System Administrator to become a Linux/Solaris System Programmer?

Hi all What is the qualification required by Linux/Solaris System Administrator to become a Linux/Solaris System Programmer as to gain complete knowledge on computers. Thanks (1 Reply)
Discussion started by: Tlogine
1 Replies

2. UNIX for Dummies Questions & Answers

Help with Solaris file system

Hi, I have not worked on Solaris 10 that much. Need some help with this. I can't seem where the file or how the file systems are mounted. Please see the /etcvfstab below. more vfstab #device device mount FS fsck mount mount #to mount to fsck ... (3 Replies)
Discussion started by: samnyc
3 Replies

3. HP-UX

how to mount a file system from a solaris server into an hp-ux system

Hi all I wonder if its possible to mount on a hp-ux server a file system that was previously mounted on a solaris 10 server. The LUN is on NetApp stoarge. The problem on hp-ux I cannot do pvcreate on the lun (disk) because contains data. Any help will be appreciated FR (2 Replies)
Discussion started by: fretagi
2 Replies

4. Solaris

dual boot solaris/solaris zfs file system

Hi, I am running into a some problems creating a dual boot system of 2 solaris instances using ZFS file system and I was wondering if someone can help me out. First some back ground. I have been asked to change the file system of our server from UFS to ZFS. Currently we are using Solaris... (3 Replies)
Discussion started by: estammis
3 Replies

5. Solaris

Solaris 10 system requirements???

Hi guys, I have been using Solaris 10 virtually since a couple of weeks under VirtualBox. Now I want to run it on hardware as it doesn't seem to work well under VirtualBox, atleast to my knowledge. I have another system which I intend to run Solaris on, and it is as under. Processor:- Intel... (1 Reply)
Discussion started by: gabam
1 Replies

6. Solaris

Solaris 10 system hangs

Solaris 10 (Sun V210) System hangs every couple of months. Have to go into ALOM to reset. I did a consolehistory report and seen this in it. Failed to exec inetd_start method of instance svc:/network/bootps/udp:default: I/O error WARNING: /pci@1c,600000/scsi@2 (glm0): Resetting... (3 Replies)
Discussion started by: Joeentech
3 Replies

7. Solaris

How I can get System Performance on Solaris

Hi All, Can someone help me out knowing all commands for getting system performance on Solaris machines. Thanks in advance, Yagami Light. (5 Replies)
Discussion started by: Yagami
5 Replies

8. Solaris

rsh commands not getting executed from Solaris 10 System to AIX System

Hi Friends, I am trying to execute rsh commands from Solaris 10 system to AIX system. When I give; Solaris10# rsh <hostname> ls -l , it gives me an error rshd : 0826-826 The host name for your address is not known At the same time, Solaris10# rsh <hostname> ---- gives me remote shell of... (25 Replies)
Discussion started by: jumadhiya
25 Replies
Login or Register to Ask a Question