Originally posted by: SystemAdmin
Hi again,
as suggested we upgraded our AIX system.
But we still have serious problems while developing UNICODE applications... I found out that wcsdup() had some troubles...
Here is an example where I successfully called 4 times my own wcsdup, and as soon as I call the standard one, it crashes...
[u]New environment[/u]
OS: AIX 5.3 level 5
Compiler: IBM XL C/C++ Enterprise Edition V8.0 for AIX (Version: 08.00.0000.0000) - Fixes were installed.
[u]Source code[/u]
code #include "wchar.h"
#include "stdarg.h"
#include "stdlib.h"
#include "memory.h"
wchar_t* my_wcsdup(const wchar_t* p)
{
int len = ((int) wcslen(p));
int size = (len+1)*sizeof(wchar_t);
wchar_t* newp = (wchar_t*) malloc(size);
memcpy(newp, p, size);
return newp;
}
int main(int argc, char** argv)
{
wchar_t* p1 = my_wcsdup(L"Hello1\n");
wprintf(p1);
wchar_t* p2 = my_wcsdup(L"Hello2\n");
wprintf(p2);
wchar_t* p3 = my_wcsdup(L"Hello3\n");
wprintf(p3);
wchar_t* p4 = my_wcsdup(L"Hello4\n");
wprintf(p4);
wchar_t* p5 = wcsdup(L"Hello5\n");
wprintf(p5);
return 0;
}
[/code]
[u]Compiling[/u]
/usr/vacpp/bin/xlc -g -D_AIX -Dunix -DNDEBUG -D_UNICODE -q64 unitest.cpp -o UnicodeUnix/AIX64/unitest.o
[u]Output[/u]
Hello1
Hello2
Hello3
Hello4
Segmentation fault (core dumped)
[u]Call Stack[/u]
leftmost(??, ??) at 0x90000000004fb1c
malloc_y(0x8, 0x0, 0x110000a4c, 0x0, 0x0, 0x0, 0x0, 0x0) at 0x900000000051ce4
malloc_common_52_36(??) at 0x90000000004edf4
malloc(??) at 0x90000000004ec3c
wprintf(0x110000a30, 0x1000007ec, 0x110000a4c, 0x0, 0x0, 0x0, 0x0, 0x0) at 0x900000000038c58
main(argc = 1, argv = 0x0ffffffffffffb98), line 33 in "unitest.cpp"
Really hoping that some of you with good UNICODE programming knowledge will help me to make this work... it starts becoming critical for us.
Thanks a lot,
Thomas
#AIX-Forum