Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Segmentation fault in dissector

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Tue, 27 Mar 2007 19:35:54 -0700

On Mar 27, 2007, at 6:36 AM, durgabhavani.uppuluru@xxxxxxxxx wrote:

We are using a 32 bit machine and dissector is working fine. The same dissector when used in a 64 bit m/c is giving problems.

Is this a dissector you've written?

If so, are you

1) calling routines without including the appropriate header file that declares them (e.g., <epan/emem.h> to declare "ep_alloc()"?

	2) putting pointer values into an "int" or "unsigned int" variable?

Both of those can cause problems in LP64 environments; your 64-bit environment is probably LP64, meaning that an int is half the size of a pointer, so

1) if you call a function that returns a pointer, such as ep_alloc(), without including the appropriate header to declare that function, the compiler will think it returns an int, and will generate code that will throw away 32 of the 64 bits of the pointer;

2) if you stuff a pointer value into an "int" or "unsigned int" variable, the upper 32 bits of the pointer variable will be thrown away;

and in both cases, if the 32-bit int value is converted back into a pointer, there's a good chance that it won't point to a valid location in your address space, and an attempt to dereference the pointer will cause the application to crash.

I would like to know how is it going to get affected in the change of environment, because initially it did not even compile properly .While testing in a 64 bit machine the wireshark is getting crashed giving the following error:

Inside unpack digits , length = 29 and offset is = 18


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 182924546464 (LWP 1776)]
0x0000002a9b46afb7 in unpack_digits (tvb=0x10dfbd8, offset=18, dgt=0x2a9b588e78) at packet-xxx.c:4488
4488                    digit_str[i] = dgt->out[octet & 0x0f];

What are the values of "digit_str", "dgt" and "dgt->out" at that point?