🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.debian.bugs.dist
5 messages
5 total messages Started by Tobias Hansen Mon, 16 Nov 2026 19:40
Bug#1154190: libpari-dev: pari.h uses sigjmp_buf, so it fails to compile with -std=c17
#4769
Author: Tobias Hansen
Date: Mon, 16 Nov 2026 19:40
44 lines
3307 bytes
Package: libpari-dev
Version: 2.19.1-1
Severity: important
Affects: src:sagemath

Dear Maintainer,

since 2.19.1-1, the public PARI headers cannot be compiled in strict ISO C
mode (-std=c99/c11/c17), because they use the POSIX type sigjmp_buf, which
glibc's <setjmp.h> only declares when POSIX features are enabled:
  
   In file included from /usr/include/x86_64-linux-gnu/pari/pari.h:42,
                    from testfile.c:2:
   /usr/include/x86_64-linux-gnu/pari/paristio.h:206:3: error: unknown type name 'sigjmp_buf'; did you mean 'jmp_buf'?
     206 |   sigjmp_buf *iferr_env;
         |   ^~~~~~~~~~
   In file included from /usr/include/x86_64-linux-gnu/pari/pari.h:43:
   /usr/include/x86_64-linux-gnu/pari/paricom.h:42:15: error: unknown type name 'sigjmp_buf'; did you mean 'jmp_buf'?
      42 | extern THREAD sigjmp_buf *iferr_env;
         |               ^~~~~~~~~~
        
Minimal reproducer:
           
   $ cat t.c
   #include <pari/pari.h>
   int main(void) { pari_init(1000000, 2); pari_close(); return 0; }
   $ gcc -std=c17 t.c -lpari      # fails as above
   $ gcc -std=gnu17 t.c -lpari    # works
     
This breaks the build of sagemath, which compiles its C code with
-std=c17: its configure-time PARI version check fails, and so would the
Cython-generated C modules that include pari.h. sagemath built fine
against 2.19.0-1 with the same flags. C++ users are not affected, as g++
always defines _GNU_SOURCE.
  
A library header can't rely on the user enabling POSIX features. Could
the headers keep using jmp_buf in the public declarations, or otherwise
avoid requiring sigjmp_buf to be visible, so that pari.h works again with
strict ISO C compilers?

In sagemath I have worked around it for now by building with -std=gnu17.

Best,
Tobias
Bug#1154190: libpari-dev: pari.h uses sigjmp_buf, so it fails to compile with -std=c17
#4774
Author: Bill Allombert
Date: Mon, 16 Nov 2026 20:30
26 lines
2598 bytes
On Mon, Nov 16, 2026 at 07:37:22PM +0000, Tobias Hansen wrote:
> Package: libpari-dev
> Version: 2.19.1-1
> Severity: important
> Affects: src:sagemath
> 
> Dear Maintainer,
> 
> since 2.19.1-1, the public PARI headers cannot be compiled in strict ISO C
> mode (-std=c99/c11/c17), because they use the POSIX type sigjmp_buf, which
> glibc's <setjmp.h> only declares when POSIX features are enabled:

Hello Tobias,

Note that using the PARI headers without __GNUC__ defined can lead to significant
performance loss since that disables inline assembly, so it is not something we
should encourage. I would consider building a Debian package this way to be a bug.

That aside, if you want to use -std=c17, I suggest you also add -D_POSIX_C_SOURCE
Probably this problem could be fixed by adding #define _POSIX_C_SOURCE in pari.h

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 
Bug#1154190: libpari-dev: pari.h uses sigjmp_buf, so it fails to compile with -std=c17
#4776
Author: Bill Allombert
Date: Mon, 16 Nov 2026 21:20
50 lines
3826 bytes
On Mon, Nov 16, 2026 at 08:28:32PM +0000, John Scott wrote:
> Tobias Hansen wrote:
> > Could the headers keep using jmp_buf in the public declarations, or
> > otherwise avoid requiring sigjmp_buf to be visible, so that pari.h works
> > again with strict ISO C compilers?
> 
> I have some thoughts: currently the problematic part of the header is
> struct gp_context {
> 	…
> 	sigjmp_buf *iferr_env;
> 	…
> };
> 
> Note that the types sigjmp_buf and jmp_buf are not interchangeable,

In both glibc and musl we have

glibc:
/* Use the same type for `jmp_buf' and `sigjmp_buf'.
   The `__mask_was_saved' flag determines whether
   or not `longjmp' will restore the signal mask.  */
typedef struct __jmp_buf_tag sigjmp_buf[1];

musl:
typedef jmp_buf sigjmp_buf;

so it is not a ABI break.

Windows is handled by  #if !defined(HAS_SIGSETJMP)

> I also want to point out this note in the bug submitter's initial patch at
> https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2715
> > /* Darwin longjmp restores signal masks with sigprocmask, which changes the
> > masks of all threads.

> I don't believe this is POSIX-conforming behavior: although the POSIX
> language isn't totally crystal clear, the signal mask is a per-thread
> attribute, and I don't think setjmp()/longjmp()'s minimally-specified
> behavior with respect to signal masks is intended to permit mangling the
> signal masks of *other unrelated threads*. This broken behavior ought to be
> fixed if it really is present, by switching to pthread_sigmask() in its
> longjmp() implementation or similar.

Good luck getting macos to fix their pthread bugs...

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 
Bug#1154190: libpari-dev: pari.h uses sigjmp_buf, so it fails to compile with -std=c17
#4886
Author: Bill Allombert
Date: Tue, 17 Nov 2026 21:40
45 lines
3505 bytes
On Mon, Nov 16, 2026 at 09:28:23PM +0100, Bill Allombert wrote:
> On Mon, Nov 16, 2026 at 07:37:22PM +0000, Tobias Hansen wrote:
> > Package: libpari-dev
> > Version: 2.19.1-1
> > Severity: important
> > Affects: src:sagemath
> > 
> > Dear Maintainer,
> > 
> > since 2.19.1-1, the public PARI headers cannot be compiled in strict ISO C
> > mode (-std=c99/c11/c17), because they use the POSIX type sigjmp_buf, which
> > glibc's <setjmp.h> only declares when POSIX features are enabled:
> 
> Hello Tobias,
> 
> Note that using the PARI headers without __GNUC__ defined can lead to significant
> performance loss since that disables inline assembly, so it is not something we
> should encourage. I would consider building a Debian package this way to be a bug.

However it seems that using -std=c17 does not actually disable __GNUC__ so this is
not an issue here. 

> That aside, if you want to use -std=c17, I suggest you also add -D_POSIX_C_SOURCE
> Probably this problem could be fixed by adding #define _POSIX_C_SOURCE in pari.h

Indeed adding to pari.h the following fix the issue.

#  ifndef _POSIX_C_SOURCE
#    define _POSIX_C_SOURCE 1
#  endif

However, I am still unsure it is make sens to set -std=c17 without also setting _POSIX_C_SOURCE
to something. Sure the C code can do it for you but then, why using -std=c17 in the first place ?

For example from  feature_test_macros(7) 

       _POSIX_C_SOURCE
              Defining this macro causes header files to expose definitions as follows:
              •  The value 1 exposes definitions conforming to POSIX.1-1990 and ISO C (1990).

Cheers,
-- 
Bill. <ballombe@debian.org>

Imagine a large red swirl here. 
Bug#1154190: libpari-dev: pari.h uses sigjmp_buf, so it fails to compile with -std=c17
#4893
Author: Tobias Hansen
Date: Tue, 17 Nov 2026 22:10
47 lines
3869 bytes
On 17/11/2026 21:32, Bill Allombert wrote:
> On Mon, Nov 16, 2026 at 09:28:23PM +0100, Bill Allombert wrote:
>> On Mon, Nov 16, 2026 at 07:37:22PM +0000, Tobias Hansen wrote:
>>> Package: libpari-dev
>>> Version: 2.19.1-1
>>> Severity: important
>>> Affects: src:sagemath
>>>
>>> Dear Maintainer,
>>>
>>> since 2.19.1-1, the public PARI headers cannot be compiled in strict ISO C
>>> mode (-std=c99/c11/c17), because they use the POSIX type sigjmp_buf, which
>>> glibc's <setjmp.h> only declares when POSIX features are enabled:
>> Hello Tobias,
>>
>> Note that using the PARI headers without __GNUC__ defined can lead to significant
>> performance loss since that disables inline assembly, so it is not something we
>> should encourage. I would consider building a Debian package this way to be a bug.
> However it seems that using -std=c17 does not actually disable __GNUC__ so this is
> not an issue here.
>
>> That aside, if you want to use -std=c17, I suggest you also add -D_POSIX_C_SOURCE
>> Probably this problem could be fixed by adding #define _POSIX_C_SOURCE in pari.h
> Indeed adding to pari.h the following fix the issue.
>
> #  ifndef _POSIX_C_SOURCE
> #    define _POSIX_C_SOURCE 1
> #  endif
>
> However, I am still unsure it is make sens to set -std=c17 without also setting _POSIX_C_SOURCE
> to something. Sure the C code can do it for you but then, why using -std=c17 in the first place ?
>
> For example from  feature_test_macros(7)
>
>         _POSIX_C_SOURCE
>                Defining this macro causes header files to expose definitions as follows:
>                •  The value 1 exposes definitions conforming to POSIX.1-1990 and ISO C (1990).
>
> Cheers,

Hi,

I don't know why sagemath uses -std=c17. Maybe they just didn't have a reason not to use it until now.

Best,

Tobias
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads