axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Schoofs" <tobias.scho...@pararede.com>
Subject Invalid access to memory location
Date Fri, 09 Feb 2007 11:33:51 GMT
Hi,
 
we're facing strange problems with a dll using axis-c (1.6b) on win32 machine.
 
1) We built a simple exe using the Calculator client class which works well.
2) We built a dll version with __stdcall convention which causes problems.
- We first built the dll without the /MD compiler flag. It worked but with strange effects.
(Memory was overwritten during the instantiation of the Calculator class.)
- we than built the dll with /MD flag which resulted in the following error:
exception in calclib: DLOPEN FAILED in loading parser library Failed to load parser within
server engine:
                 Error Message='Invalid access to memory location.
'                Error Code='998'
                 Load lib error=''
 
The code of the dll is:
 
int __stdcall add(int pOne, int pTwo) {
  char *tst = NULL;
  Calculator *calc = NULL; // static memory overwrites the stack!!!
  int rc = 0;

  try {
    calc = new Calculator();
    rc = calc->add(pOne, pTtwo);
    delete calc;    
    return rc;
  } catch (exception &e) {
    printf("exception in calclib: %s\n", e.what());
    return -1;
  }
}
 
Caller:
 
int main() {
  int rc = 0;
  int one = 10;
  int two = 35;
  try {
    rc = add(one, two);
  } catch (exception &e) {
    printf("Exception in calc: %s\n", e.what()); 
    return -1;
  }  
  if (rc > 0) { // it's just a simple test, so we're using values > 0 only
    printf("Result: %d\n", rc);
    return 0;
  } else {
    printf("Error: %d\n", rc);
    return -1;
  }
}
 
The header for both:
extern "C" int __stdcall add(int, int);
 
>From the makefile:
calclib.obj: calclib.cpp Calculator.hpp
 cl -c /MD /DWIN32 -GX /Ic:\ts\axis\include calclib.cpp 
 
calc.obj: calc.cpp
  cl -c -GX /MD /DWIN32 \
  calc.cpp
 
Calculator.obj: Calculator.cpp Calculator.hpp
  cl -c -GX /MD /DWIN32 /Ic:\ts\axis\include Calculator.cpp
 
calclib: calclib.obj Calculator.obj 
 cl /LD /MD calclib.obj \
  Calculator.obj \
  c:\\ts\\axis\\lib\\axis\\axis_client.lib \
  /link /EXPORT:add \
  /NODEFAULTLIB:"libc.lib"

calc: calc.obj
 cl  /MD \
  calclib.lib calc.obj \
 /link /NODEFAULTLIB:"libc.lib" 
 
Any ideas?
 
Tank you,
 
Tobias
 

Mime
View raw message