Page MenuHome GnuPG

libgpg-error: assertion error on Solaris/sparc
Closed, ResolvedPublic


In Ibraheem
Saleh report an assertion problem on Solaris 10 sparc with gcc 4.9.2

Tim Zingelman found a fix for this (see I'll
include this here completely:

On Mon, 11 May 2015, Ibraheem Saleh wrote:

Building libgpg-error 1.19 on Solaris 10 sparc with gcc 4.9.2 succeeds
without error but coredumps when trying to use it.

bmake test fails all 5 of the tests with the same assertion message:

gmake[2]: Entering directory
Assertion failed: !"sizeof lock obj", file posix-lock.c, line 119
Abort (core dumped)
FAIL: t-version

Anyone know whats going on or how to fix this?

I'm thinking that the problem is that in _gpgrt_lock_t the second
element ends up being 64 bit aligned (a long of padding after vers)
giving a total sizeof=32 and no such alignment happens for
gpgrt_lock_t so sizeof=28. I added a printf before the assert and it
reported those two exact different sizes, so that supports the theory.

typedef struct

long _vers;
union {
  volatile char _priv[24];
  long _x_align;
  long *_xp_align;
} u;

} gpgrt_lock_t;

typedef struct

long vers;


union {
  pthread_mutex_t mtx;
  long *dummy;
} u;

} _gpgrt_lock_t;

I just tested on Solaris 10 Sparc and the following patch resolves the
problem. I'm not sure if this patch is appropriate for all platforms
or only Sparc. If someone else has the cycles to pass this fix
upstream that would be great.
(Also note I did NOT take out the patch from
patches/patch-src_estream.c when testing this fix... it seemed
unrelated to the assert failure.)

  • src/gen-posix-lock-obj.c.orig Thu Nov 5 16:44:59 2015

+++ src/gen-posix-lock-obj.c Thu Nov 5 16:49:19 2015
@@ -109,7 +109,7 @@

"  union {\n"
"    volatile char _priv[%d];\n"
  • " long _x_align;\n"

+ " long long _x_align;\n"

"    long *_xp_align;\n"
"  } u;\n"
"} gpgrt_lock_t;\n"



Event Timeline

wiz set Version to 1.19.
wiz added a subscriber: wiz.
gniibe added a project: Restricted Project.Feb 26 2016, 2:28 AM

Thank you for the patch.
I don't have the environment, but I asked the original reporter to test.
Sadly, his reply is negative, see:

Let me clarify/confirm. Does it work on Solaris? And now do you speak for NetBSD?
My fix is specific to Solaris (no matter if it's Sparc or not). It doesn't
handle any issues for NetBSD.

I seems that Sparc GNU/Linux doesn't have this alignment issue, but (for me) it
is highly likely that sparc architecutre requires the alignment of 8-byte.

I'm working on pkgsrc, which is a portable packaging system origination on
NetBSD. I myself work mostly on NetBSD.

However, we have patches for non-NetBSD platforms in pkgsrc, and this patch was
worked on by the two people mentioned earlier. Since I can not test on Solaris,
I asked them to test on Solaris, and Ibraheem did that.

I hope that clears it up.

Thank you for clarification. I didn't know that pkgsrc supports other
platforms. Now, I understand.

I changed more:;a=commitdiff;h=34b07146bbb0863436fc9381a84314b18bdfb807;hp=49655fb6ef39b307787e1b6e00c996f9c7db64f7

The intention is that USE_DOUBLE_FOR_ALIGNMENT for Solaris 32-bit version.
I thought that checking ILP32 worked (but not, in fact). I believe that LP64
checking works (at least with GCC).

Ibraheem very kindly tested again. However, it is still not working completely.
He writes:

It's still core dumping... Out of curiosity, I explicitly defined

'USE_DOUBLE_FOR_ALIGNMENT 1' and the checks were passing on Solaris with no more
core dumps. I guess that means they're on the right track, just have to get the
preprocessor directives right for gcc and Solaris.

Full details are in

The attached is an analysis from the Solaris/SPARC point of view.

One of the possible SPARC specific fixes:

  • ./src/posix-lock-obj.h.orig Wed Apr 13 08:24:20 2016

+++ ./src/posix-lock-obj.h Wed Apr 13 08:24:25 2016
@@ -29,7 +29,7 @@

typedef struct

  • long vers;

+ long long vers;

union {
  pthread_mutex_t mtx;
  • ./src/gen-posix-lock-obj.c.orig Wed Apr 13 08:23:59 2016

+++ ./src/gen-posix-lock-obj.c Wed Apr 13 08:24:29 2016
@@ -66,7 +66,7 @@

int i;


struct {
  • long vers;

+ long long vers;

pthread_mutex_t mtx;

@@ -105,7 +105,7 @@

   union and include a long and a pointer to a long.  */
printf ("typedef struct\n"
  • " long _vers;\n"

+ " long long _vers;\n"

"  union {\n"
"    volatile char _priv[%d];\n"

@@ -138,7 +138,7 @@

printf ("/* Dummy object - no locking available.  */\n"
        "typedef struct\n"
  • " long _vers;\n"

+ " long long _vers;\n"

           "} gpgrt_lock_t;\n"
           "#define GPGRT_LOCK_INITIALIZER {%d}\n",

Note, that this was not fully tested on other platforms and might need
additional changes in the header files. I did some minor tests on
Solaris amd64/SPARCv9/SPARCv7, Linux amd64/SPARCv9.

Thank you for your patch. Yes, we already located the issue is the alignment.
I think that it were good if the MTX were placed at the head. While your patch
works, it changes ABI of the lock object for existing archs, unfortunately.

I fixed the detection of Solaris in:;a=commit;h=f7a77c5c236ecec846de9be46703026f9b01008f

And I believe that the bug reported here had gone.
Please test current development master.

This particular problem of assertion error, it was fixed in 1.22. So, I close this.
We also have T2378 for a possible change for Solaris/sparc. Please continue

gniibe removed a project: Restricted Project.