AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  simplest unicode c program crashing on AIX 5.2

    Posted Fri June 23, 2006 05:33 AM

    Originally posted by: SystemAdmin


    Dear experts,

    As stated in the title, I can't explain why this very simple program is crashing.

    [u]Environment:[/u]
    Hardware: pSeries 615 Model 6C3
    OS: AIX 5.2.0.0
    Compiler: Visual Age 6.0

    [u]Source:[/u]
    code#include "wchar.h"

    int main(int argc, char** argv)
    {
    wchar_t* pString = wcsdup(L"Hello\n");
    return 0;
    }[/code]
    [u]Compiling:[/u]

    /usr/vacpp/bin/xlc -D_AIX -Dunix -D_UNICODE -q64 unitest.cpp -o unitest

    [u]Output:[/u]
    Segmentation fault (core dumped) :-)

    [u]Call stack:[/u]
    wcscpy(??, ??) at 0x900000000066a44
    wcsdup(??) at 0x90000000018f0dc
    main(0x100000001, 0x203fe9c0) at 0x100001ff8
    I found a case in ibm knowledge base (IY81817) but this one applies when using debug malloc... which is not the case here (no specific environment variables specified).
    I would be surprised to state that AIX simply cannot run an UNICODE C++ program ?! So I imagine there is a fix or workaround somewhere...
    (I already searched the AIX patches database, without success)

    Does anyone with some AIX unicode development skills have some tips for me to try ?

    Thanks very much,
    Sincerely,

    Thomas
    #AIX-Forum


  • 2.  update ... something

    Posted Fri June 23, 2006 07:58 AM

    Originally posted by: nagger


    I tried this program on AIX 5.3 and VAC 5 and 7 and could not get the crash.

    Can you update AIX and the compiler and try again?
    #AIX-Forum


  • 3.  Re: update ... something

    Posted Tue August 08, 2006 11:52 AM

    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


  • 4.  Re: update ... something

    Posted Tue November 28, 2006 08:23 AM

    Originally posted by: SystemAdmin


    Hello,

    I have the same Problem hier with AIX 5.2 and xlC 7
    -bash-2.05b$ uname -aMp
    AIX aix5l 2 5 00412C9C4C00 powerpc IBM,7044-170

    it happens only in 64 bit mode (with -q64 flag)

    Workaround will be an own implementation like your my_wcsdup, we have this already for Solaris, but I am surprised there is no documentation about it.

    Alexandre
    #AIX-Forum