[Bug 8061] New: print 64 bit data in pthread always becomes strange data

bugzilla at busybox.net bugzilla at busybox.net
Wed Apr 29 07:43:18 UTC 2015


https://bugs.busybox.net/show_bug.cgi?id=8061

           Summary: print 64 bit data in pthread always becomes strange
                    data
           Product: uClibc
           Version: 0.9.33.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: minor
          Priority: P5
         Component: stdio
        AssignedTo: unassigned at uclibc.org
        ReportedBy: zhao.junkui at zte.com.cn
                CC: uclibc-cvs at uclibc.org
   Estimated Hours: 0.0


when i try to printf a long long data in pthread,the printf result is always
wrong. But the same data printf in the main process,the result is correct? And
the result of stroll interface is wrong(always the max long long)?

test result:
/ # iptables -h
pthread_entry_zjk:HIGH 203e235e
pthread_entry_zjk:LOW 2702123
pthread_entry_zjk:HIGH 203e235e
pthread_entry_zjk:LOW 2702123
pthread_entry_zjk:0
pthread_entry_zjk:175676819675021312
pthread_entry_zjk:270212300000000
pthread_entry_zjk:175676819675021312
pthread_entry_zjk:175676819675021312
pthread_entry_zjk:175676819675021312
pthread_entry_zjk:3689067335152182110
pthread_entry_zjk_lijishu:175676819675021312
iptables-main:2323333344444555555
iptables-main:7fffffffffffffff
iptables-main:7fffffffffffffff
iptables-main:2323333344444555555
iptables-main:2323333344444555555
iptables-main:2323333344444555555
iptables-main:2323333344444555555

code following:
(i test in iptables open source code)

int
main(int argc, char *argv[])
{
    ...
    ret = do_command(argc, argv, &table, &handle);
    if (ret) {
        ret = iptc_commit(handle);
        iptc_free(handle);
    }

    ...
    exit(!ret);
}


long long test_zjk10 = 0;
long long test_zjk = 0;
long long test_zjk16 = 0;
long long test_zjk17 = 0;

long long test_zjk10_p  = 0;
long long test_zjk16_p = 0;
long long test_zjk_p  = 0;
char test_zjk_arr_p[100] = {0};


pthread_mutex_t mutex_zjk = PTHREAD_MUTEX_INITIALIZER;
void pthread_entry_zjk(void)
{
    char test[] = "2323333344444555555";
    char test1[] = "2323333344444555555";
    test_zjk_p = atoll("2323333344444555555");
    test_zjk10_p = strtoll(&test[0], NULL,10);
    test_zjk16_p= strtoll(&test1[0], NULL,10);

    pthread_mutex_lock(&mutex_zjk);

    printf("pthread_entry_zjk:%lld\n",0);
    printf("pthread_entry_zjk:%lld\n",test_zjk10_p);
    printf("pthread_entry_zjk:%llx\n",test_zjk16_p);
    printf("pthread_entry_zjk:%lld\n",test_zjk_p);
    printf("pthread_entry_zjk:%lld\n",test_zjk_p);
    printf("pthread_entry_zjk:%lld\n",test_zjk_p);
    sprintf(test_zjk_arr_p,"%lld",test_zjk10_p);
    printf("pthread_entry_zjk:%s\n",test_zjk_arr_p);
    printf("pthread_entry_zjk_lijishu:%lld\n",2323333344444555555);

    pthread_mutex_unlock(&mutex_zjk);
}

int do_command(int argc, char *argv[], char **table, struct iptc_handle
**handle)
{
    ...
    pthread_t id_zjk;
    pthread_create(&id_zjk,NULL,pthread_entry_zjk,NULL);
    sleep(40);
    test_zjk = atoll("2323333344444555555");
    test_zjk10 = strtoll(&test[0], NULL,10);
    test_zjk16 = strtoll(&test1[0], NULL,16);
    printf("iptables-main:%lld\n",test_zjk10);
    printf("iptables-main:%llx\n",test_zjk16);
    printf("iptables-main:%llx\n",test_zjk17);
    printf("iptables-main:%lld\n",test_zjk);
    printf("iptables-main:%lld\n",test_zjk);
    printf("iptables-main:%lld\n",test_zjk);
    sprintf(test_zjk_arr,"%lld",test_zjk10);
    printf("iptables-main:%s\n",test_zjk_arr);
    ...
}

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the uClibc-cvs mailing list