Closed loint closed 9 years ago
@ovr I'm very interesting with zephir and want to help zephir team to fix bug and implement more useful feature but I don't have much experience with zephir compiler. How I can start with it ?
@loint I would just try to understand what goes wrong in a specific case. (Which requires reading a lot of code and much testing and debugging)
In that case it's simply that unset is not "meant" for normal variables: Unset is pretty much the "opposite" (in terms of action) as "isset"
Isset is defined (by the zephir specifcation) as:
This operator checks whether a property or index has been defined in an array or object:
and while isset (more or less) works with variables, unset does not.
The usage of unset in your example code is also unnecessary, since
the variable is not accessed after.
(which makes the statement totally redundant as key
is destroyed
by the memory frame implementation
anways after the function has completed)
@steffengy My source code sometimes fail with Segment Fault (only "Segment Fault" without warning) with simple code such as declaring new variable :( . I think the problem is memory leak, so I want to unset some variables to reduce memory and I found unset function like I used in PHP but not.
How can I release variable memory in zephir and how can I debug if "zephir builddev" occurs with Segment Fault ?
Grab a debugger such as GDB or the one of Visual Studio and analyze why it crashes. The problem here is that you should understand PHP and zephir internals, which require a lot of work to get into and understand some relations.
It's also a good idea to take a look at the generated C-Code before.
Usually these kinds of bugs also consume a lot of time figuring out why something goes wrong, so it's most of the time the opposite of trivial.
Most segmentation faults I fixed in zephir were caused by invalid pointers. (trying to write to NULL pointers and similar kinds of problems)
So I do not think that an unset implementation would help you with that.
Generally it's best if you try to consolidate your specific crash into a small sample of code and then step by step analyze what is the exact source of the crash.
@steffengy thank you for your explanation but I haven't used gdb with zephir. Can you help me with some instructions, I had just worked with zephir command and optimizers to write C code.
The problem here is, that thats a rather complex topic. You should probably google to get familar with it (using some tutorials or whatever) And even if you can use it, it only is a powerful tool to get behind a specific bug, but you still have to do the figuring-out part, which requires indepth knowledge. It's nothing I can shortly express here, it's something that requires a very large amount of work to get familiar with the codebases and internals aswell as the tools.
Thank you very much, I understood.
I can not use unset function with variable.
OS: Centos Zephir: latest version (0.6.0a)
Zep code
Compile message: