tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Segmentation fault in tccelf.c:2189, strcmp


From: Diego Bauche Madero
Subject: Re: [Tinycc-devel] Segmentation fault in tccelf.c:2189, strcmp
Date: Tue, 25 Oct 2005 21:25:48 -0400
User-agent: Mozilla Thunderbird 1.0.7 (X11/20050923)

Evan Langlois wrote:

>On Tue, 2005-10-25 at 17:06 -0400, Diego Bauche Madero wrote:
>  
>
>>    /* load all referenced DLLs */
>>    for(i = 0, dt = dynamic; i < nb_dts; i++, dt++) {
>>        switch(dt->d_tag) {
>>        case DT_NEEDED:
>>            name = dynstr + dt->d_un.d_val;
>>            for(i = 0; i < s1->nb_loaded_dlls; i++) {
>>                dllref = s1->loaded_dlls[i];
>>                if (!strcmp(name, dllref->name))
>>                    goto already_loaded;
>>            }
>>----
>>
>>During the strcmp(name,dllref->name) call, `name' points to 0x4f6fb954,
>>which is not a valid address, being dynstr = 0x80d4fe8 and dt->d-un =
>>{d_val = 0x4762696c, d_ptr = 0x4762696c}
>>    
>>
>
>If dynstr and dt->d_un.d_val are the values you say they are, then name
>is quite correct.  You added the pointers!  I see no reason at all to
>fault the compiler.  You should also likely want to use strncmp so you
>have some sort of upper bound on your string compare, just in case.
>
>  
>
----
(gdb) x/i $pc

0xb7e76c28 <strcmp+8>:  mov    (%ecx),%al
(gdb) x/x *$ecx
Cannot access memory at address 0x4f6fb954
(gdb) set $dynstr=0x80d4fe8
(gdb) set $d_val=0x4762696c
(gdb) p/x $dynstr+$d_val
$1 = 0x4f6fb954
(gdb)
----
        
As you can see, `name' points to the address i said, and of course, being not 
an accesable address, the program just sends SIGSEGV.
Anyway, the core file and tcc ELF executable binary (compiled with glibc 2.3.4) 
can be found at http://genexx.org/tcc_strcmp.tbz2


>>If more information is needed (i.e. core file), please let me know.
>>    
>>
>
>  
>
>Have you compiled with another compiler to verify that this isn't a
>problem in the source and not the compiler?
>
>
>  
>
Yes, i have:

----
$ tcc -IGL /usr/X11R6/lib/libX11.so.6 /usr/X11R6/lib/libXext.so.6
/usr/X11R6/lib/libGLU.so /usr/X11R6/lib/libglut.so.3 -lGL -IGLU -lm -o
libellenbeck-fract libellenbeck-fract.c
Segmentation fault
$ gcc -IGL /usr/X11R6/lib/libX11.so.6 /usr/X11R6/lib/libXext.so.6
/usr/X11R6/lib/libGLU.so /usr/X11R6/lib/libglut.so.3 -lGL -IGLU -lm -o
libellenbeck-fract libellenbeck-fract.c
$ ls libellenbeck-fract
libellenbeck-fract*
$ tcc -v; gcc -v
tcc version 0.9.23
Reading specs from /usr/pp/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../configure --prefix=/usr/pp
Thread model: posix
gcc version 3.3
$ uname -mps
Linux i686 Pentium III (Katmai)
$ 
----

>
>
>_______________________________________________
>Tinycc-devel mailing list
>address@hidden
>http://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
>
>  
>


Cheers
- Diego Bauche Madero




reply via email to

[Prev in Thread] Current Thread [Next in Thread]