Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcedit crash on safe (shadows) #4192

Closed
mc-butler opened this issue Feb 2, 2021 · 7 comments
Closed

mcedit crash on safe (shadows) #4192

mc-butler opened this issue Feb 2, 2021 · 7 comments
Assignees
Labels
area: tty Interaction with the terminal, screen libraries prio: medium Has the potential to affect progress ver: 4.8.26 Reproducible in version 4.8.26
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/4192
Reporter slyfox (@trofi)

It's a forward of upstream https://bugs.gentoo.org/768285 ticket by Thomas Deutschmann where mc crashes on certain window sizes in shadow clipping code.

Backtrace is:

#0  g_log_structured_array (log_level=<optimized out>, fields=0x7fffe2dff550, n_fields=4)
    at ../glib-2.66.4/glib/gmessages.c:554
554     ../glib-2.66.4/glib/gmessages.c: No such file or directory.
(gdb) bt
#0  g_log_structured_array (log_level=<optimized out>, fields=0x7fffe2dff550, n_fields=4)
    at ../glib-2.66.4/glib/gmessages.c:554
#1  0x00007fb071105955 in g_log_default_handler (log_domain=log_domain@entry=0x7fb07115300e "GLib",
    log_level=log_level@entry=6,
    message=message@entry=0x56421febd830 "../glib-2.66.4/glib/gmem.c:112: failed to allocate 18446744073709551588 bytes", unused_data=unused_data@entry=0x0) at ../glib-2.66.4/glib/gmessages.c:3123
#2  0x00007fb071105bb1 in g_logv (log_domain=0x7fb07115300e "GLib", log_level=G_LOG_LEVEL_ERROR,
    format=<optimized out>, args=<optimized out>) at ../glib-2.66.4/glib/gmessages.c:1350
#3  0x00007fb071105e57 in g_log (log_domain=log_domain@entry=0x7fb07115300e "GLib",
    log_level=log_level@entry=G_LOG_LEVEL_ERROR, format=format@entry=0x7fb07115d790 "%s: failed to allocate %lu bytes")
    at ../glib-2.66.4/glib/gmessages.c:1415
#4  0x00007fb0711045a4 in g_malloc (n_bytes=18446744073709551588) at ../glib-2.66.4/glib/gmem.c:111
#5  0x000056421ef63ea1 in tty_colorize_area (y=12, x=122, rows=6, cols=-2, color=10) at tty-ncurses.c:565
#6  0x000056421ef64ec5 in tty_draw_box_shadow (y=11, x=-2, rows=7, cols=124, shadow_color=10) at tty.c:272
#7  0x000056421ef27b58 in frame_draw (f=0x56421febb550) at frame.c:80
#8  0x000056421ef27d65 in frame_callback (w=0x56421febb550, sender=0x0, msg=MSG_DRAW, parm=0, data=0x0) at frame.c:132
#9  0x000056421ef6c15d in widget_draw (w=0x56421febb550) at widget-common.c:526
#10 0x000056421ef298bd in group_draw (g=0x56421feb8200) at group.c:420
#11 0x000056421ef29d03 in group_default_callback (w=0x56421feb8200, sender=0x0, msg=MSG_DRAW, parm=0, data=0x0)
    at group.c:563
#12 0x000056421ef192c1 in dlg_default_callback (w=0x56421feb8200, sender=0x0, msg=MSG_DRAW, parm=0, data=0x0)
    at dialog.c:343
#13 0x000056421ef6cef5 in query_default_callback (w=0x56421feb8200, sender=0x0, msg=MSG_DRAW, parm=0, data=0x0)
    at wtools.c:112
#14 0x000056421ef6c15d in widget_draw (w=0x56421feb8200) at widget-common.c:526
#15 0x000056421ef6c733 in widget_default_set_state (w=0x56421feb8200, state=WST_FOCUSED, enable=1)
    at widget-common.c:779
#16 0x000056421ef29e0c in group_default_set_state (w=0x56421feb8200, state=WST_FOCUSED, enable=1) at group.c:610
#17 0x000056421ef18b4e in widget_set_state (w=0x56421feb8200, state=WST_FOCUSED, enable=1)
    at ../../lib/widget/widget-common.h:343
#18 0x000056421ef19948 in dlg_init (h=0x56421feb8200) at dialog.c:515
#19 0x000056421ef19a98 in dlg_run (h=0x56421feb8200) at dialog.c:574
#20 0x000056421ef6da61 in query_dialog (header=0x56421effa2ea "Save file",
    text=0x56421fddc940 "Confirm save file: \"/home/thomas/repositories/gentoo/dev-php/doctrine-instantiator/doctrine-instantiator-1.3.1.ebuild\"", flags=0, count=2) at wtools.c:350
#21 0x000056421efa163d in edit_save_confirm_cmd (edit=0x56421fe7edb0) at editcmd.c:2049
#22 0x000056421ef9b0b8 in edit_execute_cmd (edit=0x56421fe7edb0, command=53, char_for_insertion=-1) at edit.c:3826
#23 0x000056421ef99841 in edit_execute_key_command (edit=0x56421fe7edb0, command=53, char_for_insertion=-1)
--Type <RET> for more, q to quit, c to continue without paging--c
    at edit.c:3235
#24 0x000056421efab8dd in edit_callback (w=0x56421fe7edb0, sender=0x56421fe7ebc0, msg=MSG_ACTION, parm=53, data=0x0) at editwidget.c:971
#25 0x000056421ef14ceb in send_message (w=0x56421fe7edb0, sender=0x56421fe7ebc0, msg=MSG_ACTION, parm=53, data=0x0) at ../../lib/widget/widget-common.h:243
#26 0x000056421ef15053 in buttonbar_call (bb=0x56421fe7ebc0, i=1) at buttonbar.c:154
#27 0x000056421ef150c8 in buttonbar_callback (w=0x56421fe7ebc0, sender=0x0, msg=MSG_HOTKEY, parm=266, data=0x0) at buttonbar.c:171
#28 0x000056421ef28db4 in send_message (w=0x56421fe7ebc0, sender=0x0, msg=MSG_HOTKEY, parm=266, data=0x0) at ../../lib/widget/widget-common.h:243
#29 0x000056421ef29b44 in group_handle_hotkey (g=0x56421fe776a0, key=266) at group.c:497
#30 0x000056421ef29d34 in group_default_callback (w=0x56421fe776a0, sender=0x0, msg=MSG_HOTKEY, parm=266, data=0x0) at group.c:570
#31 0x000056421ef192c1 in dlg_default_callback (w=0x56421fe776a0, sender=0x0, msg=MSG_HOTKEY, parm=266, data=0x0) at dialog.c:343
#32 0x000056421efab546 in edit_dialog_callback (w=0x56421fe776a0, sender=0x0, msg=MSG_HOTKEY, parm=266, data=0x0) at editwidget.c:834
#33 0x000056421ef28db4 in send_message (w=0x56421fe776a0, sender=0x0, msg=MSG_HOTKEY, parm=266, data=0x0) at ../../lib/widget/widget-common.h:243
#34 0x000056421ef2991d in group_handle_key (g=0x56421fe776a0, key=266) at group.c:434
#35 0x000056421ef29d1e in group_default_callback (w=0x56421fe776a0, sender=0x0, msg=MSG_KEY, parm=266, data=0x0) at group.c:567
#36 0x000056421ef1900d in dlg_key_event (h=0x56421fe776a0, d_key=266) at dialog.c:251
#37 0x000056421ef199d1 in dlg_process_event (h=0x56421fe776a0, key=266, event=0x7fffe2e00340) at dialog.c:541
#38 0x000056421ef191ff in frontend_dlg_run (h=0x56421fe776a0) at dialog.c:320
#39 0x000056421ef19aa4 in dlg_run (h=0x56421fe776a0) at dialog.c:575
#40 0x000056421efac33d in edit_files (files=0x56421fe04d40 = {...}) at editwidget.c:1272
#41 0x000056421ef21970 in mc_maybe_editor_or_viewer () at filemanager.c:977
#42 0x000056421ef2316e in do_nc () at filemanager.c:1826
#43 0x000056421ef0b91f in main (argc=2, argv=0x7fffe2e005b8) at main.c:463

Note

Original attachments:

@mc-butler
Copy link
Author

Changed by slyfox (@trofi) on Feb 2, 2021 at 8:08 UTC

mc-4.8.26-clip-768285.patch

@mc-butler
Copy link
Author

Changed by slyfox (@trofi) on Feb 2, 2021 at 8:10 UTC (comment 1)

If I understand the trigger values correctly (from https://bugs.gentoo.org/768285#c3):

tty_colorize_area (y + 1, x + cols, rows - 1, 2, shadow_color); ('right' case)
y = 12;
x = 122;
rows = 6;
cols = 2;

tty_clip()

cols = -2; somehow, perhaps due to:

if (*x + *cols > COLS)

*cols = COLS - *x;


To get negative COLS should be 120.

Thus right hand side box clipping is not enough. Proposed patch:

      <li class="entry">
        <h2>
          <a>lib/tty/tty-ncurses.c</a>
          
        </h2>
        
        
        <table class="trac-diff inline" summary="Differences" cellspacing="0">
          
            
            
              <colgroup><col class="lineno" /><col class="lineno" /><col class="content" /></colgroup>
              <thead>
                <tr>
                  <th title="File a/lib/tty/tty-ncurses.c">
                    
                      a
                  </th>
                  <th title="File b/lib/tty/tty-ncurses.c">
                    
                      b
                  </th>
                  <td><em> tty_clip (int *y, int *x, int *rows, int *cols)</em> </td>
                </tr>
              </thead>
            
          
          
            <tbody class="unmod">
              
    
                 
                  <tr>
                      
                      
                        
                        
                          <th>135</th><th>135</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; *rows += *y;</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>136</th><th>136</th><td class="l"><span></span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>137</th><th>137</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; if (*rows &lt;= 0)</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>138</th><th>138</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return FALSE;</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>139</th><th>139</th><td class="l"><span></span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>140</th><th>140</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; *y = 0;</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>141</th><th>141</th><td class="l"><span>&nbsp; &nbsp; }</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>142</th><th>142</th><td class="l"><span></span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>143</th><th>143</th><td class="l"><span>&nbsp; &nbsp; if (*x &lt; 0)</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>144</th><th>144</th><td class="l"><span>&nbsp; &nbsp; {</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>145</th><th>145</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; *cols += *x;</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>146</th><th>146</th><td class="l"><span></span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>147</th><th>147</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; if (*cols &lt;= 0)</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>148</th><th>148</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return FALSE;</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>149</th><th>149</th><td class="l"><span></span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>150</th><th>150</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; *x = 0;</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>151</th><th>151</th><td class="l"><span>&nbsp; &nbsp; }</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>152</th><th>152</th><td class="l"><span></span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>153</th><th>153</th><td class="l"><span>&nbsp; &nbsp; if (*y + *rows &gt; LINES)</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>154</th><th>154</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; *rows = LINES - *y;</span> </td>
                        
                      
                    
                  </tr>
                
    
                
    
                
    
                
    
              
            </tbody><tbody class="add">
              
    
                
    
                 
                  <tr class="first">
                    
                      
                        
                        
                          <th> </th><th>155</th><td class="r"><ins>&nbsp; &nbsp; if (*rows &lt;= 0)</ins> </td>
                        
                      
                    
                  </tr><tr class="last">
                    
                      
                        
                        
                          <th> </th><th>156</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; return FALSE;</ins> </td>
                        
                      
                    
                  </tr>
                
    
                
    
                
    
              
            </tbody><tbody class="unmod">
              
    
                 
                  <tr>
                      
                      
                        
                        
                          <th>155</th><th>157</th><td class="l"><span>&nbsp; &nbsp; if (*x + *cols &gt; COLS)</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>156</th><th>158</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; *cols = COLS - *x;</span> </td>
                        
                      
                    
                  </tr>
                
    
                
    
                
    
                
    
              
            </tbody><tbody class="add">
              
    
                
    
                 
                  <tr class="first">
                    
                      
                        
                        
                          <th> </th><th>159</th><td class="r"><ins>&nbsp; &nbsp; if (*cols &lt;= 0)</ins> </td>
                        
                      
                    
                  </tr><tr class="last">
                    
                      
                        
                        
                          <th> </th><th>160</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; return FALSE;</ins> </td>
                        
                      
                    
                  </tr>
                
    
                
    
                
    
              
            </tbody><tbody class="unmod">
              
    
                 
                  <tr>
                      
                      
                        
                        
                          <th>157</th><th>161</th><td class="l"><span></span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>158</th><th>162</th><td class="l"><span>&nbsp; &nbsp; return TRUE;</span> </td>
                        
                      
                    
                  </tr><tr>
                      
                      
                        
                        
                          <th>159</th><th>163</th><td class="l"><span>}</span> </td>
                        
                      
                    
                  </tr>
                
    
                
    
                
    
                
    
              
            </tbody>
            
          
        </table>
      </li>
    

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 3, 2021 at 6:54 UTC (comment 2)

  • Component changed from mc-core to mc-tty
  • Milestone changed from Future Releases to 4.8.27
  • Owner set to andrew_b
  • Status changed from new to accepted
  • Branch state changed from no branch to on review

Thanks for the patch!

Branch: 4192_shadows_out_of_screen.
[6394547]

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 3, 2021 at 6:56 UTC (comment 3)

  • Branch state changed from on review to approved
  • Votes set to andrew_b

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 3, 2021 at 6:56 UTC (comment 4)

Merged to master: [a34525c].

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 3, 2021 at 7:00 UTC (comment 5)

  • Status changed from accepted to testing
  • Votes changed from andrew_b to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 3, 2021 at 7:41 UTC (comment 6)

  • Status changed from testing to closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tty Interaction with the terminal, screen libraries prio: medium Has the potential to affect progress ver: 4.8.26 Reproducible in version 4.8.26
Development

No branches or pull requests

2 participants