After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 679385 - shmsrc: memory corruption when a client disconnects
shmsrc: memory corruption when a client disconnects
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
0.10.x
Other Linux
: Normal normal
: 0.10.24
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-07-04 09:35 UTC by Aleix Conchillo Flaqué
Modified: 2012-10-06 11:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix for memory corruption when one client disconnects (664 bytes, patch)
2012-07-04 09:42 UTC, Aleix Conchillo Flaqué
none Details | Review

Description Aleix Conchillo Flaqué 2012-07-04 09:35:45 UTC
This is another bug (see bug 675640) that ends in memory corruption when more than one shmsink is reading from a shmsrc and one of them disconnects.

The same gst-launch command in bug 675640 should show the problem, but I have not been able to reproduce the issue with it. The problem has been found with a bigger app that uses shmsrc/shmsink.

Imaging we have these list of buffers (in ShmPipe) and we iterate through them in sp_writer_close_client. 

v means client has ack the buffer
x means client has decremented buffer use count (without ack)

              Client 1     Client 2

0 0x1d3d1c0                   
1 0x1d4ef80
2 0x1d4ef40      v
3 0x1e01940      v

If we iterate in the sp_writer_close loop, we have

              Client 1     Client 2

0 0x1d3d1c0                   x
1 0x1d4ef80                   x
2 0x1d4ef40      v            x   <-- we need a valid prev_buf
3 0x1e01940      v

But prev_buf is still NULL... prev_buf assignment should be outside the client loop.

  for (buffer = self->buffers; buffer; buffer = buffer->next) {
    int i;

    for (i = 0; i < buffer->num_clients; i++) {
      if (buffer->clients[i] == client->fd) {
        if (!sp_shmbuf_dec (self, buffer, prev_buf, client))
          goto again;
        break;
      }
      prev_buf = buffer;
    }
  }
Comment 1 Aleix Conchillo Flaqué 2012-07-04 09:42:23 UTC
Created attachment 217991 [details] [review]
fix for memory corruption when one client disconnects
Comment 2 Olivier Crête 2012-07-05 18:38:03 UTC
Patch committed, thank you!
Comment 3 Olivier Crête 2012-07-05 18:39:36 UTC
0.10: 

commit 0687a65eea23f6ec826cc6db2236a3d821afa7ad
Author: Aleix Conchillo Flaque <aleix@oblong.com>
Date:   Wed Jul 4 11:38:51 2012 +0200

    shmsrc: memory corruption when a client disconnects (fixes #679385)

master (0.11/1.0):

commit 7b6029ebe147b8d96c64e0ab513b44018508eb1f
Author: Aleix Conchillo Flaque <aleix@oblong.com>
Date:   Wed Jul 4 11:38:51 2012 +0200

    shmsrc: memory corruption when a client disconnects (fixes #679385)