Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[NOVICE] seg fault on dsm_create call

4 views
Skip to first unread message

Max Fomichev

unread,
Jun 28, 2016, 8:47:31 AM6/28/16
to
Hello.
I'm trying to understand how to work with dynamic shared memory, message
queues and workers.
The problem is I can not initialize a dsm segment -

void _PG_init() {
...
dsm_segment *seg = dsm_create(32768, 0); // Segmentation fault here
...
BackgroundWorker worker;
sprintf(worker.bgw_name, "mystem wrapper process");
worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
worker.bgw_start_time = BgWorkerStart_RecoveryFinished;
worker.bgw_restart_time = BGW_NEVER_RESTART;
worker.bgw_main = mainProc;
worker.bgw_notify_pid = 0;
RegisterBackgroundWorker(&worker);
}

Also I was trying to move dsm_create call to a worker, but with the same
result -

static void mainProc(Datum) {
...
dsm_segment *seg = dsm_create(32768, 0); // Segmentation fault here
...
pqsignal(SIGTERM, mystemSigterm);
BackgroundWorkerUnblockSignals();
...

What could be a reason and what am I doing wrong?

PS test/modules/test_shm_mq works fine...


--
Best regards,
Max Fomichev



--
Sent via pgsql-novice mailing list (pgsql-...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

Andrej

unread,
Jun 28, 2016, 11:02:38 PM6/28/16
to
On 29 June 2016 at 00:47, Max Fomichev <max.fo...@gmail.com> wrote:
> Hello.
> I'm trying to understand how to work with dynamic shared memory, message
> queues and workers.
> The problem is I can not initialize a dsm segment -
>
> void _PG_init() {
> ...
> dsm_segment *seg = dsm_create(32768, 0); // Segmentation fault here

> Also I was trying to move dsm_create call to a worker, but with the same
> result -
>
> static void mainProc(Datum) {
> ...
> dsm_segment *seg = dsm_create(32768, 0); // Segmentation fault here
> ...
> pqsignal(SIGTERM, mystemSigterm);
> BackgroundWorkerUnblockSignals();
> ...
>
> What could be a reason and what am I doing wrong?
>
> PS test/modules/test_shm_mq works fine...

I'm no expert in C programming (or postgres, as it were), but
test/modules/test_shm_mq seems to call the function w/ only one
parameter, not two?



> --
> Best regards,
> Max Fomichev


Cheers,
Andrej
0 new messages