[Gambas-bugtracker] Bug #2540: Gambas does not seem to be writing to same shared memory as local processes

bugtracker at gambaswiki.org bugtracker at gambaswiki.org
Wed May 4 17:25:02 CEST 2022


http://gambaswiki.org/bugtracker/edit?object=BUG.2540&from=L21haW4-

Comment #5 by Brian G:

Sorry Did not read correctly your problem..

What is this line in your actual code :

shm_fd = shm_open(shm_id, 2, 666) ' 2=read/write

should be perhaps be

shm_fd = shm_open(shm_id, 2, &O660) ' 2=read/write

So perhaps assuming:

Extern mmap(MapPoint As Pointer, MapLength As Integer, prot As Integer, flags As Integer, fd As Integer, offset As Integer) As Pointer In "libc:6"
Extern shm_open(name As String, oflag As Integer, mode As Integer) As Integer In "librt:1"

Static Private Const PROT_READ As Integer = &H01
Static Private Const PROT_WRITE As Integer = &H02
Static Private Const MAP_SHARED As Integer = &H01
Static Private Const MAP_ANONYMOUS As Integer = &H020

Static Private Const O_ACCMODE As Integer = &O0003
Static Private Const O_RDONLY As Integer = &O00
Static Private Const O_WRONLY As Integer = &O01
Static Private Const O_RDWR As Integer = &O02
Static Private Const O_CREAT As Integer = &O0100
Static Private Const O_EXCL As Integer = &O0200

public shm_addr as pointer = 0

this section of your code:

          protection = (PROT_READ or PROT_WRITE)  ' PROT_READ | PROT_WRITE  MAP_FIXED = 16
          visibility = MAP_SHARED ' MAP_SHARED(4) MAP_PRIVATE(2)
          'Change here ******************
          shm_fd = shm_open(shm_id,O_RDWR , &O660) ' 2=read/write
          If shm_fd == -1 Then
            Message.Info("shm_open() failed!", " OK ")
            Quit
          Endif
          ' map shared Memory To process address space
          shm_addr = mmap(0, shm_size, protection, visibility, shm_fd, 0)
          mmap_err = shm_addr ' convert the pointer to a long
          If mmap_err < 1 Then
            Message.Info("mmap() failed!", " OK ")
            Quit
          Endif
          shmaddr2 = shm_addr

I hope this actually helps




More information about the Bugtracker mailing list