weak

GCC optimization bug on weak const variable

陌路散爱 提交于 2021-01-22 06:51:11
问题 I'm getting a weird gcc behaviour when dealing with weak const variables on different optimize levels (i.e. -O0 or -O1 ). Here is the code: def.h : declarations const int var; int copy; int do_copy(void); weak.c : weak var definition, do_copy implementation doing copy = var #include "def.h" const int __attribute__((weak)) var = 1; int do_copy(void) { copy = var; return var; } main.c : strong var definition, and use of do_copy #include <stdio.h> #include "def.h" int copy = 0; int copy2 = 0;

Was there a a time when PHP's rand() function was used as an exploit?

放肆的年华 提交于 2020-01-07 07:28:26
问题 Does anybody know if there was a time or event where somebody used rand()'s weakness in order to predict exploit it? Something like generating tokens or cheating in video games? Since prior to PHP 7, rand() was very easy to crack. In fact here is some C code, credit to Peter Selinger, that predicts the values given a seed: #include <stdio.h> #define MAX 1000 #define seed 1 main() { int r[MAX]; int i; r[0] = seed; for (i=1; i<31; i++) { r[i] = (16807LL * r[i-1]) % 2147483647; if (r[i] < 0) { r

Disabling weak Ciphers for Tomcat 5.5.27?

风格不统一 提交于 2019-12-25 03:24:25
问题 Please let me know how can I disable weak Ciphers for Tomcat 5.5.27 回答1: See the ciphers attribute in the HTTP connector definition: http://tomcat.apache.org/tomcat-5.5-doc/config/http.html Alternatively if you're using APR, see the SSLCipherSuite directive as documented in the SSL connector configuration as documented here: http://tomcat.apache.org/tomcat-5.5-doc/apr.html. Note that OpenSSL ciphersuite names aren't quite the same as the j2se ciphersuite names. The Java ciphers are documented

Can weak symbol be resolved among libraries during linking?

佐手、 提交于 2019-12-24 04:35:52
问题 My scenario is about cross-compiling to a Arduino Due (ARM target), but I guess it's a generic C weak symbol problem. I want to break my firmware into 3 parts: 1. The hardware library (CMSIS, Middleware) -> libHardware.a 2. Realtime OS library -> libOS.a 3. Application code -> Output.elf linked to above. the referenced CMSIS implementation has declared the followings: void SysTick_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); // ...and a few dozen IRQ handler hook skipped

Setting WEAK to a non @property variable

末鹿安然 提交于 2019-12-24 00:48:27
问题 Will need someone with knowledge of ARC to help me. Basically, I have declared some variables as such in my class @interface Class{ NSString* one; NSString* two; } @property(nonatomic,weak) NSString* one; As you can see, I can set the weak identifier to NSString* one . However, I do not need a getter/setter/synthesizer for NSString* two as it is just a common variable. How can I set a weak label to it so the memory is deallocated? Or is automatically set? 回答1: You can do it like this: __weak

Python - how to check if weak reference is still available

心不动则不痛 提交于 2019-12-22 06:57:02
问题 I am passing some weakrefs from Python into C++ class, but C++ destructors are actively trying to access the ref when the real object is already dead, obviously it crashes... Is there any Python C/API approach to find out if Python reference is still alive or any other known workaround for this ? Thanks 回答1: If you call PyWeakref_GetObject on the weak reference it should return either Py_None or NULL, I forget which. But you should check if it's returning one of those and that will tell you

Trouble using scriptedmain in MinGW

一个人想着一个人 提交于 2019-12-21 21:35:54
问题 I want to reproduce this Perl code in C, bundling API and CLI in the same C source code file (scriptedmain). This is done in Python with if __name__=="__main__": main() and in gcc/Unix, this looks like: $ gcc -o scriptedmain scriptedmain.c scriptedmain.h $ ./scriptedmain Main: The meaning of life is 42 $ gcc -o test test.c scriptedmain.c scriptedmain.h $ ./test Test: The meaning of life is 42 scriptedmain.h int meaning_of_life(); scriptedmain.c #include <stdio.h> int meaning_of_life() {

iOS ARC - weak and strong properties

孤街醉人 提交于 2019-12-21 05:05:19
问题 I'm trying to understand the way ARC works, and as far as I know, I should be doing something wrong here. This is the code I'm using: Interface: @interface ViewController : UIViewController{ } @property (strong, nonatomic) NSString * myString ; @property (weak, nonatomic) NSString * myPointer ; Implementation: - (void)viewDidLoad{ [super viewDidLoad]; self.myString = @"Hello world!" ; // myString is strong self.myPointer = self.myString ; // myPointer var is weak [self performSelector:

IBOutlet for NSTextView in a ARC project

孤街醉人 提交于 2019-12-20 17:26:10
问题 As you read here in most cases a IBOutlet should be weak. Now as you can read in the development library not all classes support weak references. (e.g. NSTextView). This means you have to use assign: @property (assign) IBOutlet NSTextView *textView; If you use a weak reference you will get the following error: "Synthesis of a weak-unavailable property is disallowed because it requires synthesis of an ivar of the __weak object" What the documentation missed to mention is now you have to set

boost::shared_ptr cycle break with weak_ptr

旧城冷巷雨未停 提交于 2019-12-13 12:38:48
问题 I am currently in a situation like: struct A { shared_ptr<B> b; }; struct B { shared_ptr<A> a; }; //... shared_ptr<A> a(new A()); shared_ptr<B> b(new B()); a->b(b); b->a(a); I know this won't work, because the references would continue to point to each other. I've also been told that weak_ptr solves this issue. However, weak_ptr has no get or -> overload. I've heard mentions of 'use lock() ', but can anyone give code examples of how to do this correctly? 回答1: Come on now. http://boost.org/doc