[openssl-dev] Seg fault during make test
Stephan Mühlstrasser
stm at pdflib.com
Mon May 4 14:36:21 UTC 2015
Am 04.05.15 um 16:19 schrieb John Foley:
> I think you're wrong about sizeof and pointers. It'll return 4 or 8
> depending if it's a 32 or 64 bit system. Try the following code:
>
> #include <stdio.h>
>
> typedef struct _s1 {
> int x;
> int y;
> int z;
> } S1;
>
> typedef struct _s2 {
> double d1;
> double d2;
> double d3;
> double d4;
> int x1;
> int x2;
> } S2;
>
> int main (int argc, char *argv[]) {
> S1 *first;
> S2 *second;
>
> printf("%d %d\n", sizeof(first), sizeof(second));
> }
Yes, but that is different from what is relevant in the commit
53ba0a9e91ad203de2943edaf1090ab17ec435fa.
You're right that in your test program you will get always different
output on 32-bit and 64-bit systems because the pointer size is different.
But the code in the OpenSSL uses "sizeof(*pointer)" and not
"sizeof(pointer)". "sizeof(*pointer)" gets the size of the structure to
which "pointer" points.
So try the following in your test program
printf("%d %d\n", sizeof(*first), sizeof(*second));
This might return different output on 32-bit and 64-bit systems, but it
might also return the same output, depending on the size of the basic
types and the padding in the structures.
> You're right about the memset, good catch. So it appears there are two
> issues with this commit.
>
>
>
> On 05/04/2015 09:35 AM, Stephan Mühlstrasser wrote:
>> Am 04.05.15 um 14:51 schrieb John Foley:
>>> Is anyone seeing a segmentation fault during the test_verify phase of
>>> make test on 32-bit systems? I haven't done a full triage yet. But it
>>> appears to have been introduced by
>>> 5b38d54753acdabbf6b1d5e15d38ee81fb0612a2. The problem no longer occurs
>>> when backing out this commit. This could be a faulty commit since the
>>> sizeof invocations in this commit would return different values for
>>> 32/64 bit systems.
>>
>> The sizeof invocations do not return the pointer sizes, but the size
>> of the structures pointed to.
>>
>> The problem is that there's apparently a copy&paste error:
>>
>> https://github.com/openssl/openssl/commit/53ba0a9e91ad203de2943edaf1090ab17ec435fa
>>
>>
>> 172 memset(param, 0, sizeof *paramid);
>> 173 memset(paramid, 0, sizeof *paramid);
>>
>> The first memset should be fixed to use "*param" instead of "*paramid":
>>
>> memset(param, 0, sizeof *param);
>>
>> Regards
>> Stephan
>> _______________________________________________
>> openssl-dev mailing list
>> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
>>
>
> _______________________________________________
> openssl-dev mailing list
> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
>
More information about the openssl-dev
mailing list