Patch: SMSbox crash

"Nikos Balkanas" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <000f01ca25b1$63139fb0$02b2a8c0@tardis>
Hi Donald,

I guess intercepting it upstream was my intention, too, however I think you got it too far back. I was thinking more likely at the SMS router function to check if payload is NULL to quietly discard the SMS and pick the next one from Q, this way minimizing overhead. Plus at this stage it would apply to all MO SMS, not only SMPP.

I changed subject to patch, so that Alex picks up on it and speaks his mind.

BR,
Nikos
  ----- Original Message ----- 
  From: Donald Jackson 
  To: Nikos Balkanas 
  Cc: Hemant Gmail ; [email protected] 
  Sent: Tuesday, August 25, 2009 8:33 PM
  Subject: Re: SMSbox crashed


  Hi Nikos,


  Apologies I wasn't actually following the thread he emailed me privately :)


  The problem occurs in smsbox when it tries to find a translation for the message. The different thing about these messages, is they are NULL. This is because this operator is not sending the (TLV) message_payload parameter with the data_sm PDU if no text is specified. 


  Smsbox/find_translation does no NULL checking on msgdata before trying the octstr_covert_range, which is why it fails the assertion. My patch simply sets the parameter to an empty Octstr inside the data_sm code, to prevent smsbox from falling over, and then still passing the upstream applications an empty string, instead of '(null)'.


  Let me know your thoughts,


  Thanks,
  Donald


  2009/8/25 Nikos Balkanas <[email protected]>

    Thanks, Donald.

    I was personally holding out for Herman to try out patching, but yours is more than welcome.

    I have also not forgotten your store isuue. I have not been able to reproduce it with fakesmsc, so it seems to be exclusive to the at driver. I will have to add code to simulate the modem calls (don't have modem or other smsc links - I am a wap guy) and i wouldn't like to spend a lot of money to try it out on a real connection.

    Meanwhile could you provide us with some relevant bb logs from the problem? I believe you can increase in real time the log detail from the http administration.

    BR,
    Nikos
      ----- Original Message ----- 
      From: Donald Jackson 
      To: Development mailing list 
      Cc: Hemant Gmail ; [email protected] 
      Sent: Tuesday, August 25, 2009 4:40 PM
      Subject: Re: SMSbox crashed


      Hi Nikos, 


      I have fixed this problem for Hemant. There is a bug when receiving data_sm PDU's for MO's.


      I will send in the patch for CVS review shortly.


      Cheers,
      Donald


      2009/8/25 Nikos Balkanas <[email protected]>

        Hi,

        Just switched to devel group. This is getting too much for users.

        1) Does latest CVS still faces same problem?

        2) There is no <if> statement at line 1384. I think we may be out of sync in urltrans.c. Best look for function:

        find_translation

        and then consider the octstr_convert_range  in there. That's the one that throws the panic. However, you shouldn't comment it out, since it is needed by the normal (non-empty) SMS.

        Best run bb through the debugger and fire an empty sms. When it crashes find the path to it. It should lead to the aforementioned function. At an appropriate point in the path, as soon as posssible, you need to check if SMS text is NULL and if it is to discard it.

        BR,
        Nikos
          ----- Original Message ----- 
          From: Hemant Gmail 
          To: 'Nikos Balkanas' 
          Cc: [email protected] 
          Sent: Tuesday, August 25, 2009 3:59 PM
          Subject: RE: SMSbox crashed


          Hi Nikos,



          Can I just comment the if condition on line 1384? Will that help? Please let me know



          Thanks,

          Hemant



          From: Nikos Balkanas [mailto:[email protected]] 
          Sent: Monday, August 24, 2009 8:40 PM
          To: Hemant Gmail
          Cc: [email protected]
          Subject: Re: SMSbox crashed



          Hi,



          Just update to latest CVS and test. All patches are in there. If problem still exists I could work a simple patch for it. If you want to fix it yourself, the problem is in octstr_convert_range in gw/urltrans.c: 1384



          BR,

          Nikos

            ----- Original Message ----- 

            From: Hemant Gmail 

            To: 'Nikos Balkanas' 

            Cc: [email protected] 

            Sent: Monday, August 24, 2009 5:59 PM

            Subject: RE: SMSbox crashed



            Hi,



            Just figured the problem .. every time Kannel receives an empty message, smsbox crashes … I am sure this is a known issue. Can you please point me to some patch available to fix this.



            Thanks again,

            Hemant



            From: Nikos Balkanas [mailto:[email protected]] 
            Sent: Thursday, August 20, 2009 12:04 PM
            To: Hemant Gmail
            Cc: [email protected]
            Subject: Re: SMSbox crashed



            Hi,



            Seems you have an extra space in your get-url. Are you using url-mapping? How come your www.smsexample.com/services is translated to index.php/smswebadmin/subscribe_users_proservices? Is this right?



            If problem persist post SMS you are sending. Also post relevant bearerbox logs (application + access) from problem.



            BR,

            Nikos

              ----- Original Message ----- 

              From: Hemant Gmail 

              To: 'Nikos Balkanas' 

              Cc: [email protected] 

              Sent: Thursday, August 20, 2009 7:39 AM

              Subject: RE: SMSbox crashed



              Hi Nikos,



              This is an MO, please check the sms-service configuration below.



              group = sms-service

              keyword = default

              catch-all = yes

              get-url = "http://www.smsexample.com/ services?to=%P&mobilenumber=%p&message=%a&receivedon=%t"

              max-messages = 4

              concatenation = true

              omit-empty = true



              Thanks,

              Hemant



              From: Nikos Balkanas [mailto:[email protected]] 
              Sent: Wednesday, August 19, 2009 11:10 PM
              To: Hemant Gmail
              Cc: [email protected]
              Subject: Re: SMSbox crashed



              Hi,



              Could you please post your sms-service configuration for smsgame1?



              Also I assume this is an MO. What sms do you send?



              BR,

              Nikos

                ----- Original Message ----- 

                From: Hemant Gmail 

                To: 'Nikos Balkanas' 

                Cc: [email protected] 

                Sent: Wednesday, August 19, 2009 3:51 PM

                Subject: RE: SMSbox crashed



                Hi Nikos,



                Please find below the log, I hope this helps.



                SMSBOX.LOG

                2009-08-16 23:00:57 [4477] [4] INFO: Starting to service <smsgame1> from <+123456789> to <1111>

                2009-08-16 23:00:57 [4477] [9] DEBUG: Queue contains 0 pending requests.

                2009-08-16 23:00:57 [4477] [9] DEBUG: Parsing URL `http://www.smsexample.com/services?to=1111&mobilenumber=%2B123456789&message=smsgame1&receivedon=2009-08-17+03:00:57':

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Scheme: http://

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Host: www.smsexample.com

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Port: 80

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Username: (null)

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Password: (null)

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Path: /index.php/smswebadmin/subscribe_users_proservices

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Query: to=1111&mobilenumber=%2B123456789&message=smsgame1&receivedon=2009-08-17+03:00:57

                2009-08-16 23:00:57 [4477] [9] DEBUG:   Fragment: (null)

                2009-08-16 23:00:57 [4477] [9] DEBUG: HTTP: Opening connection to `www.smsexample.com:80' (fd=28).

                2009-08-16 23:00:57 [4477] [9] DEBUG: Socket connecting

                2009-08-16 23:00:57 [4477] [8] DEBUG: Get info about connecting socket

                2009-08-16 23:00:57 [4477] [8] DEBUG: HTTP: Sending request:

                2009-08-16 23:00:57 [4477] [8] DEBUG: Octet string at 0x10f9c950:

                2009-08-16 23:00:57 [4477] [8] DEBUG:   len:  227

                2009-08-16 23:00:57 [4477] [8] DEBUG:   size: 1024

                2009-08-16 23:00:57 [4477] [8] DEBUG:   immutable: 0

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 47 45 54 20 2f 69 6e 64 65 78 2e 70 68 70 2f 73   GET /index.php/s

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 6d 73 77 65 62 61 64 6d 69 6e 2f 73 75 62 73 63   mswebadmin/subsc

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 72 69 62 65 5f 75 73 65 72 73 5f 70 72 6f 73 65   ribe_users_prose

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 72 76 69 63 65 73 3f 74 6f 3d 31 38 31 38 26 6d   rvices?to=1111&m

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 6f 62 69 6c 65 6e 75 6d 62 65 72 3d 25 32 42 32   obilenumber=%2B2

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 33 31 36 36 31 33 39 38 37 26 6d 65 73 73 61 67   316613987&messag

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 65 3d 46 6f 6f 74 62 61 6c 6c 26 72 65 63 65 69   e=smsgame1&recei

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 76 65 64 6f 6e 3d 32 30 30 39 2d 30 38 2d 31 37   vedon=2009-08-17

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 2b 30 33 3a 30 30 3a 35 37 20 48 54 54 50 2f 31   +03:00:57 HTTP/1

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 2e 31 0d 0a 48 6f 73 74 3a 20 77 77 77 2e 73 6d   .1..Host: www.sm

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 73 73 74 72 65 61 6d 65 72 2e 63 6f 6d 0d 0a 43   sstreamer.com..C

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d   onnection: keep-

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 61 6c 69 76 65 0d 0a 55 73 65 72 2d 41 67 65 6e   alive..User-Agen

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 74 3a 20 4b 61 6e 6e 65 6c 2f 31 2e 34 2e 33 0d   t: Kannel/1.4.3.

                2009-08-16 23:00:57 [4477] [8] DEBUG:   data: 0a 0d 0a                                          ...

                2009-08-16 23:00:57 [4477] [8] DEBUG: Octet string dump ends.

                2009-08-16 23:00:58 [4477] [8] DEBUG: HTTP: Status line: <HTTP/1.1 200 OK>

                2009-08-16 23:00:58 [4477] [8] DEBUG: HTTP: Received response:

                2009-08-16 23:00:58 [4477] [8] DEBUG: Octet string at 0x10f9d630:

                2009-08-16 23:00:58 [4477] [8] DEBUG:   len:  381

                2009-08-16 23:00:58 [4477] [8] DEBUG:   size: 1024

                2009-08-16 23:00:58 [4477] [8] DEBUG:   immutable: 0

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 44 61 74 65 3a 20 4d 6f 6e 2c 20 31 37 20 41 75   Date: Mon, 17 Au

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 67 20 32 30 30 39 20 30 33 3a 30 30 3a 35 37 20   g 2009 03:00:57

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 47 4d 54 0d 0a 53 65 72 76 65 72 3a 20 41 70 61   GMT..Server: Apa

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 63 68 65 2f 32 2e 32 2e 38 20 28 46 65 64 6f 72   che/2.2.8 (Fedor

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 61 29 0d 0a 58 2d 50 6f 77 65 72 65 64 2d 42 79   a)..X-Powered-By

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 3a 20 50 48 50 2f 35 2e 32 2e 36 0d 0a 53 65 74   : PHP/5.2.6..Set

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 2d 43 6f 6f 6b 69 65 3a 20 43 41 4b 45 50 48 50   -Cookie: CAKEPHP

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 3d 72 75 31 70 31 30 69 33 36 70 68 6b 74 33 32   =ru1p10i36phkt32

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 36 68 6b 76 68 6a 6c 75 66 67 36 3b 20 65 78 70   6hkvhjlufg6; exp

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 69 72 65 73 3d 54 68 75 2c 20 31 37 20 41 75 67   ires=Thu, 17 Aug

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 20 32 30 33 34 20 30 39 3a 30 30 3a 35 37 20 47    2034 09:00:57 G

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 4d 54 3b 20 70 61 74 68 3d 2f 69 6e 64 65 78 2e   MT; path=/index.

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 70 68 70 2f 0d 0a 50 33 50 3a 20 43 50 3d 22 4e   php/..P3P: CP="N

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 4f 49 20 41 44 4d 20 44 45 56 20 50 53 41 69 20   OI ADM DEV PSAi

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 43 4f 4d 20 4e 41 56 20 4f 55 52 20 4f 54 52 6f   COM NAV OUR OTRo

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 20 53 54 50 20 49 4e 44 20 44 45 4d 22 0d 0a 43    STP IND DEM"..C

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 36   ontent-Length: 6

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 30 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 63   0..Connection: c

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 6c 6f 73 65 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79   lose..Content-Ty

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 70 65 3a 20 74 65 78 74 2f 68 74 6d 6c 0d 0a 0d   pe: text/html...

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 0a 0a 59 6f 75 20 68 61 76 65 20 73 75 63 63 65   ..You have succe

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 73 73 66 75 6c 6c 79 20 73 75 62 73 63 72 69 62   ssfully subscrib

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 65 64 20 74 6f 20 46 6f 6f 74 62 61 6c 6c 20 67   ed to smsgame1 g

                2009-08-16 23:00:58 [4477] [8] DEBUG:   data: 72 6f 75 70 20 73 65 72 76 69 63 65 73            roup services

                2009-08-16 23:00:58 [4477] [8] DEBUG: Octet string dump ends.

                2009-08-16 23:00:58 [4477] [5] DEBUG: message length 59, sending 1 messages

                2009-08-16 23:00:58 [4477] [0] DEBUG: Got ACK (0) of 595fac84-2cc9-4f23-a552-2fca9830206f

                2009-08-16 23:00:58 [4477] [0] DEBUG: No client - multi-send or ACK to pull-reply

                2009-08-16 23:23:25 [4477] [4] PANIC: gwlib/octstr.c:2481: seems_valid_real: Assertion `ostr != NULL' failed. (Called from gwlib/octstr.c:836:octstr_convert_range.)

                2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox(gw_panic+0x15b) [0x43c7fb]

                2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox [0x43d079]

                2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox(octstr_convert_range+0x3d) [0x43d54d]

                2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox(urltrans_find+0x55) [0x41d045]

                2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox [0x415790]

                2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox [0x433885]

                2009-08-16 23:23:25 [4477] [4] PANIC: /lib64/libpthread.so.0 [0x343da06367]

                2009-08-16 23:23:25 [4477] [4] PANIC: /lib64/libc.so.6(clone+0x6d) [0x343ced309d]



                Thanks,

                Hemant



                From: Nikos Balkanas [mailto:[email protected]] 
                Sent: Tuesday, August 18, 2009 9:02 PM
                To: [email protected]
                Cc: [email protected]
                Subject: Re: SMSbox crashed



                Hi,



                Please supply longer logs before the problem. Make sure there are at least 2 - 3 entries from thread [4] before the problem.



                BR,

                Nikos

                  ----- Original Message ----- 

                  From: Hemant Gmail 

                  To: [email protected] 

                  Sent: Monday, August 17, 2009 8:51 AM

                  Subject: SMSbox crashed



                  Hello,



                  For some reason my smsbox has started crashing since last couple of days. Please find below the log entries.

                  Can anyone please help me on this?



                  2009-08-16 23:00:58 [4477] [0] DEBUG: Got ACK (0) of 595fac84-2cc9-4f23-a552-2fca9830206f

                  2009-08-16 23:00:58 [4477] [0] DEBUG: No client - multi-send or ACK to pull-reply

                  2009-08-16 23:23:25 [4477] [4] PANIC: gwlib/octstr.c:2481: seems_valid_real: Assertion `ostr != NULL' failed. (Called from gwlib/octstr.c:836:octstr_convert_range.)

                  2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox(gw_panic+0x15b) [0x43c7fb]

                  2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox [0x43d079]

                  2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox(octstr_convert_range+0x3d) [0x43d54d]

                  2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox(urltrans_find+0x55) [0x41d045]

                  2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox [0x415790]

                  2009-08-16 23:23:25 [4477] [4] PANIC: /usr/local/kannel/sbin/smsbox [0x433885]

                  2009-08-16 23:23:25 [4477] [4] PANIC: /lib64/libpthread.so.0 [0x343da06367]

                  2009-08-16 23:23:25 [4477] [4] PANIC: /lib64/libc.so.6(clone+0x6d) [0x343ced309d]



                  Thanks in advance.

                  Hemant




      -- 
      Donald Jackson
      http://www.thearchitech.com




  -- 
  Donald Jackson
  http://www.thearchitech.com
  donald(a)thearchitech.com
data_sm_mo.patch (application/octet-stream, 784 B)
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.122
diff -u -r1.122 smsc_smpp.c
--- gw/smsc/smsc_smpp.c	21 Jul 2009 10:27:29 -0000	1.122
+++ gw/smsc/smsc_smpp.c	25 Aug 2009 17:28:39 -0000
@@ -637,9 +637,13 @@
 
     if (pdu->u.data_sm.esm_class & ESM_CLASS_SUBMIT_RPI)
         msg->sms.rpi = 1;
-
-    msg->sms.msgdata = pdu->u.data_sm.message_payload;
-    pdu->u.data_sm.message_payload = NULL;
+	
+    if(pdu->u.data_sm.message_payload != NULL) {
+        msg->sms.msgdata = pdu->u.data_sm.message_payload;
+        pdu->u.data_sm.message_payload = NULL;
+    } else {
+        msg->sms.msgdata = octstr_imm("");
+    }
 
     /*
      * Encode udh if udhi set
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.