Page 2 of 3

Posted: Tue May 27, 2008 6:49 am
by Mistrel
This bug is still preventing TailBite from functioning properly with PureBasic 4.20. Is this a PureBasic bug or a TailBite bug?

http://www.purebasic.fr/english/viewtopic.php?t=32585

Posted: Tue May 27, 2008 12:04 pm
by Fred
It's definitely a tailbite bug, how could it be a PB one ?

Posted: Tue May 27, 2008 12:15 pm
by gnozal
<Asks humbly> Some hint on how to fix this tailbite issue would be great !
I am no asm guru myself.

Posted: Tue May 27, 2008 12:22 pm
by Fred
The tailbite function should change the 'Ret' line to:

Code: Select all

RET    X+4 
Only when a string is returned. It should work then.

Posted: Tue May 27, 2008 1:54 pm
by srod
Fred wrote:The tailbite function should change the 'Ret' line to:

Code: Select all

RET    X+4 
Only when a string is returned. It should work then.
Yes - it works! :) (Tested with coffIT, manually editing the ASM files and creating the DESC file by hand. Tailbite should easily follow suit.)

Thanks Fred. Looking at it, the damn solution was obvious!!!

Can I ask why PB passes an extra parameter when calling compiled user lib functions?

Posted: Tue May 27, 2008 2:27 pm
by gnozal
It seems to work yes (I only made a few tests).
1. only add 'RET X + 4' to the exported functions, not the private functions
2. don't use exported functions in the library

I have just updated the custom Tailbite for jaPBe V3 : http://freenet-homepage.de/gnozal/TailBite.zip
Source included, search for 'PB4.20 fix'. It seems to work.
Sorry, it's not the ABBKlaus source, but I am more confortable with the old ElChoni source :oops:

Posted: Tue May 27, 2008 2:30 pm
by srod
gnozal wrote:2. don't use exported functions in the library
That should be fine Gnozal. I see no reason why that should be a problem.

Posted: Tue May 27, 2008 2:47 pm
by gnozal
srod wrote:
gnozal wrote:2. don't use exported functions in the library
That should be fine Gnozal. I see no reason why that should be a problem.
I made some tests, and it crashed.
I am probably doing something wrong, but imho the '+ 4' fix is only for the exported functions when called from the outside (PB), it's not right if the function is called from the library itself.
But then again, I am no asm guru.

Posted: Tue May 27, 2008 2:52 pm
by srod
Right, I'll have a crack at it! :)

Posted: Tue May 27, 2008 3:03 pm
by srod
gnozal wrote:
srod wrote:
gnozal wrote:2. don't use exported functions in the library
That should be fine Gnozal. I see no reason why that should be a problem.
I made some tests, and it crashed.
I am probably doing something wrong, but imho the '+ 4' fix is only for the exported functions when called from the outside (PB), it's not right if the function is called from the library itself.
But then again, I am no asm guru.
Confirmed. Crashes if one exported string function calls another! :( Yes, thinking about it -and considering the code posted by Klaus above, it's obvious now.

Mind you, in this case you'll just have to ensure that no function within a library calls a string function from the same library which is to be exported. Just add a 'dummy' function through which the exported string function operates.

Posted: Tue May 27, 2008 3:14 pm
by gnozal
srod wrote:Mind you, in this case you'll just have to ensure that no function within a library calls a string function from the same library which is to be exported. Just add a 'dummy' function through which the exported string function operates.
Yes, that's what I did for one test library.
I will check all my libs for this before recompiling them with PB4.20 final.

Posted: Tue May 27, 2008 11:49 pm
by ABBKlaus
Thanks Fred, i´m going to donate now :D

Posted: Wed May 28, 2008 1:09 am
by Fred
srod wrote:Can I ask why PB passes an extra parameter when calling compiled user lib functions?
PB could need to reuse this parameter value, after the function call. Before VC8, the parameter value was never changed by the called function (as it was pushed on the stack which is not in the function scope), so we could use a trick to get it back if needed. With VC8, this trick didn't work anymore (the function can modify the user-parameter stack), so we have to duplicate the push, to be able to get it back if needed.

Posted: Wed May 28, 2008 1:18 am
by Mistrel
Is there an inconsistency somewhere that prevents us from calling an exported function that returns a string from within the same library? I'm assuming that the ASM output is different between a Procedure and ProcedureDLL.

Would it be possible to keep the ASM the same so that we can call these functions again with TailBite?

Posted: Wed May 28, 2008 2:52 am
by Mistrel
Removed by Mistrel. (I fixed the problem)