Bug 811842

Summary: YCP code in yast2-scanner lets YaST segfault in ncurses mode
Product: [openSUSE] openSUSE 12.3 Reporter: Forgotten User d3bkfIx-vJ <forgotten_d3bkfIx-vJ>
Component: YaST2Assignee: Thomas Göttlicher <tgoettlicher>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Major    
Priority: P5 - None CC: forgotten_d3bkfIx-vJ, gs, jsmeix, linuxlalala, mfilka, mvidner, novell, tgoettlicher
Version: Final   
Target Milestone: ---   
Hardware: All   
OS: openSUSE 12.3   
Whiteboard:
Found By: Community User Services Priority:
Business Priority: Blocker: No
Marketing QA Status: --- IT Deployment: ---
Attachments: y2log
y2log from "yast scanner" start until segfault
y2log in graphical mode from start until "UI Syntax Error"

Description Forgotten User d3bkfIx-vJ 2013-03-26 20:30:04 UTC
User-Agent:       Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22

yast in text mode doesn't install my scanner (epson perfection 1250) correctly.
I can go to the scanner configuration, I can choose the right driver (plustek) but when I say OK yast is just going back to the previous menu. The configuration didn't happen.

The GUI of yast2 is doing the job fine.


Reproducible: Always

Steps to Reproduce:
1.start yast
2. add configure the scanner with the plustek driver
3. "OK"
Actual Results:  
nothing

Expected Results:  
driver should be installed
Comment 1 Thomas Fehr 2013-03-27 09:32:23 UTC
Could be a problem with ncurses UI or with YCP code.
Reassigning to maintainer of yast2-scanner, adding ncurses maintainer to CC:
Comment 2 Johannes Meixner 2013-03-27 09:44:07 UTC
Please provide YaST logs.
Comment 4 Forgotten User d3bkfIx-vJ 2013-03-28 12:40:24 UTC
Created attachment 532447 [details]
y2log
Comment 5 Forgotten User d3bkfIx-vJ 2013-03-28 12:41:12 UTC
is this the log you asked for?
Comment 6 Johannes Meixner 2013-04-02 09:15:14 UTC
Created attachment 533004 [details]
y2log from "yast scanner" start until segfault

When I run it in ncurses mode it crashes with
----------------------------------------------------------------------------
/sbin/yast2: line 431: 31653 Segmentation fault
$ybindir/y2base $module "$@" "$SELECTED_GUI" $Y2_GEOMETRY $Y2UI_ARGS
----------------------------------------------------------------------------
printed in the Xterm from where I had started "yast scanner".

I get the same "invalid index" error
------------------------------------------------------------------------------
2013-04-02 10:52:35 <3> g139(31653) [Interpreter] Wizard.ycp:862 invalid
 index -1220233708 (max 2) in YCPValue YCPListRep::value(int) const
2013-04-02 10:52:35 <5> g139(31653) [zypp]
 ZYppFactory.cc(sigsegvHandler):53 Error: signal 11
------------------------------------------------------------------------------
as in your attachment#532447 [details]
------------------------------------------------------------------------------
2013-03-28 13:34:33 <3> print.site(1759) [Interpreter] Wizard.ycp:862 invalid
 index -1219418604 (max 2) in YCPValue YCPListRep::value(int) const
2013-03-28 13:34:33 <5> print.site(1759) [zypp]
 ZYppFactory.cc(sigsegvHandler):53 Error: signal 11
------------------------------------------------------------------------------
Comment 7 Johannes Meixner 2013-04-02 09:22:16 UTC
Created attachment 533005 [details]
y2log in graphical mode from start until "UI Syntax Error"

In graphical mode I get an error popup that reads:
---------------------------------------------------------------
         UI Syntax Error
  Invalid argument for the PushButton widget
         Check the log file!
            [Close]
---------------------------------------------------------------

When I click [Close] it proceeds and my scanner driver
gets activated.
Comment 8 Johannes Meixner 2013-04-02 09:25:45 UTC
This YCP code in yast2-scanner is rather old
and I did not do any changes since a longer time.
Comment 9 Forgotten User d3bkfIx-vJ 2013-04-02 10:34:20 UTC
Do you need more information to be able to fix this?
Comment 11 Johannes Meixner 2013-04-04 09:52:08 UTC
The YCP code in yast2-scanner is
/usr/share/YaST2/include/scanner/dialogs.ycp

I guess it might be somehow related to this therein:
-------------------------------------------------------------------------------
any SelectModelDialog()
...
  Wizard::SetContentsButtons( caption,
                              contents,
                              HELPS["select_model"]:"",
                              Label::BackButton(),
                              Label::NextButton()
                            );
  // According to the YaST Style Guide (dated Tue, 04 Nov 2008)
  // the button with the "back" functionality must be disabled
  // only when it is the first dialog of a wizard stlye dialog sequence.
   
  // According to the YaST Style Guide (dated Tue, 04 Nov 2008)
  // there is no longer a "abort" functionality which exits the whole module.
  // Instead this button is now named "Cancel" and its functionality is
  // to go back to the Overview dialog (i.e. what the "back" button would do)
  // because it reads "Cancel - Closes the window and returns to the overview."
  Wizard::SetAbortButton( `back, Label::CancelButton() );
-------------------------------------------------------------------------------

My guess is because
in attachment#533005 [details] there is
-------------------------------------------------------------------------------
[libycp] Wizard.ycp:862 Widget id `back is not unique
[libycp] Wizard.ycp:862 Invalid arguments for the PushButton widget:
 `PushButton (`id (`back), `opt (`key_F8), "&Back")
[ui] YCPDialogParser.cc(parsePushButton):1435 	THROW:
    Invalid arguments for the PushButton widget
-------------------------------------------------------------------------------
and in attachment#533004 [details] theer is
-------------------------------------------------------------------------------
[libycp] Wizard.ycp:862 Widget id `back is not unique
[Interpreter] Wizard.ycp:862 invalid index -1220233708 (max 2) in
 YCPValue YCPListRep::value(int) const
[zypp] ZYppFactory.cc(sigsegvHandler):53 Error: signal 11
-------------------------------------------------------------------------------

I guess that
  Wizard::HideBackButton();
keeps the widget id `back as a vaild/active widget id
so that the subsequent
  Wizard::SetAbortButton( `back, Label::CancelButton() );
adds another valid/active widget with id `back
and I guess that two widgets with same id
cause the segfault in ncurses mode and
the "UI Syntax Error" in graphical mode.

But I really have no knowledge about YaST internals
so that my guesses could be totally misleading.
Comment 12 Johannes Meixner 2013-04-04 09:54:35 UTC
Strange - somehow a line disappeared in comment#11.

The excerpt from scanner/dialogs.ycp should read:
-------------------------------------------------------------------------------
any SelectModelDialog()
...
  Wizard::SetContentsButtons( caption,
                              contents,
                              HELPS["select_model"]:"",
                              Label::BackButton(),
                              Label::NextButton()
                            );
  // According to the YaST Style Guide (dated Tue, 04 Nov 2008)
  // the button with the "back" functionality must be disabled
  // only when it is the first dialog of a wizard stlye dialog sequence.
  Wizard::HideBackButton();
  // According to the YaST Style Guide (dated Tue, 04 Nov 2008)
  // there is no longer a "abort" functionality which exits the whole module.
  // Instead this button is now named "Cancel" and its functionality is
  // to go back to the Overview dialog (i.e. what the "back" button would do)
  // because it reads "Cancel - Closes the window and returns to the overview."
  Wizard::SetAbortButton( `back, Label::CancelButton() );
-------------------------------------------------------------------------------
Comment 13 Michal Filka 2013-04-04 11:56:20 UTC
> I get the same "invalid index" error
> ------------------------------------------------------------------------------
> 2013-04-02 10:52:35 <3> g139(31653) [Interpreter] Wizard.ycp:862 invalid
>  index -1220233708 (max 2) in YCPValue YCPListRep::value(int) const
> 2013-04-02 10:52:35 <5> g139(31653) [zypp]
>  ZYppFactory.cc(sigsegvHandler):53 Error: signal 11
> ------------------------------------------------------------------------------
> as in your attachment#532447 [details]
> ------------------------------------------------------------------------------
> 2013-03-28 13:34:33 <3> print.site(1759) [Interpreter] Wizard.ycp:862 invalid
>  index -1219418604 (max 2) in YCPValue YCPListRep::value(int) const
> 2013-03-28 13:34:33 <5> print.site(1759) [zypp]
>  ZYppFactory.cc(sigsegvHandler):53 Error: signal 11
> ------------------------------------------------------------------------------

In my opinion it seems as a zypper problem. Reassigning to zypper maintainers.
Comment 14 Michael Andres 2013-04-04 13:57:04 UTC
No zypp problem. But zypp has a SEGV handler which dumps a stack trace to the log before exiting:

[zypp] ZYppFactory.cc(sigsegvHandler):53 Error: signal 11
[bt]: (1) /usr/lib/libzypp.so.1200 : +0x2eaaab [0xb6a48aab]
[bt]: (2) linux-gate.so.1 : __kernel_sigreturn+0 [0xb77aa400]

The first two entries were caused by the SEGV handler itself, 
below is the crash:

[bt]: (3) /usr/lib/libycpvalues.so.5 : YCPValueRep::isTerm() const+0x7 [0xb7599167]
[bt]: (4) /usr/lib/YaST2/plugin/libpy2UI.so.2 : YCPDialogParser::getWidgetOptions(YCPTerm const&, int*)+0xa5 [0xb6ffc385]
[bt]: (5) /usr/lib/YaST2/plugin/libpy2UI.so.2 : YCPDialogParser::parseWidgetTreeTerm(YWidget*, YWidgetOpt&, YCPTerm const&)+0x61 [0xb7014a91]
[bt]: (6) /usr/lib/YaST2/plugin/libpy2UI.so.2 : YCPDialogParser::parseWidgetTreeTerm(YWidget*, YCPTerm const&)+0x9d [0xb701888d]
[bt]: (7) /usr/lib/YaST2/plugin/libpy2UI.so.2 : YCP_UI::ReplaceWidget(YCPValue const&, YCPTerm const&)+0xd2 [0xb6ff5ec2]
[bt]: (8) /usr/lib/YaST2/plugin/libpy2UI.so.2 : YUINamespace::ReplaceWidget(YCPTerm const&, YCPTerm const&)+0x46 [0xb6fdcc46]
[bt]: (9) /usr/lib/YaST2/plugin/libpy2UI.so.2 : YUIFunction::evaluateCall_int()+0x483a [0xb6fe299a]
[bt]: (10) /usr/lib/YaST2/plugin/libpy2UI.so.2 : YCPBuiltinCaller::call()+0x35 [0xb6ff9e65]
[bt]: (11) /usr/lib/libyui.so.4 : YUI::uiThreadMainLoop()+0x74 [0xb6f4c5e4]
[bt]: (12) /usr/lib/libyui.so.4 : start_ui_thread(void*)+0x1f [0xb6f4c75f]
[bt]: (13) /lib/libpthread.so.0 : +0x6b5e [0xb751eb5e]
[bt]: (14) /lib/libc.so.6 : clone+0x5e [0xb732b16e]


The crash is in libycpvalues from yast2-core package -> AFAIK maintained by Martin; and Cc: to Thomas as libui seems to be involved.
Comment 15 Martin Vidner 2013-04-04 15:55:18 UTC
YCPDialogParser::getWidgetId fails to assign to *argnr if the widget id is not unique. YCPDialogParser::getWidgetOptions then uses the uninitialized value.

https://github.com/yast/yast-ycp-ui-bindings/blob/1ca059ace45c2ecefaec2680314c0e3d0fd755be/src/YCPDialogParser.cc#L3688

-> Thomas

I guess that Johannes should split off a bug for the duplicated id problem that triggers the UI bug.
Comment 16 Thomas Göttlicher 2013-04-05 09:30:17 UTC
> /**
>  * Look for a widget id in a widget term. If it finds one, returns
>  * it and sets argnr to 1, otherwise it creates a new unique widget
>  * id and sets argnr to 0. For example PushButton( `id( 17 ), .... )
>  * has with id 17.
>  * Return value: The widget id on success or YCPNull on failure
>  **/
> static YCPValue getWidgetId( const YCPTerm & term, int *argnr );

Looking at the documentation setting *argnr to 1 makes most sense. Martin, are you fine with this?
Comment 17 Martin Vidner 2013-04-05 14:30:51 UTC
Well, setting *argnr to 1 makes most sense.

Reading the implementation, the doc should read:
- argnr is set to point after an `id(), whether it turned out valid or not
(that's the subject of this fix)

and:
- if we cannot find an id, or the id is a duplicate of an existing one, nil is returned.
Comment 18 Thomas Göttlicher 2013-07-05 11:53:18 UTC
Fixed in yast2-ycp-ui-bindings version 2.24.0.
Comment 19 Johannes Meixner 2013-08-29 10:00:17 UTC
*** Bug 833234 has been marked as a duplicate of this bug. ***