Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1513464

Bus error on shm_open/ftruncate/mmap after changing kernel boot partition

From Thierry Moreau <thierry.moreau@connotech.com>
Newsgroups linux.kernel
Subject Bus error on shm_open/ftruncate/mmap after changing kernel boot partition
Date 2016-11-01 21:10 +0100
Message-ID <syNxD-4RO-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Strange bug after changing the boot partition (the previous was on a 
hard disk with a few media errors).

I must apologize that the old partition is re-formatted. (As an excuse 
the other services on this server system work fine with the new partition.)

Anyway, the bogus code sequence is below. Should work fine everywhere, 
modulo write permission on /dev/shm.

Same observation with privileged execution.

uname -a reports:

Linux hostname 4.1.3 #15 SMP Sun Aug 30 03:01:12 UTC 2015 x86_64 
Intel(R) Pentium(R) CPU G3250 @ 3.20GHz GenuineIntel GNU/Linux

Obviously, any help appreciated.

Regards

- Thierry Moreau


============
/* mmap_test.cpp --
*/

#include <cstdio>
#include <cstring>
#include <cerrno>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
   int shm_fd;
   shm_fd=shm_open(/*"/dev/shm/"*/"test",
          O_RDWR | O_CREAT | O_EXCL,
          S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP);
   if (shm_fd>=0) {
     if (ftruncate(shm_fd,0x20000)==0) {
       void *region=mmap(0,0x20000,
                    PROT_READ|PROT_WRITE,MAP_SHARED,
                    shm_fd,0);
       if (MAP_FAILED!=region) {
	fprintf(stderr,"%d %p\n",__LINE__,region);
	fprintf(stderr,"%d %d\n",__LINE__,*((int *)region));
         /* ===== this triggers a bus error on the kernel instance */
       }
       else {
	fprintf(stderr,"%d %d %s\n",__LINE__,errno,strerror(errno));
       }
     }
     else {
       fprintf(stderr,"%d %d %s\n",__LINE__,errno,strerror(errno));
     }
   }
   else {
     fprintf(stderr,"%d %d %s\n",__LINE__,errno,strerror(errno));
   }
return errno;
}
============

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Bus error on shm_open/ftruncate/mmap after changing kernel boot partition Thierry Moreau <thierry.moreau@connotech.com> - 2016-11-01 21:10 +0100
  Re: Bus error on shm_open/ftruncate/mmap after changing kernel boot  partition: FIXED Thierry Moreau <thierry.moreau@connotech.com> - 2016-11-02 00:40 +0100

csiph-web