Jane_Jessica
jane_jessica
采纳率0%
2021-03-01 13:57

统信UOS系统libcurl段错

15
已结题

客户端访问服务端,一样的url字串,curl -k 就能返回json串

root@uos-PC:/usr/local/HTTC/httcsec# curl -# -k 'https://127.0.0.1:54530/ECAgent/?op=CheckLoginStatus&Guid=sdk&callback=EA_cb10014'
EA_cb10014("{\"type\":\"CheckLoginStatus\",\"result\":\"0\",\"message\":\"\",\"debug\":\"\"}")root@uos-PC:/usr/local/HTTC/httcsec# 
 

但是在代码里这样调用就不行?会直接死在curl_easy_perform接口

堆栈如下:

目前抓到的堆栈:

Thread 1 "tipcli" received signal SIGSEGV, Segmentation fault.
strcmp () at ../sysdeps/aarch64/strcmp.S:64
64    ../sysdeps/aarch64/strcmp.S: 没有那个文件或目录.
(gdb) bt
#0  strcmp () at ../sysdeps/aarch64/strcmp.S:64
#1  0x00000000006720f0 in getrn ()
#2  0x0000000000672320 in lh_insert ()
#3  0x00000000006b0590 in OBJ_NAME_add ()
#4  0x0000007f925f711c in ?? () from /lib/aarch64-linux-gnu/libcrypto.so.1.1
#5  0x0000007f9260c894 in ?? () from /lib/aarch64-linux-gnu/libcrypto.so.1.1
#6  0x0000007f92ccf250 in __pthread_once_slow (once_control=0x7f9275a548, init_routine=0x7f9260c888) at pthread_once.c:116
#7  0x0000007f92655a94 in CRYPTO_THREAD_run_once () from /lib/aarch64-linux-gnu/libcrypto.so.1.1
#8  0x0000007f9260cd88 in OPENSSL_init_crypto () from /lib/aarch64-linux-gnu/libcrypto.so.1.1
#9  0x0000007f9278fbb4 in OPENSSL_init_ssl () from /lib/aarch64-linux-gnu/libssl.so.1.1
#10 0x0000007f92793368 in SSL_CTX_new () from /lib/aarch64-linux-gnu/libssl.so.1.1
#11 0x0000007f93dbe028 in ?? () from /lib/aarch64-linux-gnu/libcurl.so.4
#12 0x0000007f93dc11d0 in ?? () from /lib/aarch64-linux-gnu/libcurl.so.4
#13 0x0000007f93dc20e8 in ?? () from /lib/aarch64-linux-gnu/libcurl.so.4
#14 0x0000007f93d71b7c in ?? () from /lib/aarch64-linux-gnu/libcurl.so.4
#15 0x0000007f93d735e0 in ?? () from /lib/aarch64-linux-gnu/libcurl.so.4
#16 0x0000007f93d7dc30 in ?? () from /lib/aarch64-linux-gnu/libcurl.so.4
#17 0x0000007f93d90ff0 in ?? () from /lib/aarch64-linux-gnu/libcurl.so.4
#18 0x0000007f93d91e1c in curl_multi_perform () from /lib/aarch64-linux-gnu/libcurl.so.4
#19 0x0000007f93d89224 in curl_easy_perform () from /lib/aarch64-linux-gnu/libcurl.so.4
#20 0x000000000058e1dc in _oper (url=0x7fc4e24a58 "https://127.0.0.1:54530/ECAgent/?op=CheckLoginStatus&Guid=sdk&callback=EA_cb10014", result=0x7fc4e24a54)
    at appif_config.c:513
使用curl的代码如下:

    curl = curl_easy_init();
    if (curl == NULL) {
        printf("curl_easy_init fail.\n");
        goto err;
    }

   

memset(&resp, 0, sizeof(resp));

    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&resp);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, local_write_resp);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);

    res = curl_easy_perform(curl);

  • 点赞
  • 收藏
  • 复制链接分享

3条回答

  • bill20100829 歇歇 1月前

    找一台非开发环境调试,应该是依赖库不完整

    点赞 评论 复制链接分享
  • Jane_Jessica jane_jessica 1月前

    如果写在产品的可执行文件里,就会段错,段错内容同上。ldd确认过使用的是同一个libcurl,命令行curl -k 'xxxxx'也能正常返回,请问有人遇见过类似的情况吗?现在就是没有思路,在线等。

    点赞 评论 复制链接分享
  • Jane_Jessica jane_jessica 1月前

    补充一下,用这段代码,写的demo,可以返回正常。

    点赞 评论 复制链接分享

为你推荐