Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 1398709 Details for
Bug 1547495
Incorrect branching in postgresql on ppc64 when compiled with -O3
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh90 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
reproducer
oom-reproducer.c (text/x-csrc), 4.24 KB, created by
Petr Kubat
on 2018-02-21 12:48:18 UTC
(
hide
)
Description:
reproducer
Filename:
MIME Type:
Creator:
Petr Kubat
Created:
2018-02-21 12:48:18 UTC
Size:
4.24 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <stdint.h> >#include <string.h> >#include <sys/types.h> > >#ifndef bool >typedef char bool; >#endif > >#ifndef true >#define true ((bool) 1) >#endif > >#ifndef false >#define false ((bool) 0) >#endif > >#define VFD_CLOSED (-1) >#define Assert(condition) ((void)true) >#define MEMSET_LOOP_LIMIT 1024 >#define LONG_ALIGN_MASK (sizeof(long) - 1) > >#define MemSet(start, val, len) \ > do \ > { \ > /* must be void* because we don't know if it is integer aligned yet */ \ > void *_vstart = (void *) (start); \ > int _val = (val); \ > Size _len = (len); \ >\ > if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \ > (_len & LONG_ALIGN_MASK) == 0 && \ > _val == 0 && \ > _len <= MEMSET_LOOP_LIMIT && \ > /* \ > * If MEMSET_LOOP_LIMIT == 0, optimizer should find \ > * the whole "if" false at compile time. \ > */ \ > MEMSET_LOOP_LIMIT != 0) \ > { \ > long *_start = (long *) _vstart; \ > long *_stop = (long *) ((char *) _start + _len); \ > while (_start < _stop) \ > *_start++ = 0; \ > } \ > else \ > memset(_vstart, _val, _len); \ > } while (0) > >typedef unsigned int Index; >typedef int File; >typedef size_t Size; > >typedef struct vfd >{ > int fd; /* current FD, or VFD_CLOSED if none */ > unsigned short fdstate; /* bitflags for VFD's state */ > // ResourceOwner resowner; /* owner, for automatic cleanup */ > File nextFree; /* link to next free VFD, if in freelist */ > File lruMoreRecently; /* doubly linked recency-of-use list */ > File lruLessRecently; > off_t seekPos; /* current logical file position, or -1 */ > off_t fileSize; /* current size of file (0 if not temporary) */ > char *fileName; /* name of file, or NULL for unused VFD */ > /* NB: fileName is malloc'd, and must be free'd when closing the VFD */ > int fileFlags; /* open(2) flags for (re)opening the file */ > int fileMode; /* mode to pass to open(2) */ >} Vfd; > >static Vfd *VfdCache; >static Size SizeVfdCache = 0; > >void >InitFileAccess(void) >{ > Assert(SizeVfdCache == 0); /* call me only once */ > > /* initialize cache header entry */ > VfdCache = (Vfd *) malloc(sizeof(Vfd)); > if (VfdCache == NULL) { > fprintf(stderr, "%s", "OUT OF MEMORY!\n"); > exit(1); > } > MemSet((char *) &(VfdCache[0]), 0, sizeof(Vfd)); > VfdCache->fd = VFD_CLOSED; > > SizeVfdCache = 1; >} > >static File >AllocateVfd(void) >{ > Index i; > File file; > > printf("Current cache size: %i\n", SizeVfdCache); > if (VfdCache[0].nextFree == 0) > { > /* > * The free list is empty so it is time to increase the size of the > * array. We choose to double it each time this happens. However, > * there's not much point in starting *real* small. > */ > printf("List is empty, doubling size\n"); > Size newCacheSize = SizeVfdCache * 2; > Vfd *newVfdCache; > > if (newCacheSize < 32) > newCacheSize = 32; > > /* > * Be careful not to clobber VfdCache ptr if realloc fails. > */ > newVfdCache = (Vfd *) realloc(VfdCache, sizeof(Vfd) * newCacheSize); > if (newVfdCache == NULL) { > fprintf(stderr, "%s", "OUT OF MEMORY!\n"); > free(VfdCache); > exit(1); > } > VfdCache = newVfdCache; > > /* > * Initialize the new entries and link them into the free list. > */ > for (i = SizeVfdCache; i < newCacheSize; i++) > { > MemSet((char *) &(VfdCache[i]), 0, sizeof(Vfd)); > VfdCache[i].nextFree = i + 1; > VfdCache[i].fd = VFD_CLOSED; > } > VfdCache[newCacheSize - 1].nextFree = 0; > VfdCache[0].nextFree = SizeVfdCache; > > /* > * Record the new size > */ > SizeVfdCache = newCacheSize; > } > > file = VfdCache[0].nextFree; > > VfdCache[0].nextFree = VfdCache[file].nextFree; > > return file; >} > >int main (int argc, char **argv) { > File f; > InitFileAccess(); > while(1) > f = AllocateVfd(); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1547495
: 1398709