Home » U++ Library support » U++ MT-multithreading and servers » Witz and Skylark weird behaviour (possibly a bug)
Witz and Skylark weird behaviour (possibly a bug) [message #38521] |
Fri, 21 December 2012 15:12 |
Peter
Messages: 16 Registered: October 2012
|
Promising Member |
|
|
Hello.
Let's start with the code:
main.cpp:
#include <Skylark/Skylark.h>
using namespace Upp;
SKYLARK(HomePage, "")
{
ValueMap lng;
lng.Add(LNG_('P','L','P','L'), "Polish");
lng.Add(LNG_('E','N','U','S'), "English");
http("LNG_LIST", lng).RenderResult("Skylark_Bug/page");
}
SKYLARK(CatchAll, "**")
{
http.Redirect(HomePage);
}
struct MyApp : SkylarkApp {
MyApp() {
#ifdef _DEBUG
prefork = 0;
use_caching = false;
#endif
}
};
CONSOLE_APP_MAIN
{
#ifdef _DEBUG
StdLogSetup(LOG_FILE|LOG_COUT);
Ini::skylark_log = true;
#endif
MyApp().Run();
}
page.witz:
<html>
<body>
<form action=$ACTION method="post" accept-charset="utf-8" enctype="multipart/form-data">
$post_identity()
<select name="language">
$for(i in LNG_LIST)
<option value="">$i</option>
$/
</select>
</form>
</body>
</html>
When I compile the above code, run the application and go to its root page, I should see a menu from which I can choose one of two languages. What I see instead is some random ID string as both menu options. However, when I refresh the page, it suddenly displays menu contents correctly (see the attached files wrong.html and correct.html for reference).
If I change <option value=""> to <option value="$i._key"> and try to display the page for the first time, the whole application crashes due to a segmentation fault.
I investigated the problem and I know it's caused by
"$post_identity()" in page.witz (that's where the random ID comes from).
Why are the page contents wrong the first time it's displayed (a value from a hidden field overrides both valid values from ValueMap) and why are the correct values displayed after reloading the page? Finally, why does a reference to i._key in page.witz cause a crash? I imagine why it can happen - I'm trying to retrieve the key of a random ID which is not an element of my ValueMap, but is this the expected behaviour? Shouldn't it evaluate to null, empty string etc. instead of causing a segmentation fault?
Is it a problem with Witz or Skylark or both?
Best regards
Peter
-
Attachment: wrong.html
(Size: 0.49KB, Downloaded 292 times)
-
Attachment: correct.html
(Size: 0.44KB, Downloaded 286 times)
|
|
|
|
Goto Forum:
Current Time: Sat Mar 30 01:52:43 CET 2024
Total time taken to generate the page: 0.01272 seconds
|