What's the correct way to free a hash table and all the entries in it? I thought zend_array_destroy would do it, but I'm still seeing memory leaks from things allocated in zend_hash.c.
Code examples appear to only use zend_array_destory, so I must be doing something wrong. I'm adding entries with zend_hash_next_index_insert_ptr.
I was working on a programming exercise and was stuck on figuring out the correct algorithm. Here is the problem:
Given a decimal number, how many minimum possible steps are required to convert this to zero provided:
Change the bit i if the next bit i+1 is '1' and all the other bi...
@Derick Can you please have a look at github.com/php/php-src/pull/6081 I tried to refactor the ZPP of DatePeriod::__construct(). Nikita was not particularly impressed ^^ but I think it's a useful change.
reminds me of a guy at a customer (lawyers) years ago, who used to print out the entire email chain for filing every time he got an email, sometimes there would be 60-70 messages in the chain that he printed every single time, like half a ream of paper
@Derick possibly; the issue is that AppVeyor apparently doesn't run the tasks in parallel (likely a limitation of the free account; maybe ask for more ressources?)
Right now, I have a different issue and that is that suddenly some of Xdebug's profiler tests are memleaking. I suspect the Observer API that's now merged in PHP ... but investigating now
considering I would really want to build more than I do now... and I have no idea how to tool to get Artifacts out of Azure either. I have a little script to do that with appveyor, and I cba to redo all of that :P
@NikiC If I have used USE_ZEND_ALLOC=0, how can I still see a Zend MM memory leak?
@NikiC but wouldn't we need a dedicated machine for that? Anhow, Dale is working on Azure pipeline builds, and is planning to open-source that when ready.
Okay, that would be nice (was rejected back then, though). The basic issue with the slow builds are the tests, from what I can tell, and these are slow because all available exts are loaded every time (multiple times per test). Running without exts is way faster (3x - 4x)
@NikiC Turned out that there was already a leak without your change too. Fixing that also fixed the new one that your change made show up → github.com/xdebug/xdebug/pull/639/files
it's only after travelling, that I became aware that the Department of Transport in the UK is a world leader in designing safe roads and signals.....most other countries have at least one 'feature' in their road designs that are inherently unsafe.
@Tiffany yes, that matches my search results. We could change the ... to ...args for now, but the problem is that PhD automatically adds a leading $ to parameters names, so that would be rendered as $...args, whereas it should be ...$args. quick-and-dirty POC for PhD
SELECT checklist.id, checklist.nomeCliente, checklist.nomeLoja, checklist.dataIni, checklist.arrayMaterialUsado, checklist.arrayComprovantes FROM checklist
UNION
SELECT os.id
INNER JOIN os_mensagens ON os.id = os_mensagens.id_os
where am i wrong This is showing up:
Query 1 ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INNER JOIN os_mensagens ON os.id = os_mensagens.id_os' at line 4
@NikiC If I've passed the zval to a user function, then I probably want Z_DELREF, no?
@NikiC Custom destructor for the hash table? Right now I loop through it, freeing the pointer before calling zend_hash_destroy. Is there an easier/better way?
Switching to zend_hash_destroy produced quite a few more leaks, so clearly I'm doing something wrong.
I'm using zend_new_array(0) to create it, that's probably wrong?
I am trying to find an email in file content and then echo the whole email. I am using strpos the location of email Like. strpos($fileContent, "@gmail.com") But how Can I get the the part before @gmail.com till an space with substr?
@cmb @NikiC Thanks! That helps move my pointer freeing to one place. I added FREE_HASHTABLE after zend_hash_destroy. Still getting a couple memory leaks though. zend_hash.c(153) : Freeing 0x0000000103817a00 (264 bytes), zend_hash.c(2072) : Freeing 0x0000000103796480 (56 bytes)
@NikiC If I want to store and clear an exception thrown when using zend_call_function, does this look correct? error = EG(exception); GC_ADDREF(error); zend_clear_exception();
Basically add -fsanitize=address to your CFLAGS and LDFLAGS at configure time. Are you building this as part of PHP or a standalone extension build or..?
@FlorianMargaine there's a couple of things that seem to be accepted in France that are just never allowed in UK roads. e.g. slip roads/onramps that are too short That junction is fine when there's no traffic. And it's fine when there's heavy traffic, so everyone is moving slowly.
But when there is moderately heavy traffic, the cars are all moving fast, and there isn't enough time to merge safely. And as the slip road is only 50 meters long, you have to choose between doing an unsafe merge, or slamming on the brakes, and having any care behind you probably ram into you.
Also, the habit in the countryside of not making roads wide enough for two cars, but everyone still passes each other at 100km/h, with half the wheels on the grass....
@Trowski so from wikipedia (fibers use cooperative multitasking) i am making assumptions, with a fiber everything still runs linear. and unless something with blocking I/O has explicit code to "yield" to another fiber the API is just looking parallel, but is essentially not
@beberlei my understanding is, you could run workers with parallels, and then do async communication between the processes with fibres....which would be equivalent to Go's channels.
@cmb would it be preferable at all to just not add anything special for <parameter>? It seems like adding extra content is a hindrance now, and will likely be a hindrance in the future if the language and/or manual evolves...
@rangerboyy You can't, the best you can achieve is checking if it doesn't bounce back, but for that you need to send an email to said address, which is probably not feasible
@cmb As a quick idea, we could cache the result of SKIPIF sections by hash. Probably we don't have that many distinct skipifs. Not sure how much that would save though
@cmb this question is from complete inexperience, but could we do something like $attrs[Reader::XMLNS_DOCBOOK]["role"]["reference"] and $attrs[Reader::XMLNS_DOCBOOK]["role"]["variadic"]?
or something of that sort... or maybe have $attrs[Reader::XMLNS_DOCBOOK]["role"] = "reference"; and $attrs[Reader::XMLNS_DOCBOOK]["role"] = "variadic";?
no, that would not work; we could have <parameter role="reference,variadic"> I suppose, but not sure whether that would have to be regarded as hack; note that variadics can be passed by-ref as well
I have checked all the questions first. But non of them helped to solve my problem.
I have PHP E-mail responder connected to HTML contact form. I need to display selected checkbox value inside the email responder which is sent to customer.
PHP code
<?php
if(isset($_POST) && ($_POST['send'] == 1)...
@LuboMasura tbh at this time on a friday it's not all that likely, but please note that it's just because it's friday night and everyone is busy doing other stuff :-)
When trying to use valgrind, I get Fatal error: Error installing signal handler for 31 in Unknown on line 0 Could not startup. Is there a env var or something else I need to set to stop that?
Digging a bit, looks like EG(user_exception_handler) is what I'm looking for. Though it appears to be a zval, not sure how to call from a zval… I've always had zend_fcall_info.
In the fiber extension I'm working on, a fiber has a set of callbacks when it finishes. That callback shouldn't throw. If it does, I was going to forward the exception to the user exception handler or fatal error.
@Trowski I think normally, you just look at if one of those callbacks has thrown an exception, and stop processing the other callbacks, and resume control to the engine....which then would do the appropriate exception stuff for you.
The exception from a fiber throwing then has to go to the Awaitable::onResolve() callback that resumed the fiber, so then we have an unhandled exception there.
Which also happens if Fiber implements awaitable, but then we don't have to tell implementers of Awaitable to expect their onResolve callbacks to throw.
Sure. But I think it always bubbles up to the scheduler that way and it's a lot better than solving multiple maybe throwing callbacks and then solving what to do with that exception.
That was fine too I guess. I liked that the callback to suspend didn't require you to call Fiber::getCurrent() to get the reference to the fiber object.
Plus it made suspend return a value, which IMO is a bit more intuitive.
@Crell different wrappers will happen without the scheduler in core, but we've designed the API in a way so that multiple projects can interoperate and don't break each other. However, if they're not using the same scheduler, different schedulers will still block each other.
@bwoebi You set up the code to resume or throw within the callback. It avoided requiring references or another object (though at the cost of a closure… so it's a bit of a toss).
@kelunik Yeah, good point. The event loop is the only real interop hangup.
@Trowski how exactly is that superior to just $fiber = Fiber::getCurrent(); $promise->onResolve(function($e, $v) use ($fiber) { ... }); Fiber::suspend();
I don't know the details, I am just begging you to not create a situation where FIG will have to re-standardize anything, which some projects will ignore on principle. :-)
@Trowski I don't think we should have the suspend($cb), this also has a strong assumption that the fiber gets to decide itself when it is going to be resumed … which we can still have, but only explicitly, and not mandated by the API
If you use a fiber like we did generators in amp, then another library couldn't use a fiber without having interop issues.
Was fine with generators since they're self contained, but fibers are an issue since another lib could call suspend expecting their promise implementation.
@kelunik I do not see the issue: await calls the event loop, the event loop waits for its events, processes them … at some time the promise of await gets resolved and it continues