Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
37 user(s) are online (31 user(s) are browsing Forums)

Members: 1
Guests: 36

slygon, more...

Support us!

Headlines

 
  Register To Post  

Finding where a .library is allocated in memory ?
Not too shy to talk
Not too shy to talk


See User information
Hello

I have maded a .library but I encounters various crashes
After lots of investigations (including Enforcer on WinUAE)
I suppose now that library code is trashed at some moment so causing crash some time after

So my goal is to check periodically the .library "integrity"
So my idea :
Make a copy of the .library memory block
Check the changes original vs copy periodically
So find when the trashing happen

So the question : How can I find where a .library is allocated in memory ??

Thank

Alain Thellier

Go to top
Re: Finding where a .library is allocated in memory ?
Just can't stay away
Just can't stay away


See User information
@thellier

I'm not certain to have well understood...

struct Library *resultat;

resultat=(struct Library *)FindName(&SysBase->LibList,"Wazp3D.library") ;

Go to top
Re: Finding where a .library is allocated in memory ?
Not too shy to talk
Not too shy to talk


See User information
Thanks
But no no I dont want know where is the LibraryBase but where the library code is

Alain

Go to top
Re: Finding where a .library is allocated in memory ?
Just can't stay away
Just can't stay away


See User information
@thellier
And the adress of "resultat" will not be OK for you ?

Go to top
Re: Finding where a .library is allocated in memory ?
Quite a regular
Quite a regular


See User information
@thellier
The library base should have a BPTR to SegList, if that's what you are looking for.

This is just like television, only you can see much further.
Go to top
Re: Finding where a .library is allocated in memory ?
Not too shy to talk
Not too shy to talk


See User information

I find this a rather strange idea. Trashed memory is usually caused by writing beying allocated memory. You can use a utility like Mungwall to find these hits.

Anyway, you can just reference any label in your program, for example like this:

#include <stdio.h>

void my_program_starts_here (void)

{
/* this is the very first routine in my program */
}

int main (void)

{

printf ("my program starts at 0x%lx\n",my_program_starts_here);

return (
0);
}


Go to top
Re: Finding where a .library is allocated in memory ?
Home away from home
Home away from home


See User information
@thomas

Executable memory might get trashed on 68k systems if a static string allocation is written to, overun or underun and the static allocations are mixed with code.

@theliier

If the above was the case then if you have an OS4 version of the library it would GR on access to that string.

The other option could be collateral damage of a corrupted stack.

Code related crashes can also occur when function pointers are passed with the wrong type.


Go to top
Re: Finding where a .library is allocated in memory ?
Not too shy to talk
Not too shy to talk


See User information

There shouldn't be any static or global variables in a .library. Libraries have to be reentrent.


Go to top
Re: Finding where a .library is allocated in memory ?
Just can't stay away
Just can't stay away


See User information
@thomas

Quote:

There shouldn't be any static or global variables in a .library. Libraries have to be reentrent.


For a disk based library it is no different than having global data in the library base structure like many OS libraries do. In either case you have to arbitrate access to the data somehow unless the data is meant to be read-only. This can be done with semaphores or mutexes for example.

Go to top
Re: Finding where a .library is allocated in memory ?
Not too shy to talk
Not too shy to talk


See User information
@thellier

If crashes are memory related, and after all, in any cases, check that the compiler helps you at the maximum. Have you activated warning options like: -Wall -Wextra -Wwrite-strings ?

Maybe compiling with another optimization level (that is to say -O0) would change the behavior and give a clue.

Another strategy would be to compile the library as a static library, crashes could be easier to track.

Maybe check on another system like OS4 (if that makes sense ... maybe your code is specific to UAE) or compile with vbcc that could warn on other things.

Go to top
Re: Finding where a .library is allocated in memory ?
Not too shy to talk
Not too shy to talk


See User information
Thanks to all

>The library base should have a BPTR to SegList, if that's what you are looking for.
How do I use it ? Example code ?


>if you have an OS4 version of the library it would GR on access to that string.
No the OS4 version crash later when accessing to some corrupted data not when trashing occurs
Both 68k and OS4 version crash


The problem occurs with my Microbe3D.library (*) when called from Arexx (it got an "Arexx support" function) I mean the "same" test program written in C works fine but crash in Arexx
Arexx parameters looks fine seen from inside Microbe3D.library
Then the Microbe3D function is called , begin normally (good parameters) then it crash at some point (like if the code or OS has been trashed)
Very strange


Alain

(*) See what is Microbe3D here:
https://www.youtube.com/results?search_query=Microbe3D

Go to top
Re: Finding where a .library is allocated in memory ?
Home away from home
Home away from home


See User information
@thellier

Quote:


The problem occurs with my Microbe3D.library (*) when called from Arexx (it got an "Arexx support" function) I mean the "same" test program written in C works fine but crash in Arexx
Arexx parameters looks fine seen from inside Microbe3D.library
Then the Microbe3D function is called , begin normally (good parameters) then it crash at some point (like if the code or OS has been trashed)
Very strange



Does it need much stack? Odds are your C program will have more than rexxmast has by default.

Try bumping the stack in the rexxmast program icon.



Go to top
Re: Finding where a .library is allocated in memory ?
Not too shy to talk
Not too shy to talk


See User information
@Broadblues

You are right : this is the stack
I have added that it my code
mytask=FindTask(NULL);
a=(ULONG)mytask->tc_SPLower;
b=(ULONG)mytask->tc_SPUpper;
s=b-a;

and the stack size s is 4096 bytes
If i change the stack in the icon = it is still 4096
If i change the stack in rexxmast icon = it is still 4096

:-/

Where do I change the stack for arexx scripts ?

I mean I have an arexx script that call my Microbe3D.library
(this lib got an arexx support fuction that make it callable from arexx scripts)

Alain Thellier



Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project