Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754672AbcKAUGW (ORCPT ); Tue, 1 Nov 2016 16:06:22 -0400 Received: from connotech.com ([76.10.176.241]:44697 "EHLO mail.connotech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754245AbcKAUGF (ORCPT ); Tue, 1 Nov 2016 16:06:05 -0400 X-Greylist: delayed 390 seconds by postgrey-1.27 at vger.kernel.org; Tue, 01 Nov 2016 16:06:04 EDT Message-ID: <5818F39A.30702@connotech.com> Date: Tue, 01 Nov 2016 19:57:14 +0000 From: Thierry Moreau User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Subject: Bus error on shm_open/ftruncate/mmap after changing kernel boot partition Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1658 Lines: 65 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 #include #include #include #include #include #include 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; } ============