longjmp crashes on Windows

Piotr Podsiadły" <ppodsiadly at mykolab.com> Piotr Podsiadły" <ppodsiadly at mykolab.com>
Sat Nov 16 08:22:15 PST 2013


On Saturday, 16 November 2013 at 14:41:46 UTC, Maxim Fomin wrote:
> What kind of problem you try to solve by manual defining system 
> data structures? Why not use platform independent valid 
> declarations? Why did you decide that _JBLEN is 64, 256, 528 
> according to version? Why did you decide that having _JBLEN 
> bytes filled with zeros is a valid value of jmp_buf object? Why 
> should setjmp/longjmp take buffer by reference?

I couldn't find these declarations for Windows in druntime (there 
is only POSIX version).
Values of _JBLEN are based on constants from headers from DMC 
(x86 version) and Visual Studio (x86_64 and ia64).

These are declarations copied from setjmp.h from DMC:

#define _JBLEN 16
typedef int jmp_buf[_JBLEN];

#define __CLIB	__cdecl
int __CLIB _setjmp(jmp_buf);
void __CLIB longjmp(jmp_buf,int);

jmp_buf is initialized by the first call to setjmp, so its 
initial value doesn't matter.
In C, arrays are alawys passed as a pointer - that's why I used 
ref.

> Try to use proper version of setjmp/jmp_buf from druntime.
> By the way, why did you decide to use it in D language in a 
> first place?

I'm trying to use libpng and libjpeg directly from D, without any 
wrappers.
These libraries use longjmp to handle errors (the only 
alternative is to call exit() or abort()).


More information about the Digitalmars-d-learn mailing list