Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race/heap corruption on thread exit #3595

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Race/heap corruption on thread exit #3595

monetdb-team opened this issue Nov 30, 2020 · 0 comments


Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2014-10-03 14:56:15 +0200
From: Richard Hughes <<richard.monetdb>>
To: GDK devs <>
Version: 11.17.21 (Jan2014-SP3)
CC: @njnes

Last updated: 2014-10-31 14:14:31 +0100

Comment 20235

Date: 2014-10-03 14:56:15 +0200
From: Richard Hughes <<richard.monetdb>>

Created attachment 300
proposed fix

Valgrind picked up a write-to-freed-memory when a client disconnected. I tracked it down to the following series of events:

Thread 1 Thread 2

in MSserveClient calls join_threads()
starts to exit
calls MT_exiting_thread
sets p->exited=1
notices posthread::exited==1
calls rm_posthread
calls free(p)
blocks in pthread_join
returns to thread_starter
sets p->exited=1

That last assignment is to freed memory.

Attached a patch to fix this.

Attached file: thread-exit-heap-corruption.patch (application/octet-stream, 677 bytes)
Description: proposed fix

Comment 20283

Date: 2014-10-11 18:04:57 +0200
From: MonetDB Mercurial Repository <>

Changeset eaadb9ab037d made by Niels Nes in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=eaadb9ab037d

Changeset description:

free thread data after last use, fixes bug #3595.

Comment 20284

Date: 2014-10-11 18:05:24 +0200
From: @njnes

Thanks for the patch. Indeed fixes the problem

Comment 20376

Date: 2014-10-31 14:14:31 +0100
From: @sjoerdmullender

Oct2014 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant