hURL/AmiSSL crash on MorphOS

Discuss about plugins that don't have a dedicated forum
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hURL/AmiSSL crash on MorphOS

Post by airsoftsoftwair »

I don't see any of this documented in AmiSSL. Only the register convention of the LVOs is obviously documented. For callback functions I see no such specification.

But since the parameters aren't in the registers, they surely must be on the stack. But how exactly are they stored in the stack? I've tried to look for the "arg" parameter (the last callback parameter) like this:

Code: Select all

ULONG *stackptr = (ULONG *) REG_A7;
printf("STACK TOP: %p\n", stackptr[-1]);
But once again the values didn't match. So how to get this stuff from the stack?
Piru
Posts: 8
Joined: Sat Dec 21, 2019 10:42 pm

Re: hURL/AmiSSL crash on MorphOS

Post by Piru »

It seems AmiSSL doesn't specify the calling convention. In fact, it depends on the compiler specifics (gcc in this case). What a horrible design.

Considering the authors of this project I am not even surprised.
Piru
Posts: 8
Joined: Sat Dec 21, 2019 10:42 pm

Re: hURL/AmiSSL crash on MorphOS

Post by Piru »

But how exactly are they stored in the stack?
Stack grows upwards (pushing values to stack makes stack pointer get upwards in memory). So any parameters that might be there are on the positive side.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hURL/AmiSSL crash on MorphOS

Post by airsoftsoftwair »

Piru wrote: Sun Dec 22, 2019 9:53 pm It seems AmiSSL doesn't specify the calling convention. In fact, it depends on the compiler specifics (gcc in this case). What a horrible design.
Well, another reason for MorphOS team to come up with an in-house solution that uses a clear specification ;)
Piru wrote: Sun Dec 22, 2019 9:55 pm Stack grows upwards (pushing values to stack makes stack pointer get upwards in memory). So any parameters that might be there are on the positive side.
But shouldn't a7 be a pointer to the stack top?
Piru
Posts: 8
Joined: Sat Dec 21, 2019 10:42 pm

Re: hURL/AmiSSL crash on MorphOS

Post by Piru »

SP points to the current position where last value was pushed. SP begins at the very bottom of the stack (so called SPUpper) and "grows" upwards.

On 68k when a function is being called with stack parameters the stack inside the function will look like:

Code: Select all

SP+00 returnaddr
SP+ 4 arg1
SP+ 8 arg2
SP+12 arg3
Of course all this is also complicated by the fact that you can have part of the arguments in registers and ones that didn't fit in stack. And lets not get into varargs. Lets hope we don't need to worry about those.
Last edited by Piru on Sun Dec 22, 2019 10:14 pm, edited 1 time in total.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hURL/AmiSSL crash on MorphOS

Post by airsoftsoftwair »

Ok, figured it out, works correctly now. Thanks a lot for your help!
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hURL/AmiSSL crash on MorphOS

Post by airsoftsoftwair »

FWIW, I've also opened an issue at Github now.
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: hURL/AmiSSL crash on MorphOS

Post by jPV »

How about linking OpenSSL statically to the hURL plugin for MorphOS? hURL has different requirements for different platforms anyway, so maybe it could be ok?

We would avoid 3rd party requirements then... and it seems that AmiSSL v4 installer doesn't work properly with MorphOS Installer either... I'd have to examine that more closely some day, but it seems to fail to add the required lines to the S:user-startup. I didn't notice this earlier when updating old AmiSSL with existing assigns, but doing that on a fresh system seems to fail.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hURL/AmiSSL crash on MorphOS

Post by airsoftsoftwair »

jPV wrote: Mon Dec 23, 2019 8:58 am How about linking OpenSSL statically to the hURL plugin for MorphOS? hURL has different requirements for different platforms anyway, so maybe it could be ok?
This would bloat hurl.hwp to a 5MB+ binary that is loaded with the start of every Hollywood app. Not something very desirable IMHO...
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hURL/AmiSSL crash on MorphOS

Post by airsoftsoftwair »

Ok, it's fixed now. I hope I've found all OpenSSL functions that do callbacks. Here's a test binary: http://www.softwarefailure.de/tmp/hurl.lha

Code: Select all

- Fix [MorphOS]: Fixed hURL to be compatible with the 68k version of AmiSSL
Post Reply