problem with setLocale

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with setLocale

ali_sedaghat
In order to print unicode characters with llvm, I used setLocale in llvm ir:

    call i8* @setlocale(i32 6, i8* getelementptr inbounds ([1 x i8]* @pe, i32 0, i32 0)) nounwind

where @pe is defined as follows:

    @pe = private unnamed_addr constant [1 x i8] zeroinitializer, align 1

However, I got the following error:

    *** glibc detected *** ./test/bin/executable: free(): invalid next size (fast): 0x08f93140 ***

I used gdb to debug the program and the backtrace is as follows:

    #0  0xb7728424 in __kernel_vsyscall ()
    #1  0xb74aee71 in raise () from /lib/i386-linux-gnu/libc.so.6
    #2  0xb74b234e in abort () from /lib/i386-linux-gnu/libc.so.6
    #3  0xb74e5577 in ?? () from /lib/i386-linux-gnu/libc.so.6
    #4  0xb74ef961 in ?? () from /lib/i386-linux-gnu/libc.so.6
    #5  0xb74f128b in ?? () from /lib/i386-linux-gnu/libc.so.6
    #6  0xb74f441d in free () from /lib/i386-linux-gnu/libc.so.6
    #7  0xb74a6730 in ?? () from /lib/i386-linux-gnu/libc.so.6
    #8  0xb74a5299 in ?? () from /lib/i386-linux-gnu/libc.so.6
    #9  0xb74a4cd1 in setlocale () from /lib/i386-linux-gnu/libc.so.6
    ...

How can I resolve this issue? Any help would be appreciated

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: problem with setLocale

Duncan Sands
Hi Ali, did you link your program statically?  Try linking it dynamically.

Ciao, Duncan.

On 27/01/13 07:36, Ali Sedaghat wrote:

> In order to print unicode characters with llvm, I used setLocale in llvm ir:
>
>      call i8* @setlocale(i32 6, i8* getelementptr inbounds ([1 x i8]* @pe, i32
> 0, i32 0)) nounwind
>
> where @pe is defined as follows:
>
>      @pe = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
>
> However, I got the following error:
>
>      *** glibc detected *** ./test/bin/executable: free(): invalid next size
> (fast): 0x08f93140 ***
>
> I used gdb to debug the program and the backtrace is as follows:
>
>      #0  0xb7728424 in __kernel_vsyscall ()
>      #1  0xb74aee71 in raise () from /lib/i386-linux-gnu/libc.so.6
>      #2  0xb74b234e in abort () from /lib/i386-linux-gnu/libc.so.6
>      #3  0xb74e5577 in ?? () from /lib/i386-linux-gnu/libc.so.6
>      #4  0xb74ef961 in ?? () from /lib/i386-linux-gnu/libc.so.6
>      #5  0xb74f128b in ?? () from /lib/i386-linux-gnu/libc.so.6
>      #6  0xb74f441d in free () from /lib/i386-linux-gnu/libc.so.6
>      #7  0xb74a6730 in ?? () from /lib/i386-linux-gnu/libc.so.6
>      #8  0xb74a5299 in ?? () from /lib/i386-linux-gnu/libc.so.6
>      #9  0xb74a4cd1 in setlocale () from /lib/i386-linux-gnu/libc.so.6
>      ...
>
> How can I resolve this issue? Any help would be appreciated
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: problem with setLocale

ali_sedaghat
This post was updated on .
Hi Duncan,  my compiler is written in java and generates some .ll files as its output. Each of these .ll files is converted to an object file using llc. Then, I use clang++ to link them and generate an executable file without linking with any external libraries, so I cannot understand what you mean. Sorry, if my question sounds silly to you
Reply | Threaded
Open this post in threaded view
|

Re: problem with setLocale

Duncan Sands
Hi Ali,

On 28/01/13 06:38, ali_sedaghat wrote:
> Hi Ciao,  my compiler is written in java and generates some .ll files as its
> output. Each of these .ll files is converted to an object file using llc.
> Then, I use clang++ to link them and generate an executable file without
> linking with any external libraries, so I cannot understand what you mean.
> Sorry, if my question sounds silly to you

do you mean that you wrote your own version of setlocale?  The usual setlocale
lives in a system library, and to use it you must have linked with that system
library.  Usually a compiler like clang will automatically add that library to
the list of libraries to link with, so you may not realize you linked with it.
What is the exact command you used to create the executable?

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: problem with setLocale

ali_sedaghat
I didn't implement my own version of setlocale, and as you said clang should automatically link with that library. I use the following simple command to generate executable:
clang++ -o executable my-obj-files