🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Colin B Maharaj Tue, 22 Jan 2008 14:10
DLL and currency issues
#739
Author: Colin B Maharaj
Date: Tue, 22 Jan 2008 14:10
50 lines
2202 bytes
Hi all,  I wrote this sorting DLL years ago
works fine and all. However recently I started
using the DLL more than once at a time, via
the current win user and a web user.

This is a sorting DLL.
However whenever, the web or win user process
start and concurrency begins, and ends an access
violation ensues.

Here is the DLL wrapper code



//---------------------------------------------------------------------------
// The procID and Sequence number are to make
// unique temporary file sets in the DLL
// so file names would not collide in the sorting
// process.
//---------------------------------------------------------------------------

typedef void (__stdcall *lpSortWrapperDLL)(char *, int, int, char *, 
char *);


void SortWithDLL(char *cmdline,  int procID, int SeqNo, char *InF, char 
*OutF)
{
   HINSTANCE lpDLL = LoadLibrary("CTSORT.DLL");
   lpSortWrapperDLL SortWrapperDLL=NULL;

   if (lpDLL)
   {
       SortWrapperDLL = (lpSortWrapperDLL) GetProcAddress(lpDLL, 
"SortWrapperDLL");
       if (SortWrapperDLL) SortWrapperDLL(cmdline, procID, SeqNo, InF, 
OutF);

     if (!SortWrapperDLL)
     {
       ErrorMessage("Function not found in DLL!");
     }

     FreeLibrary(lpDLL);
   }
   else
   {
     ErrorMessage("CTSORT.DLL is needed.");
   }
}
Re: DLL and currency issues
#740
Author: dhoke
Date: Tue, 22 Jan 2008 15:56
59 lines
2739 bytes
An access violation occurs where?

Doesn't look like it would happen in the code you presented, unless you have 
the same appl accessing that routine, and some of the items passed in via 
pointer are being freed underneath one of the invocations by a thread that 
used a different invocation...

"Colin B Maharaj" <noreply@myhost.com> wrote in message 
news:4795f94a$1@newsgroups.borland.com...
> Hi all,  I wrote this sorting DLL years ago
> works fine and all. However recently I started
> using the DLL more than once at a time, via
> the current win user and a web user.
>
> This is a sorting DLL.
> However whenever, the web or win user process
> start and concurrency begins, and ends an access
> violation ensues.
>
> Here is the DLL wrapper code
>
>
>
> //---------------------------------------------------------------------------
> // The procID and Sequence number are to make
> // unique temporary file sets in the DLL
> // so file names would not collide in the sorting
> // process.
> //---------------------------------------------------------------------------
>
> typedef void (__stdcall *lpSortWrapperDLL)(char *, int, int, char *, char 
> *);
>
>
> void SortWithDLL(char *cmdline,  int procID, int SeqNo, char *InF, char 
> *OutF)
> {
>   HINSTANCE lpDLL = LoadLibrary("CTSORT.DLL");
>   lpSortWrapperDLL SortWrapperDLL=NULL;
>
>   if (lpDLL)
>   {
>       SortWrapperDLL = (lpSortWrapperDLL) GetProcAddress(lpDLL, 
> "SortWrapperDLL");
>       if (SortWrapperDLL) SortWrapperDLL(cmdline, procID, SeqNo, InF, 
> OutF);
>
>     if (!SortWrapperDLL)
>     {
>       ErrorMessage("Function not found in DLL!");
>     }
>
>     FreeLibrary(lpDLL);
>   }
>   else
>   {
>     ErrorMessage("CTSORT.DLL is needed.");
>   }
> } 
Re: DLL and currency issues
#664
Author: Colin B Maharaj
Date: Sun, 17 Feb 2008 23:53
19 lines
1738 bytes
OK after a month of checking (on and off)
I revisited the DLL I wrote, and the code
was horrible. I wrote this about 6 years ago...
problems were....

1. No proper encapsulation of variables with objects
    (I was using global variables)
2. Non thread safe code and function calls.
3. Same temporary file names used throughout
    (ridiculous when running con-currently)
4. Other concurrency issues.

I must admit I learn't a lot about multi-threading
design in the last few years - now onto SMP!

dhoke wrote:
> An access violation occurs where?
> 
> Doesn't look like it would happen in the code you presented, 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads