Menu

#1320 The databinding test case report Segmentation fault is executed in Ubuntu22.04

v1.0 (example)
closed-fixed
None
5
2024-05-27
2024-05-27
James Wang
No

1、When I run the address program under the databinding directory and input relevant information, the Segmentation fault is reported, and the printed information of gdb debugging is as follows:
(gdb) r
Starting program: /home/alnin/gsoap/linux/gsoap-2.8-armeabi-v7a-build/gsoap/samples/databinding/address
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

ADDRESS BOOK - An Example XML Data Binding Application

Enter a new contact:
Name > alnin
Street > donghu
City > wuhan
Zip > 430000
Country > us
Phone > 13144842767
Mobile > 84233396
DOB > 569710150

Program received signal SIGSEGV, Segmentation fault.
soap_s2dateTime (soap=0x7ffff7a2a010, s=0x55555559e3a0 <user_input(char const*)::buf=""> "569710150", p=0x0) at stdsoap2_cpp.cpp:19340
19340 *p = 0;
(gdb)</user_input(char>

2、It shows that p is a null pointer, and nowhere else is there any allocation of dynamic memory, such as in the following statement:

// 在堆上分配一个 time_t 变量并初始化
time_t *p = new time_t(time(nullptr));

Could you please help to see if this is a problem? If it's not a problem, what can I do to make the program run without error? Thank you.

1 Attachments

Discussion

  • Robert van Engelen

    Thanks for reporting. The address.cpp demo example application has a missing allocation for the DOB field. The code that takes the DOB in address.cpp:166 should be:

    // change soap_s2dateTime to soap_xsd__dateTime when overriding the default xsd:dateTime to time_t mapping
      if (*(s = user_input("DOB")))
      {
        a->dob = soap_new_dateTime(soap);
        if (soap_s2dateTime(soap, s, a->dob) != SOAP_OK)
          std::cerr << "Not a valid ISO 8601 date time (ignored)" << std::endl;
      }
    

    Otherwise, a->dob is null and that leads to the problem.

     
  • Robert van Engelen

    • status: open --> closed-fixed
    • assigned_to: Robert van Engelen
     

Log in to post a comment.