mmap

Segfault reading lazy bytestring past 2^18 bytes

这一生的挚爱 提交于 2019-12-08 16:37:19
问题 Consider the following code: http://hpaste.org/90394 I am memory mapping a large 460mb file to a lazy ByteString. The length of the ByteString reports 471053056 . When nxNodeFromID file 110000 is changed to a lower node ID, ie: 10000 , it works perfectly. However; as soon as I try and serialize anything past exactly 2^18 bytes ( 262144 ) of the ByteString I get Segmentation fault/access violation in generated code and termination. I'm running Windows and using GHC 7.4.2. Please advise whether

Unmapping or 'release' a MappedByteBuffer under Android

筅森魡賤 提交于 2019-12-08 15:31:55
问题 The usual problem in Java is that you have to hack to get a proper unmapping of memory mapped files - see here for the 14year old bug report ;) But on Android there seems to be 0 solutions in pure Java and just via NDK. Is this true? If yes, any pointers to an open source solution with Android/Java bindings? 回答1: There is no hack available under Android. But there are a few helpers and snippets which make the C-Java binding for mmap files easy/easier: util-mmap, Apache License 2.0, here is an

mmap very slow when using O_SYNC

ε祈祈猫儿з 提交于 2019-12-08 11:39:11
问题 Brief description of our project: We are using CycloneV in our project, FPGA will write data to DDR using AXI bus and our application needs to send the data out using Ethernet. We benchmark our Ethernet throughput using iperf and it can achieve a speed of about 700Mbps. When we test our application throughput, the result we are getting is just 400Mbps. We write a simple server code without using /dev/mem , then populate the memory with random data using dd command and the application reads

Read Text file using Boost mmap

最后都变了- 提交于 2019-12-08 06:50:52
问题 I am reading the following file: File.txt Y:\Test\DOCUMENTS\DOCUMENTS\Flux Assurance 2\multi\ACTEPROC_OK\018-1-R.xml Y:\Test\DOCUMENTS\DOCUMENTS\Flux Assurance 2\multi\ACTEPROC_OK\A018-2-R.xml Y:\Test\DOCUMENTS\DOCUMENTS\Flux Assurance 2\multi\ACTEPROC_OK\021-1-R.xml Y:\Test\DOCUMENTS\DOCUMENTS\Flux Assurance 2\multi\ACTEPROC_OK\A021-2-R.xml Y:\Test\DOCUMENTS\DOCUMENTS\Flux Assurance 2\multi\ACTEPROC_OK\022-1-R.xml Y:\Test\DOCUMENTS\DOCUMENTS\Flux Assurance 2\multi\ACTEPROC_OK\022-2-R.xml Y:

Can we TWO MMAP on same /dev file

不羁岁月 提交于 2019-12-08 05:17:35
问题 I have build an character driver in which i am allocating two PAGESIZE buffer using dma_alloc_coherent() Now i am passing the PHYSICAL address of these BUFFER [src_ptr & dest_ptr] to user space using ioctl() as source_offset and dest_offset . In user space this offeset is used as an offset for mmap call. So on same /dev file say /dev/250 i am making TWO MMAP call usr_src_ptr= mmap(0,page_size, PROT_READ|PROT_WRITE, MAP_SHARED,dev_FD, src_offset ); if (usr_src_ptr == MAP_FAILED){ printf("USR

Looking for mmap flag values

蹲街弑〆低调 提交于 2019-12-08 05:11:35
问题 I was wondering where I could find mmap flag values on os x. The manpages for mmap say to use MAP_PRIVATE, MAP_... and such, but if you are dealing with assembly you have to know the actual values to make the syscall. I tried looking for the header files that defined these constants but I could not find it. Could someone link it possibly? 回答1: Using the -E option with gcc allows you to see the output of a source file after the preprocessor. Using gcc -E test.c on the following source file

How to use mmap to point to STL type?

喜夏-厌秋 提交于 2019-12-08 04:18:19
问题 I have a mmap typecast to a char pointer char *ptr; ptr = (char *)mmap(0, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); This was my earlier code. But now I want to use a map instead of char * as the requirements changed. Now, my map is declared as map < int, string > i_s_map; How do I change my mmap call to point to the map? 回答1: You don't want to store STL containers in shared memory, at least not share them. The reason is that they rely heavily on heap allocation, so out-of-the-box

ASLR bits of Entropy of mmap()

泪湿孤枕 提交于 2019-12-08 03:32:53
问题 I am studying ASLR randomization of mmap(), on x86 system. I have read in a lot of places that there are 16bits of randomization on the address loaded with mmap(). But in the source code i have found: static unsigned long mmap_rnd(void) 02 { 03 unsigned long rnd = 0; 04 05 /* 06 * 8 bits of randomness in 32bit mmaps, 20 address space bits 07 * 28 bits of randomness in 64bit mmaps, 40 address space bits 08 */ 09 if (current->flags & PF_RANDOMIZE) { 10 if (mmap_is_ia32()) 11 rnd = (long)get

How do you allocate a specific area of memory using the 'mmap' command in C? (Android NDK)

半世苍凉 提交于 2019-12-08 03:13:23
问题 What is the proper way to allocate a specific region of memory using 'mmap' in C? I've read /proc/self/maps to determine that the area is available. I've tried the following, but it crashes when trying to write to the allocated memory: // rdram is defined in header as: #define rdram ((unsigned int *)0x80000000) printf( "rdram=0x%x", (int)rdram ); printf( "munmapping" ); munmap ((void*)0x80000000, 0x800000); printf( "mmapping" ); if(mmap ((void*)0x80000000, 0x800000, PROT_READ | PROT_WRITE,

Converting a pointer to a byte slice

白昼怎懂夜的黑 提交于 2019-12-08 01:38:50
问题 The Mmap() syscall in the x/sys/unix package in Golang returns a []byte type, while the underlying syscall actually returns a pointer. How does it do this? More specifically, in this package by a Golang developer, the VirtualAlloc function simply returns a pointer. How can this be converted to a byte slice, the same way as it's done in the Unix package? 回答1: Using the unsafe package you can do the same thing golang.org/x/sys/unix does in the Mmap method of its unexported mmapper type: //