Re: why does this core dump on solaris and not on linux

From: You have no need to know (anjahnoaoed_at_fl.net.invalid)
Date: 05/29/05


Date: Sun, 29 May 2005 07:02:51 GMT

Abandoning the right to remain silent, nin234 at Wed, 19 Jan 2005 13:36:25
-0800 said:

> I am using system shared memory techniques, like shmget, shmat etc to
> create a shared memory segment and manipulate data. I get a core dump
> (SIGSEGV) when I run the daemon on Solaris. The same program works fine
> on Red hat enterprise linux.

If by "on Solaris" you mean "on Sparc hardware" you have to get alignment
right. If your code specifies an aligned object (e.g. pointer) it had
better be aligned correctly. Otherwise you *will* get core dumps.

> Here is the relevant section of code causing the problem.
>
> probeSession *pSession = reinterpret_cast<probeSession *>(shmStart +
>
> nO ffset);
>
> util::utilLog(ePROBE_LOG_ERROR, "Failed to %d. \n",
> pSession->captureRuleIndex)
>
> The access to the shared memory variable pSession->captureRuleIndex is
> the culprit.

So if pSession&0x03 != 0 (32 bit mode or 0x07 in 64 bit mode) you will get
a dump.

> Even on Solaris if i do as follows, It works fine.
>
> int nTest;
>
> memcpy (&nTest, &(pSession->captureRuleIndex), sizeof (int));
>
> util::utilLog(ePROBE_LOG_ERROR, "Failed to %d. \n", nTest);

memcpy has char parameters, so alignment does not matter. When you
reference the memcpy'd object it had better be correctly aligned.

> I want to avoid the memcpy for performance reasons. In the real world I
> want to access the entire struct (probeSession) which is about 1264
> bytes . So memcpy is an expensive operation for a real time packet
> capture system that I am working on.
>
> Ninan

-- 
Avoid reality at all costs.
$email =~ s/n(.)a(.)n(.)a(.)e(.+)invalid/$1$2$3$4$5au/;
icbm: 33.43.46S 150.59.27E


Relevant Pages

  • Re: why does this core dump?
    ... I get a core dump ... >(SIGSEGV) when I run the daemon on Solaris. ...
    (comp.unix.solaris)
  • Re: Debugging broken pipe
    ... I'm writing some code which stops due to a broken pipe on Solaris 8 (sparc ... It seems that the application doesn't give a core dump even though coredumps ... but dbx with Sun Studio will trap SIGPIPE. ...
    (comp.unix.programmer)
  • OpenSSH problems
    ... I am using OpenSSH 3.7.1p2-pwexp24 on Solaris 9 system. ... /var/adm/messages file shows that sshd tries to core dump. ... I have also noticed that establishing an ssh connection to this Solaris box ... often fails when I initiate the connection from my PC but ...
    (comp.security.ssh)
  • Re: readdir_r causes coredump?
    ... > I want to use readdir_r, but it always cause core dump. ... I use Solaris 2.7, ... > Following is my sample code: ... Don't use a char buffer. ...
    (comp.unix.programmer)