Re: libpq and multi-threading - Mailing list pgsql-general

From Geoff Winkless
Subject Re: libpq and multi-threading
Date
Msg-id CAEzk6ffV0HLKPBygzaSi+iD8EN15wETnXtCwMGPJqQehKo+rBQ@mail.gmail.com
Whole thread Raw
In response to Re: libpq and multi-threading  ("Michael J. Baars" <mjbaars1977.pgsql.hackers@gmail.com>)
List pgsql-general
On Wed, 3 May 2023 at 12:11, Michael J. Baars <mjbaars1977.pgsql.hackers@gmail.com> wrote:
The shared common address space is controlled by the clone(2) CLONE_VM option. Indeed this results in an environment in which both the parent and the child can read / write each other's memory, but dynamic memory being allocated using malloc(3) from two different threads simulaneously will result in internal interference. 

There's an interesting note here


TL;DR: glibc malloc does not cope well with threads created with clone(). Use pthread_create if you wish to use glibc malloc.

Geoff

pgsql-general by date:

Previous
From: "Peter J. Holzer"
Date:
Subject: Re: libpq and multi-threading
Next
From: Jeff Janes
Date:
Subject: Re: iso-8859-1 postgres ssl error "could not accept SSL connection: Success" and timeout