Project

General

Profile

Actions

Bug #5549

closed

/sockread have some trailing null bytes when reading from UDP sockets

Added by westor (GR) 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Scripting
Target version:
Start date:
04/17/2022
Due date:
% Done:

0%

Estimated time:
Operative System:
All
Regression:
No

Description

Hello,

After spending 2 days to reproduce that bug finally i having a code that it seems the adiirc is adding extra zeros NUL on the end for an unknown reason that messes up the results, i've tried that also on a clean adiirc.

Please if you cannot reproduce the bug, reply me so i can provide a better example or anything else that needs.

Reproduce Code :

There are 2 tests you can use to reproduce, 1st is binary mode (/send_test1) and 2nd is non-binary mode (/send_test2).
In both examples you are going to see the zeros NUL there.

ON *:UDPREAD:test1: {
  if ($sockerr) { echo 4 -a Sockerr $sockname > $sockerr --> $sock($sockname).wsmsg | return }

  sockread $sock($sockname).rq &temp

  if ($sockbr) { echo 4 -sg $sockbr -- $bvar(&temp,0) -- $bvar(&temp,1-) -- $bvar(&temp,1-).text }
}

ON *:UDPREAD:test2: {
  if ($sockerr) { echo 4 -a Sockerr $sockname > $sockerr --> $sock($sockname).wsmsg | return }

  var %temp
  sockread %temp

  if ($sockbr) { echo 13 -sg $sockbr -- %temp }
}

alias send_test1 {
  make_data

  sockclose test1
  sockudp -k test1 8901

  var %t = $line(@temp,0)
  var %t = 3
  ; Lets first test the first 3 lines from the @temp then comment out it for full test

  var %i = 1

  while (%i <= %t) {
    var %l = $line(@temp,%i)

    if (%l) { .timer 1 1 bset &v -1 %l $(|) sockudp test1 127.0.0.1 8901 &v }

    inc %i
  }

  window -c @temp

  echo 2 -ag $calias > Finished!
}

alias send_test2 {
  make_data

  sockclose test1
  sockclose test2
  sockudp -k test1 8901
  sockudp -k test2 8902

  var %t = $line(@temp,0)
  var %t = 3
  ; Lets first test the first 3 lines from the @temp then comment out it for full test

  var %i = 1

  while (%i <= %t) {
    var %l = $line(@temp,%i)

    if (%l) { 
      .timer 1 1 bset &v -1 %l $(|) sockudp test1 127.0.0.1 8901 &v 
      .timer 1 1 bset &a -1 %l $(|) sockudp test2 127.0.0.1 8902 &a
    }

    inc %i
  }

  window -c @temp

  echo 2 -ag $calias > Finished!
}

alias make_data {
  window -h @temp

  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 48 57 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 112 105 99 107 101 100 32 117 112 32 34 103 108 111 99 107 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 48 57 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 112 105 99 107 101 100 32 117 112 32 34 99 52 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 48 57 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 116 114 105 103 103 101 114 101 100 32 34 71 111 116 95 84 104 101 95 66 111 109 98 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 48 57 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 108 101 102 116 32 98 117 121 122 111 110 101 32 119 105 116 104 32 91 32 119 101 97 112 111 110 95 107 110 105 102 101 95 116 32 119 101 97 112 111 110 95 103 108 111 99 107 32 119 101 97 112 111 110 95 99 52 32 67 52 32 93 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 49 48 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 100 114 111 112 112 101 100 32 34 103 108 111 99 107 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 49 49 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 116 114 105 103 103 101 114 101 100 32 34 68 114 111 112 112 101 100 95 84 104 101 95 66 111 109 98 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 49 49 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 100 114 111 112 112 101 100 32 34 99 52 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 49 50 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 112 105 99 107 101 100 32 117 112 32 34 103 108 111 99 107 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 49 51 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 112 105 99 107 101 100 32 117 112 32 34 99 52 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 49 51 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 116 114 105 103 103 101 114 101 100 32 34 71 111 116 95 84 104 101 95 66 111 109 98 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 50 56 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 116 114 105 103 103 101 114 101 100 32 34 66 111 109 98 95 66 101 103 105 110 95 80 108 97 110 116 34 32 97 116 32 98 111 109 98 115 105 116 101 32 65 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 51 50 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 49 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 109 111 110 101 121 32 99 104 97 110 103 101 32 56 48 48 43 51 48 48 32 61 32 36 49 49 48 48 32 40 116 114 97 99 107 101 100 41 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 51 50 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 116 114 105 103 103 101 114 101 100 32 34 80 108 97 110 116 101 100 95 84 104 101 95 66 111 109 98 34 32 97 116 32 98 111 109 98 115 105 116 101 32 65 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 55 58 51 50 58 32 34 239 184 187 227 131 135 228 184 128 32 87 69 83 84 79 82 32 226 152 160 60 56 62 60 83 84 69 65 77 95 49 58 48 58 51 56 49 53 48 49 51 51 62 60 84 69 82 82 79 82 73 83 84 62 34 32 100 114 111 112 112 101 100 32 34 99 52 34 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 56 58 49 51 58 32 84 101 97 109 32 34 84 69 82 82 79 82 73 83 84 34 32 116 114 105 103 103 101 114 101 100 32 34 83 70 85 73 95 78 111 116 105 99 101 95 84 97 114 103 101 116 95 66 111 109 98 101 100 34 32 40 67 84 32 34 48 34 41 32 40 84 32 34 49 34 41 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 56 58 49 51 58 32 84 101 97 109 32 34 67 84 34 32 115 99 111 114 101 100 32 34 48 34 32 119 105 116 104 32 34 48 34 32 112 108 97 121 101 114 115 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 56 58 49 51 58 32 84 101 97 109 32 34 84 69 82 82 79 82 73 83 84 34 32 115 99 111 114 101 100 32 34 49 34 32 119 105 116 104 32 34 49 34 32 112 108 97 121 101 114 115 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 56 58 49 51 58 32 77 97 116 99 104 83 116 97 116 117 115 58 32 84 101 97 109 32 34 67 84 34 32 105 115 32 117 110 115 101 116 46 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 56 58 49 51 58 32 77 97 116 99 104 83 116 97 116 117 115 58 32 84 101 97 109 32 34 84 69 82 82 79 82 73 83 84 34 32 105 115 32 117 110 115 101 116 46 10 0
  aline @temp 255 255 255 255 82 76 32 48 52 47 49 55 47 50 48 50 50 32 45 32 49 53 58 49 56 58 49 51 58 32 77 97 116 99 104 83 116 97 116 117 115 58 32 83 99 111 114 101 58 32 48 58 49 32 111 110 32 109 97 112 32 34 100 101 95 110 117 107 101 34 32 82 111 117 110 100 115 80 108 97 121 101 100 58 32 49 10 0
}

- Thanks!


Files

send_test2.png (43.4 KB) send_test2.png westor (GR), 04/17/2022 07:01 PM
send_test1.png (34.5 KB) send_test1.png westor (GR), 04/17/2022 07:01 PM
Actions #1

Updated by Per Amundsen 3 months ago

  • Subject changed from ON UDPREAD event memory management corruption to /sockread have some trailing null bytes when reading from UDP sockets
  • Status changed from New to Resolved
Actions #2

Updated by Per Amundsen 3 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF