Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-09

Windows 32bit - FPC 3.0.4 Gets an Error - but not on Linux or Mac...

10 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ozz Nixon

[image: image.png]

When I evaluate the code - it is perfect. However, when I run the code, it raises a SIGSEGV - Segmentation fault. Yet, the code runs perfectly on Linux 64bit machine, and Mac 32bit.

Reply by email

Ozz Nixon
to Ozz Nixon

[image: image.png]
Okay, getting debugging... it appears, that 3.0.4 (or Windows) passing a Const Pointer is handled differently?

* The bottom grey line - shows RES = xD9020, however, the LapeOrdChar(show's it's 2nd parameter as 0x0 instead of xD9020). I was originally focusing on Params^[0] - but that is not the error - Result:Pointer is wrong address - even though the calling convention passed in the correct address. ** Again, this is only broken on my Windows compile. I use 2.6.4 on Linux 64bit, and 3.0.4 on Mac (which works) and on Windows. Same compile options (I compile via CLI).

O.

PM Ozz Nixon wrote 6 lines
[image: image.png] When I evaluate the code - it is perfect. However, when I run the code, it raises a SIGSEGV - Segmentation fault. Yet, the code runs perfectly on Linux 64bit machine, and Mac 32bit.

Reply by email

Ozz Nixon
to Alexander Grotewohl

This is 2 decade of development (and for 19 years worked flawlessly) - and in the last 6 months, the windows build is broken. Not sure if it is a 3.0.4 FPC issue, or, a change in the 3.x builds - that I am unaware of.

PM Alexander Grotewohl wrote 33 lines
or maybe don't use the variable name "result" because it might point to the special delphi "result" var and not yours? -- Alexander Grotewohl http://dcclost.com On Sep 28, 2019 4:15 PM, Alexander Grotewohl wrote: don't know off the top of my head but does the ord() bit segfault without assigning it to anything? like if the function only had writleln(ord())! or does the result:= section segfault using ord() without the pointers? my guess is it works on linux/mac purely by luck. but i could be wrong. -- Alexander Grotewohl http://dcclost.com On Sep 28, 2019 3:21 PM, Ozz Nixon wrote: [image: image.png] When I evaluate the code - it is perfect. However, when I run the code, it raises a SIGSEGV - Segmentation fault. Yet, the code runs perfectly on Linux 64bit machine, and Mac 32bit. _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Ozz Nixon
to Alexander Grotewohl:

Alexander, Its the calling line that is messing up.

TLapeImportedFunc(Ptr)(@Stack[StackPos - ParamSize], Res);

* Res has a value before executing that line. However, the called method receives the 2nd param as null.

Or is it in the definition:
TLapeImportedFunc = procedure(const Params: PParamArray; const Result: Pointer); {$IFDEF Using_CDECL}cdecl;{$ENDIF} <-- CDECL is enabled.

So, is a CDECL thing? A compile switch I need to enable/disable? Remove "const" everywhere? ... it has taken me 6 months to slow down and say, WTF. I can run everywhere but Windows. :-(

PM Alexander Grotewohl wrote 23 lines
don't know off the top of my head but does the ord() bit segfault without assigning it to anything? like if the function only had writleln(ord())! or does the result:= section segfault using ord() without the pointers? my guess is it works on linux/mac purely by luck. but i could be wrong. -- Alexander Grotewohl http://dcclost.com On Sep 28, 2019 3:21 PM, Ozz Nixon wrote: [image: image.png] When I evaluate the code - it is perfect. However, when I run the code, it raises a SIGSEGV - Segmentation fault. Yet, the code runs perfectly on Linux 64bit machine, and Mac 32bit. _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Ozz Nixon
to Ozz Nixon

It's a CDECL thing... :-(

Disabled Using_CDECL, and now the pointer passes to/from the imported functions. (Florian/Jonas/Michael - is this an expected issue on Windows?)

PM Ozz Nixon wrote 42 lines
Alexander, Its the calling line that is messing up. TLapeImportedFunc(Ptr)(@Stack[StackPos - ParamSize], Res); * Res has a value before executing that line. However, the called method receives the 2nd param as null. Or is it in the definition: TLapeImportedFunc = procedure(const Params: PParamArray; const Result: Pointer); {$IFDEF Using_CDECL}cdecl;{$ENDIF} <-- CDECL is enabled. So, is a CDECL thing? A compile switch I need to enable/disable? Remove "const" everywhere? ... it has taken me 6 months to slow down and say, WTF. I can run everywhere but Windows. :-( On Sat, Sep 28, 2019 at 3:16 PM Alexander Grotewohl wrote: > don't know off the top of my head but does the ord() bit segfault without > assigning it to anything? like if the function only had writleln(ord())! or > does the result:= section segfault using ord() without the pointers? > > my guess is it works on linux/mac purely by luck. but i could be wrong. > > -- > Alexander Grotewohl > http://dcclost.com > > On Sep 28, 2019 3:21 PM, Ozz Nixon wrote: > > [image: image.png] > > When I evaluate the code - it is perfect. However, when I run the code, > it raises a SIGSEGV - Segmentation fault. Yet, the code runs perfectly on > Linux 64bit machine, and Mac 32bit. > > > _______________________________________________ > fpc-devel maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel >

Reply by email

Sven Barth
to Ozz Nixon

Ozz Nixon schrieb am Sa., 28. Sep. 2019, 22:53:

Show quoted text 5 lines
It's a CDECL thing... :-( Disabled Using_CDECL, and now the pointer passes to/from the imported functions. (Florian/Jonas/Michael - is this an expected issue on Windows?)

It would help if you'd provide a self contained example that demonstrates the problem.

Regards,
Sven

Reply by email

Ozz Nixon
to Sven Barth

I agree - but it is over 2 million lines of code. And disabling CDECL on the windows build of my compiler/interpreter, fixed the issue.

Now, my only problem is when I run the compiler with no parameter it returns back to C:> with a trailing letter. If I trace in FPC.EXE, it does not produce this stray C:>d prompt with a Halt(0).

On Sat, Sep 28, 2019 at 6:35 PM Sven Barth via fpc-devel <

Show quoted text 20 lines
wrote: Ozz Nixon schrieb am Sa., 28. Sep. 2019, 22:53: > It's a CDECL thing... :-( > > Disabled Using_CDECL, and now the pointer passes to/from the imported > functions. (Florian/Jonas/Michael - is this an expected issue on Windows?) > It would help if you'd provide a self contained example that demonstrates the problem. Regards, Sven > _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Cyrax
to Ozz Nixon: It's a CDECL thing... :-( Disabled Using_CDECL, and now the pointer passes to/from the…
Ozz Nixon wrote 5 lines
It's a CDECL thing... :-( Disabled Using_CDECL, and now the pointer passes to/from the imported functions. (Florian/Jonas/Michael - is this an expected issue on Windows?)

[clip]
By default, Windows uses stdcall calling convention when calling externally defined subroutines in dynamic link libraries. It depends also if the dynamic link library uses stdcall calling convention, too. Other platforms uses cdecl (unix/linux et al).

In your case it may be pascal default one calling convetion.

Reply by email