Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhWuA-0006wq-SO for pgsql-bugs@arkaria.postgresql.org; Fri, 14 May 2021 12:26:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lhWu9-00016l-Qt for pgsql-bugs@arkaria.postgresql.org; Fri, 14 May 2021 12:26:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhWu9-00016d-JE for pgsql-bugs@lists.postgresql.org; Fri, 14 May 2021 12:26:57 +0000 Received: from mout.gmx.net ([212.227.17.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhWu6-0001kC-VX for pgsql-bugs@lists.postgresql.org; Fri, 14 May 2021 12:26:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620995213; bh=CRyTwyMt0bmn9Ox5+3TzMz3h0Oj66Cyex9vdiJNg2Io=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=MFXm41zmlWReLWL5wBXeYJ/6IbGTMiZ8N8lzB11aW7sqGf2OjohVPZDVsQVVfn18U VCMrIUCgQWrxubtGVsphJ5xvCRMa4yeZneFEE7rsS9WvWwKsJRUhj/rkma1/roiDfb XBaTL/XzFsR/jnTyyaKbTxMxE4zNytJDKKDi8VDw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from dagobert.disney ([217.24.239.150]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MUosT-1m86LU0Kjh-00QlYv; Fri, 14 May 2021 14:26:53 +0200 Received: from kralle.disney ([192.168.179.95]) by dagobert.disney with esmtp (Exim 4.82) (envelope-from ) id 1lhWu4-0008G0-Cm; Fri, 14 May 2021 14:26:52 +0200 Subject: Re: Segmentation fault when calling BlessTupleDesc in a C function in parallel on PostgreSQL-(12.6, 12.7, 13.2, 13.3) To: Bharath Rupireddy Cc: pgsql-bugs@lists.postgresql.org References: <99aaa2eb-e194-bf07-c29a-1a76b4f2bcf9@gmx.de> From: Eric Thinnes Message-ID: <105daf69-a864-2e83-1f93-a85e4ba80510@gmx.de> Date: Fri, 14 May 2021 14:26:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:3+soMeX1uDqnV1L2hc+LzUbZmT0UHAo5oGsnnekfU/H6gNiaIZ4 +rdvFWFkfHWYOM2IvGehX3Mow9I7tppl9XMGVrD+8oV2HjcVBJ57TVPMV4tZPgyeMJdDddt maD5/SfnXVePfxRfH/ff0LRxm72vw/HGmDig3RRNOyMFsyFQ/ZkFfbY1J4rprJlYIZoWSFs r/T2dk1IZRmTfdwzwjIPw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:VkwOopWEp+I=:w15AkxjD+V1cbL/0DbzplA rgHRiIoqb2gaaBvWQ8V2P0PH/TALoyJBMTduJHNJysmrvxK8D+jBaQmrqbxop2m0hwu8TshZP xUbdmD/bHZ4QGSaJEs5dgPRyM0LwqqzsDjVUXjuIIgkWeGwz8nzFuksRE5L5YYIOpXV3btG/7 vnO3qkqKGsr1OU74mrnCQChvM8g8FS55yU0FWk8N0ys8/uNt4xsBSnVLs40HWLdl469YxLaxg Jl59qcLUqPCnapywyW3rJFibaukwkR1QJ+GP+o/odifER4gWHh1+qOIQGEk8K6B63qfZKz6v6 pehGZZzteZt0aTHY0hJtvSujJ+JBQqQAS2tQzNefQv2iPLZeiwmUSVU2+K1XxwJn7NHG7Ia8l 2M8SGfALa7BhS+kzZm1hJW1l1BwRqUOKRVTFZLJMWy01fCLPXxUfn+zMGAau/6nxxKZsC7nkY +/RxVlGvSyg8GOZV9xftI8jvPQLKEYfQqhBV+MKpXaxYHSDCnfe0S9I01aJg6Hh6i6rCcpH24 8AOCVjfYbUlZi5VdCONHiHe90pNGf6iT6rnHThTukV7FrJ0Ex3UINSdEvoLKFmFpWehJx+zO1 nRm7isBQes5CCHqanNOaP4v8CPpNg+sn9EdBr2lhCAwPL+Q0EivMsXvltfiS+NJWeJU1aZjx0 18GrkQ0srpHMjWwIrUOr0ghBpKMzsnscKfAcgafS34cgeIjHV3yLZK7Sur7KO8qe/P/5KBv+a 6K7/p5i41Aw+OeQxDjwok4yq0Uw0Wfxgk4Zh65a6l2gZVMxyJ//YQvX6T6GfiBpZvbcx1PiV0 SdQwbLDnZG1J0yM3XCHxMj7zJE4wJZDq+IuBqsZD/bbZnIX7sAsMmJp8rUNTEScOdOEZQLcnV oj6Ny44cje8bBbgSGjqCJvX3w3/uNRsiWM2TVcblOWgja77SaLU6ds6OIWRwJI5n3QWD4jEWt 1NXxZ1sEGxjxvz63L67gbk1cz2G1G3xzmp9ZdoKj3v22pW5vu/XhrA7J+9O3EY8MvLtxu1HZ8 4zvIGnKfsHU4bT/DUFzQm2b9SbcDgneCTjSOwwrMaEWZKe5DMBucG6oiChS33C6drV17OENde 8kvaUACwrNaoJuN6PkNQJh5OaqGak78vD9ltZH3j7GlqfHJSf8UGOg0Q1nd36A97yIaj2UZJU lD1cNAmyRv9kJYrAHCn9MVCka7PJjBhH9hMJWn7N38OzGYk9vRk8+1t/wRfzmmgY58BFQ= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I do think it should be possible. The function always delivers the same result with the same call parameters except for the determination of the result types and the generation of the TupleDesc, the function has no side effects. If BlessTupleDesc inevitably leads to side effects, I am happy to be instructed to improve something. So far I haven't found any information on this. Am 14.05.21 um 13:45 schrieb Bharath Rupireddy: > On Fri, May 14, 2021 at 4:49 PM Eric Thinnes wrote: >> >> >> Hello Postgres team, >> >> i get a segmentation fault when calling BlessTupleDesc in a C function >> in parallel. >> >> System Configuration >> --------------------- >> Architecture : Intel Pentium >> Operating System : Ubuntu versions: 16.04.7 LTS, 18.04.5 LTS, >> 20.04.2 LTS >> PostgreSQL version : PostgreSQL-(12.6, 12.7, 13.2, 13.3) >> Compiler used : gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 >> >> Please enter a FULL description of your problem: >> ------------------------------------------------ >> >> In the version with the configure option --enable-cassert, the process >> is aborted >> before the segmentation fault occurs. >> >> It is possible that the error does not occur the first time and that >> the call has to be repeated several times. >> That probably indicates a timing problem with concurrency. >> >> >> postgres:5433:et@test=3D# SET max_parallel_workers_per_gather TO 4; >> SET >> Zeit: 0,558 ms >> postgres:5433:et@test=3D#* SELECT sum(sign*Betrag) FROM kpos_test, >> setof_kpos(kpos); >> INFO: pid: 9132, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> INFO: pid: 9131, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> INFO: pid: 9130, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> INFO: pid: 9134, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> INFO: pid: 9133, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> WARNING: terminating connection because of crash of another server pro= cess >> DETAIL: The postmaster has commanded this server process to roll back >> the current transaction and exit, because another server process exited >> abnormally and possibly corrupted shared memory. >> TIP: In a moment you should be able to reconnect to the database and >> repeat your command. >> SSL-SYSCALL-Fehler: Dateiende entdeckt >> Die Verbindung zum Server wurde verloren. Versuche Reset: Fehlgeschlag= en. >> Zeit: 421,098 ms >> ::@!>? \q >> >> If I call the c function once with an empty argument before the >> parallel scan, the error does not occur. >> >> >> SET max_parallel_workers_per_gather TO 4; >> SET >> Zeit: 0,390 ms >> postgres:5433:et@test=3D#* SELECT setof_kpos(''); >> INFO: pid: 12396, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> setof_kpos >> ------------ >> (0 Zeilen) >> >> Zeit: 1,253 ms >> postgres:5433:et@test=3D#* SELECT sum(sign*Betrag) FROM kpos_test, >> setof_kpos(kpos); >> INFO: pid: 12400, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> INFO: pid: 12398, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> INFO: pid: 12399, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> INFO: pid: 12397, outTypeId: 40962 >> INFO: outTypRelId: 40960, typlen: -1, typbyval: 0, typalign: d >> sum >> ----- >> 0 >> (1 Zeile) >> >> I don't know how to fix this. > > I'm not sure if this makes sense - do you want to set the set_of_kpos > function's parallel safety to 'unsafe' or 'restricted'? > > With Regards, > Bharath Rupireddy. > EnterpriseDB: http://www.enterprisedb.com >