www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - longjmp Error: Access Violation

reply some where.com writes:
The following program runs correctly on Linux, but on Win2K it errors out:

H:\bug.exe
here!
Error: Access Violation

----------------------------------------------------------- bug.d ---------
import std.c.setjmp;

int main()
{
jmp_buf jb;
setjmp(jb);
printf("here!\n");
longjmp(jb, 1);
return 1;
}

----------------------------------------------------------- setjmp.d ---------
module std.c.setjmp;

extern (C)
{

struct __nt_context {
int esp; int info; int prev; int handler; int stable; int sindex; int ebp; };
/* Copyright (C) 1986-2001 by Digital Mars. $Revision: 1.1.1.1 $ */

/* Define _CRTAPI1 (for compatibility with the NT SDK) */

/* Define _CRTAPI2 (for compatibility with the NT SDK) */

/* Define CRTIMP */

alias int jmp_buf[16];

extern (C) int _setjmp(jmp_buf);
extern (C) int setjmp(jmp_buf);  /* prototype provided for backward
compatability */
extern (C) void longjmp(jmp_buf,int);

extern (C) int _inline_setjmp(jmp_buf);

/*
* Define jump buffer layout for setjmp/longjmp under NT that unwinds stack
*/
struct __JUMP_BUFFER {
uint Ebp;
uint Ebx;
uint Edi;
uint Esi;
uint Esp;
uint Eip;
uint Except_Registration; 
uint TryLevel;
uint Reserved;
uint Unwind_Handler;
uint ExceptData[6];
}

}

----------------------------------------------------------- setjmp.d ---------
May 06 2004
parent reply some where.com writes:
In article <c7fb8q$25oi$1 digitaldaemon.com>, some where.com says...
The following program runs correctly on Linux, but on Win2K it errors out:

H:\bug.exe
here!
Error: Access Violation

----------------------------------------------------------- bug.d ---------
import std.c.setjmp;

int main()
{
jmp_buf jb;
setjmp(jb);
printf("here!\n");
longjmp(jb, 1);
return 1;
}

----------------------------------------------------------- setjmp.d ---------
module std.c.setjmp;

extern (C)
{

struct __nt_context {
int esp; int info; int prev; int handler; int stable; int sindex; int ebp; };
/* Copyright (C) 1986-2001 by Digital Mars. $Revision: 1.1.1.1 $ */

/* Define _CRTAPI1 (for compatibility with the NT SDK) */

/* Define _CRTAPI2 (for compatibility with the NT SDK) */

/* Define CRTIMP */

alias int jmp_buf[16];

extern (C) int _setjmp(jmp_buf);
extern (C) int setjmp(jmp_buf);  /* prototype provided for backward
compatability */
extern (C) void longjmp(jmp_buf,int);

extern (C) int _inline_setjmp(jmp_buf);

/*
* Define jump buffer layout for setjmp/longjmp under NT that unwinds stack
*/
struct __JUMP_BUFFER {
uint Ebp;
uint Ebx;
uint Edi;
uint Esi;
uint Esp;
uint Eip;
uint Except_Registration; 
uint TryLevel;
uint Reserved;
uint Unwind_Handler;
uint ExceptData[6];
}

}

----------------------------------------------------------- setjmp.d ---------

Jun 04 2004
parent some where.com writes:
In article <c9r2a8$28hf$1 digitaldaemon.com>, some where.com says...
In article <c7fb8q$25oi$1 digitaldaemon.com>, some where.com says...
The following program runs correctly on Linux, but on Win2K it errors out:

H:\bug.exe
here!
Error: Access Violation

----------------------------------------------------------- bug.d ---------
import std.c.setjmp;

int main()
{
jmp_buf jb;
setjmp(jb);
printf("here!\n");
longjmp(jb, 1);
return 1;
}

----------------------------------------------------------- setjmp.d ---------
module std.c.setjmp;

extern (C)
{

struct __nt_context {
int esp; int info; int prev; int handler; int stable; int sindex; int ebp; };
/* Copyright (C) 1986-2001 by Digital Mars. $Revision: 1.1.1.1 $ */

/* Define _CRTAPI1 (for compatibility with the NT SDK) */

/* Define _CRTAPI2 (for compatibility with the NT SDK) */

/* Define CRTIMP */

alias int jmp_buf[16];

extern (C) int _setjmp(jmp_buf);
extern (C) int setjmp(jmp_buf);  /* prototype provided for backward
compatability */
extern (C) void longjmp(jmp_buf,int);

extern (C) int _inline_setjmp(jmp_buf);

/*
* Define jump buffer layout for setjmp/longjmp under NT that unwinds stack
*/
struct __JUMP_BUFFER {
uint Ebp;
uint Ebx;
uint Edi;
uint Esi;
uint Esp;
uint Eip;
uint Except_Registration; 
uint TryLevel;
uint Reserved;
uint Unwind_Handler;
uint ExceptData[6];
}

}

----------------------------------------------------------- setjmp.d ---------


Jun 08 2004