Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-28 Thread Gregor Zattler
Hi Ihor,
* Ihor Radchenko  [2024-03-27; 12:00 GMT]:
> Gregor Zattler  writes:
>
>>> I'd like to see the problematic timestamp to understand what might be
>>> going on there.
>>
>>
>> thanks for your instructions, I edited it a bit:
>>
>> "- SxII VPN vxx USB S ()
>>  CLOCK: [2012-02-02 Do 14:00]--[2012-02-02 Do 16:00] =>  2:00
>>  - SxII; Rxx kx, n xx
>>  Clock: [2012-02-01 Mi 17:34]--[2012-02-01 Mi 18:24] =>  0:50
>
> The parser had inconsistent handling of case-sensitivity in "CLOCK:"
> keyword. Now, fixed - it should be case-insensitive.

I did not realize this glitch --although I stumbled
upon such one before.

> Fixed, on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3f20e32f8

Thanks so much.  I confirm it works now with my file
(after finding another glitch).

Ciao, gregor



Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-27 Thread Ihor Radchenko
Gregor Zattler  writes:

>> I'd like to see the problematic timestamp to understand what might be
>> going on there.
>
>
> thanks for your instructions, I edited it a bit:
>
> " - SxII VPN vxx USB S ()
>   CLOCK: [2012-02-02 Do 14:00]--[2012-02-02 Do 16:00] =>  2:00
>   - SxII; Rxx kx, n xx
>   Clock: [2012-02-01 Mi 17:34]--[2012-02-01 Mi 18:24] =>  0:50

The parser had inconsistent handling of case-sensitivity in "CLOCK:"
keyword. Now, fixed - it should be case-insensitive.

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3f20e32f8

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-26 Thread Gregor Zattler
Hi Ihor,
* Ihor Radchenko  [2024-03-26; 10:27 GMT]:
> Gregor Zattler  writes:
>
>> In the file.org_archive, with point on a clock line:
>>
>> Debugger entered--Lisp error: (wrong-type-argument fixnump nil)
>>   encode-time((0 nil nil nil nil nil nil -1 nil))
>>   (float-time (encode-time (list 0 (org-element--property :minute-start 
>> timestamp nil nil) (org-element--property :hour-start timestamp nil nil) 
>> (org-element--property :day-start timestamp nil nil) (org-element--property 
>> :month-start timestamp nil nil) (org-element--property :year-start timestamp 
>> nil nil) nil -1 nil)))
>
> This is helpful. You have some very strange timestamp.
> May you, when the backtrace window is active, press
> e (buffer-substring-no-properties (line-beginning-position -2) 
> (line-end-position 3)) 
> It should display text around the problematic timestamp.
>
> I'd like to see the problematic timestamp to understand what might be
> going on there.


thanks for your instructions, I edited it a bit:

"   - SxII VPN vxx USB S ()
CLOCK: [2012-02-02 Do 14:00]--[2012-02-02 Do 16:00] =>  2:00
- SxII; Rxx kx, n xx
Clock: [2012-02-01 Mi 17:34]--[2012-02-01 Mi 18:24] =>  0:50
- Gxxx-... #NV -Fx a
CLOCK: [2012-02-01 Mi 17:04]--[2012-02-01 Mi 17:33] =>  0:29"


>> seems to be somewhat truncated.  Is there a way to get
>> it unabbreviated?
>
> Press "." (M-x backtrace-expand-ellipses)

this way I get:

Debugger entered--Lisp error: (wrong-type-argument fixnump nil)
  encode-time((0 nil nil nil nil nil nil -1 nil))
  (float-time (encode-time (list 0 (org-element--property :minute-start 
timestamp nil nil) (org-element--property :hour-start timestamp nil nil) 
(org-element--property :day-start timestamp nil nil) (org-element--property 
:month-start timestamp nil nil) (org-element--property :year-start timestamp 
nil nil) nil -1 nil)))
  (let* ((timestamp (org-element--property :value element nil nil)) (ts 
(float-time (encode-time (list 0 (org-element--property :minute-start timestamp 
nil nil) (org-element--property :hour-start timestamp nil nil) 
(org-element--property :day-start timestamp nil nil) (org-element--property 
:month-start timestamp nil nil) (org-element--property :year-start timestamp 
nil nil) nil -1 nil (te (float-time (encode-time (list 0 
(org-element--property :minute-end timestamp nil nil) (org-element--property 
:hour-end timestamp nil nil) (org-element--property :day-end timestamp nil nil) 
(org-element--property :month-end timestamp nil nil) (org-element--property 
:year-end timestamp nil nil) nil -1 nil (dt (- (if tend (min te tend) te) 
(if tstart (max ts tstart) ts (if (> dt 0) (progn (setq t1 (+ t1 (floor dt 
60))
  (cond ((and (eq element-type 'clock) (match-end 2)) (let* ((timestamp 
(org-element--property :value element nil nil)) (ts (float-time (encode-time 
(list 0 (org-element--property :minute-start timestamp nil nil) 
(org-element--property :hour-start timestamp nil nil) (org-element--property 
:day-start timestamp nil nil) (org-element--property :month-start timestamp nil 
nil) (org-element--property :year-start timestamp nil nil) nil -1 nil (te 
(float-time (encode-time (list 0 (org-element--property :minute-end timestamp 
nil nil) (org-element--property :hour-end timestamp nil nil) 
(org-element--property :day-end timestamp nil nil) (org-element--property 
:month-end timestamp nil nil) (org-element--property :year-end timestamp nil 
nil) nil -1 nil (dt (- (if tend (min te tend) te) (if tstart (max ts 
tstart) ts (if (> dt 0) (progn (setq t1 (+ t1 (floor dt 60))) 
((match-end 4) (setq t1 (+ t1 (string-to-number (match-string 5)) (* 60 
(string-to-number (match-string 4)) ((memq element-type '(headline 
inlinetask)) (if (and org-clock-report-include-clocking-task (eq 
(org-clocking-buffer) (current-buffer)) (eq (marker-position 
org-clock-hd-marker) (point)) tstart tend (>= (float-time org-clock-start-time) 
tstart) (<= (float-time org-clock-start-time) tend)) (progn (let ((time (floor 
(org-time-convert-to-integer (time-since org-clock-start-time)) 60))) (setq t1 
(+ t1 time) (let* ((headline-forced (get-text-property (point) 
:org-clock-force-headline-inclusion)) (headline-included (or (null 
headline-filter) (save-excursion (let ((saved-match-data (match-data))) 
(unwind-protect (progn (funcall headline-filter)) (set-match-data 
saved-match-data t))) (setq level (- (match-end 1) (match-beginning 1))) 
(if (>= level lmax) (progn (progn (setq ltimes (vconcat ltimes (make-vector 
lmax 0))) (setq lmax (* 2 lmax) (if (or (> t1 0) (> (aref ltimes level) 0)) 
(progn (if (or headline-included headline-forced) (progn (if headline-included 
(let* ((l 0) (--cl-var-- level)) (while (<= l --cl-var--) (aset ltimes l (+ 
(aref ltimes l) t1)) (setq l (+ l 1))) nil)) (setq time (aref ltimes level)) 
(goto-char (match-beginning 0)) 

Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-26 Thread Max Nikulin

On 25/03/2024 22:46, Gregor Zattler wrote:

rm -rf *; git checkout -f


git clean -dffx

should be a bit safer. However there is still risk to lost files have 
not been committed to git.




Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-26 Thread Ihor Radchenko
Gregor Zattler  writes:

> In the file.org_archive, with point on a clock line:
>
> Debugger entered--Lisp error: (wrong-type-argument fixnump nil)
>   encode-time((0 nil nil nil nil nil nil -1 nil))
>   (float-time (encode-time (list 0 (org-element--property :minute-start 
> timestamp nil nil) (org-element--property :hour-start timestamp nil nil) 
> (org-element--property :day-start timestamp nil nil) (org-element--property 
> :month-start timestamp nil nil) (org-element--property :year-start timestamp 
> nil nil) nil -1 nil)))

This is helpful. You have some very strange timestamp.
May you, when the backtrace window is active, press
e (buffer-substring-no-properties (line-beginning-position -2) 
(line-end-position 3)) 
It should display text around the problematic timestamp.

I'd like to see the problematic timestamp to understand what might be
going on there.

> seems to be somewhat truncated.  Is there a way to get
> it unabbreviated?

Press "." (M-x backtrace-expand-ellipses)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-25 Thread Gregor Zattler
Hi Ihor,
* Ihor Radchenko  [2024-03-25; 18:20 GMT]:
> Gregor Zattler  writes:
>
>> I did
>>
>> rm -rf *; git checkout -f; make repro
>>
>> in ~/src/org-mode.  make repro is very quick.
>>
>> Then I tested again with the above mentioned clock
>> table frame and emacs command line invocation: Same
>> result.  No backtrace.
>>
>> Am I missing something?
>
> Looks like some caller is intercepting errors, demoting them to messages.
>
> What happens if you run M-: (org-clock-sum)  directly in the
> problematic buffer?

on the clock table frame?

0 (#o0, #x0, ?\C-@)

I don't know what that means.

In the file.org_archive, with point on a clock line:

Debugger entered--Lisp error: (wrong-type-argument fixnump nil)
  encode-time((0 nil nil nil nil nil nil -1 nil))
  (float-time (encode-time (list 0 (org-element--property :minute-start 
timestamp nil nil) (org-element--property :hour-start timestamp nil nil) 
(org-element--property :day-start timestamp nil nil) (org-element--property 
:month-start timestamp nil nil) (org-element--property :year-start timestamp 
nil nil) nil -1 nil)))
  (let* ((timestamp (org-element--property :value element nil nil)) (ts 
(float-time (encode-time (list 0 (org-element--property :minute-start timestamp 
nil nil) (org-element--property :hour-start timestamp nil nil) 
(org-element--property :day-start timestamp nil nil) (org-element--property 
:month-start timestamp nil nil) (org-element--property :year-start timestamp 
nil nil) nil -1 nil (te (float-time (encode-time (list 0 
(org-element--property :minute-end timestamp nil nil) (org-element--property 
:hour-end timestamp nil nil) (org-element--property :day-end timestamp nil nil) 
(org-element--property :month-end timestamp nil nil) (org-element--property 
:year-end timestamp nil nil) nil -1 nil (dt (- (if tend (min te tend) te) 
(if tstart (max ts tstart) ts (if (> dt 0) (progn (setq t1 (+ t1 (floor dt 
60))
  (cond ((and (eq element-type 'clock) (match-end 2)) (let* ((timestamp 
(org-element--property :value element nil nil)) (ts (float-time (encode-time 
(list 0 ... ... ... ... ... nil -1 nil (te (float-time (encode-time (list 0 
... ... ... ... ... nil -1 nil (dt (- (if tend (min te tend) te) (if tstart 
(max ts tstart) ts (if (> dt 0) (progn (setq t1 (+ t1 (floor dt 60))) 
((match-end 4) (setq t1 (+ t1 (string-to-number (match-string 5)) (* 60 
(string-to-number (match-string 4)) ((memq element-type '(headline 
inlinetask)) (if (and org-clock-report-include-clocking-task (eq 
(org-clocking-buffer) (current-buffer)) (eq (marker-position 
org-clock-hd-marker) (point)) tstart tend (>= (float-time org-clock-start-time) 
tstart) (<= (float-time org-clock-start-time) tend)) (progn (let ((time (floor 
... 60))) (setq t1 (+ t1 time) (let* ((headline-forced (get-text-property 
(point) :org-clock-force-headline-inclusion)) (headline-included (or (null 
headline-filter) (save-excursion (let ... ...) (setq level (- (match-end 1) 
(match-beginning 1))) (if (>= level lmax) (progn (progn (setq ltimes (vconcat 
ltimes ...)) (setq lmax (* 2 lmax) (if (or (> t1 0) (> (aref ltimes level) 
0)) (progn (if (or headline-included headline-forced) (progn (if 
headline-included ...) (setq time ...) (goto-char ...) (put-text-property ... 
... ... time) (if headline-filter ...))) (setq t1 0) (let* ((l level) 
(--cl-var-- ...)) (while (<= l --cl-var--) (aset ltimes l 0) (setq l ...)) 
nil))
  (let* ((element (let ((saved-match-data (match-data))) (unwind-protect (progn 
(org-element-at-point)) (set-match-data saved-match-data t (element-type 
(org-element-type element))) (cond ((and (eq element-type 'clock) (match-end 
2)) (let* ((timestamp (org-element--property :value element nil nil)) (ts 
(float-time (encode-time ...))) (te (float-time (encode-time ...))) (dt (- (if 
tend ... te) (if tstart ... ts (if (> dt 0) (progn (setq t1 (+ t1 ...)) 
((match-end 4) (setq t1 (+ t1 (string-to-number (match-string 5)) (* 60 
(string-to-number (match-string 4)) ((memq element-type '(headline 
inlinetask)) (if (and org-clock-report-include-clocking-task (eq 
(org-clocking-buffer) (current-buffer)) (eq (marker-position 
org-clock-hd-marker) (point)) tstart tend (>= (float-time org-clock-start-time) 
tstart) (<= (float-time org-clock-start-time) tend)) (progn (let ((time ...)) 
(setq t1 (+ t1 time) (let* ((headline-forced (get-text-property (point) 
:org-clock-force-headline-inclusion)) (headline-included (or (null 
headline-filter) (save-excursion ... (setq level (- (match-end 1) 
(match-beginning 1))) (if (>= level lmax) (progn (progn (setq ltimes ...) (setq 
lmax ... (if (or (> t1 0) (> (aref ltimes level) 0)) (progn (if (or 
headline-included headline-forced) (progn ... ... ... ... ...)) (setq t1 0) 
(let* (... ...) (while ... ... ...) nil)))
  (while (re-search-backward re nil t) (let* ((element (let ((saved-match-data 
(match-data))) (unwind-protect (progn (org-element-at-point)) 

Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-25 Thread Ihor Radchenko
Gregor Zattler  writes:

> I did
>
> rm -rf *; git checkout -f; make repro
>
> in ~/src/org-mode.  make repro is very quick.
>
> Then I tested again with the above mentioned clock
> table frame and emacs command line invocation: Same
> result.  No backtrace.
>
> Am I missing something?

Looks like some caller is intercepting errors, demoting them to messages.

What happens if you run M-: (org-clock-sum)  directly in the
problematic buffer?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-25 Thread Gregor Zattler
Hi Ihor,
* Ihor Radchenko  [2024-03-24; 13:27 GMT]:
> Gregor Zattler  writes:
>
>> with point on the following frame for a clock table:
>>
>> #+BEGIN: clocktable :scope ("/home/absolute/path/file.org_archive")
>> #+END:
>> ...
>> If instead I use a very fresh org-mode from main, specifically
>>
>> Org mode version 9.7-pre (release_9.6.22-1309-g8507ef @ 
>> /home//src/org-mode/lisp/)
>>
>> like so:
>>
>> emacs -L ~/src/org-mode/lisp -L ~/src/org-mode/contrib/lisp -Q
>>
>> org-clock-report
>>
>> with point on said frame of a clock table produces
>>
>> Updating dynamic block ‘clocktable’ at line 13...
>> org-clock-sum: Wrong type argument: fixnump, nil
>
> What if you do the same starting from "make repro" in ~/src/org-mode ?
> The backtrace should then appear rather than just an error line.

I did

rm -rf *; git checkout -f; make repro

in ~/src/org-mode.  make repro is very quick.

Then I tested again with the above mentioned clock
table frame and emacs command line invocation: Same
result.  No backtrace.

Am I missing something?

> I would like to see that backtrace to understand what went wrong.

Do you have further hints how to produce this
backtrace?

Ciao; Gregor



Re: [BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-24 Thread Ihor Radchenko
Gregor Zattler  writes:

> with point on the following frame for a clock table:
>
> #+BEGIN: clocktable :scope ("/home/absolute/path/file.org_archive")
> #+END:
> ...
> If instead I use a very fresh org-mode from main, specifically
>
> Org mode version 9.7-pre (release_9.6.22-1309-g8507ef @ 
> /home//src/org-mode/lisp/)
>
> like so:
>
> emacs -L ~/src/org-mode/lisp -L ~/src/org-mode/contrib/lisp -Q
>
> org-clock-report
>
> with point on said frame of a clock table produces
>
> Updating dynamic block ‘clocktable’ at line 13...
> org-clock-sum: Wrong type argument: fixnump, nil

What if you do the same starting from "make repro" in ~/src/org-mode ?
The backtrace should then appear rather than just an error line.
I would like to see that backtrace to understand what went wrong.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[BUG] org-clock-sum: Wrong type argument: fixnump, nil [9.7-pre (release_9.6.22-1309-g8507ef @ /home/grfz/src/org-mode/lisp/)]

2024-03-23 Thread Gregor Zattler
Dear org-mode developers, Ihor, 

the following is with GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, cairo 
version 1.16.0)
 of 2024-02-27

with point on the following frame for a clock table:

#+BEGIN: clocktable :scope ("/home/absolute/path/file.org_archive")
#+END:

org-clock-report with

emacs -Q

(that is, with Org mode version 9.6.15 (release_9.6.15 @ 
/home//src/emacs-master--32b4f9d21b14190f1ed1611515751abe4b90fa68--2024-02-27T09-36+01-00/lisp/org/)

produces a nice clock report table.

If instead I use a very fresh org-mode from main, specifically

Org mode version 9.7-pre (release_9.6.22-1309-g8507ef @ 
/home//src/org-mode/lisp/)

like so:

emacs -L ~/src/org-mode/lisp -L ~/src/org-mode/contrib/lisp -Q

org-clock-report

with point on said frame of a clock table produces

Updating dynamic block ‘clocktable’ at line 13...
org-clock-sum: Wrong type argument: fixnump, nil


file.org_archive has 2376 clock lines.

The problem does not occur with file.org which has
only 86 clock lines.  I especially archive the nodes
with clock lines, because or performance reasons.


Doing a git bisect produced:

2e901ed23667b04642847701bae2070862b8ee6e is the first bad commit
commit 2e901ed23667b04642847701bae2070862b8ee6e
Author: Ihor Radchenko 
Date:   Fri Feb 3 15:08:18 2023 +0300

org-clock-sum: Optimize performance

* lisp/org-clock.el (org-clock-sum): Do not re-parse the timestamps,
reusing already-parser element.

 lisp/org-clock.el | 29 +
 1 file changed, 21 insertions(+), 8 deletions(-)


I cannot disclose said file, because it contains loads
of sensitive data.  I extracted the clock lines only,
but a single node with a LOGBOOK drawer filled with
this clock lines does not trigger the bug.  But I would
be happy to test a patch on my file.org to test it (or
help otherwise).


HTH, Gregor