GNU bug report logs - #67711
Org Babel gives incomplete result when writing multi-thread code

Previous Next

Package: emacs;

Reported by: ". shynur" <one.last.kiss <at> outlook.com>

Date: Fri, 8 Dec 2023 14:38:02 UTC

Severity: normal

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67711 in the body.
You can then email your comments to 67711 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#67711; Package emacs. (Fri, 08 Dec 2023 14:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to ". shynur" <one.last.kiss <at> outlook.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 08 Dec 2023 14:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: ". shynur" <one.last.kiss <at> outlook.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: Org Babel gives incomplete result when writing multi-thread code
Date: Fri, 8 Dec 2023 14:31:37 +0000
(I use Emacs v29.1.90 for MS-Windows; gcc 10.3.0)
Here's an Org file:

    #+BEGIN_SRC C
    #include <stdio.h>
    #include <omp.h>
    int main() {
    #pragma omp parallel num_threads(3)
        printf("0"), printf("1");
    }
    #+END_SRC

    # Local Variables:
    # eval: (require 'ob-C)
    # org-babel-C-compiler: "gcc.exe  \
    #                         -std=c17 -Wall -O0  \
    #                         -fopenmp "
    # org-confirm-babel-evaluate: nil
    # End:

Executing the C code block usually outputs:

    #+RESULTS:
    : 10101

    #+RESULTS:
    : 1101

This output was unexpected, so I personally ran the temporary EXE file generated by Org-Babel:

    Windows Terminal
    PS D:/Tmp/babel-Xyz123> ./C-bin-Xyz123.exe
    010101

As you can see, this program should output 6 characters.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67711; Package emacs. (Fri, 08 Dec 2023 14:46:02 GMT) Full text and rfc822 format available.

Message #8 received at 67711 <at> debbugs.gnu.org (full text, mbox):

From: ". shynur" <one.last.kiss <at> outlook.com>
To: "67711 <at> debbugs.gnu.org" <67711 <at> debbugs.gnu.org>
Subject: Re: bug#67711: Org Babel gives incomplete result
Date: Fri, 8 Dec 2023 14:45:25 +0000
I found that the leading '0's of result will always be trimmed,
so `010101` will be printed as `10101`.

It seems to be a feature?
If so, I think this is reasonable and convenient.
But how can I disable it?

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67711; Package emacs. (Fri, 08 Dec 2023 14:48:02 GMT) Full text and rfc822 format available.

Message #11 received at 67711 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: ". shynur" <one.last.kiss <at> outlook.com>
Cc: 67711 <at> debbugs.gnu.org
Subject: Re: bug#67711: Org Babel gives incomplete result when writing
 multi-thread code
Date: Fri, 08 Dec 2023 16:47:14 +0200
> From: ". shynur" <one.last.kiss <at> outlook.com>
> Date: Fri, 8 Dec 2023 14:31:37 +0000
> msip_labels: 
> 
> (I use Emacs v29.1.90 for MS-Windows; gcc 10.3.0)
> Here's an Org file:
> 
>     #+BEGIN_SRC C
>     #include <stdio.h>
>     #include <omp.h>
>     int main() {
>     #pragma omp parallel num_threads(3)
>         printf("0"), printf("1");
>     }
>     #+END_SRC
> 
>     # Local Variables:
>     # eval: (require 'ob-C)
>     # org-babel-C-compiler: "gcc.exe  \
>     #                         -std=c17 -Wall -O0  \
>     #                         -fopenmp "
>     # org-confirm-babel-evaluate: nil
>     # End:
> 
> Executing the C code block usually outputs:
> 
>     #+RESULTS:
>     : 10101
> 
>     #+RESULTS:
>     : 1101
> 
> This output was unexpected, so I personally ran the temporary EXE file generated by Org-Babel:
> 
>     Windows Terminal
>     PS D:/Tmp/babel-Xyz123> ./C-bin-Xyz123.exe
>     010101
> 
> As you can see, this program should output 6 characters.

The above invocation is AFAIU not an accurate reproduction of what
happens when this program is invoked from Emacs on MS-Windows.  Emacs
on Windows communicates with subprocesses via pipes, so a more
accurate reproduction would be something like

   C-bin-Xyz123.exe | more

IOW, you need to invoke the program with its output redirected to a
pipe.

In any case, please report this to the Org developers first, and only
if their analysis shows this is a core Emacs problem, come here.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67711; Package emacs. (Fri, 08 Dec 2023 14:49:01 GMT) Full text and rfc822 format available.

Message #14 received at 67711 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: ". shynur" <one.last.kiss <at> outlook.com>
Cc: 67711 <at> debbugs.gnu.org
Subject: Re: bug#67711: Org Babel gives incomplete result
Date: Fri, 08 Dec 2023 16:48:33 +0200
> From: ". shynur" <one.last.kiss <at> outlook.com>
> Date: Fri, 8 Dec 2023 14:45:25 +0000
> msip_labels: 
> 
> I found that the leading '0's of result will always be trimmed,
> so `010101` will be printed as `10101`.
> 
> It seems to be a feature?
> If so, I think this is reasonable and convenient.
> But how can I disable it?

I think this is a question for Org developers.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67711; Package emacs. (Fri, 08 Dec 2023 14:57:01 GMT) Full text and rfc822 format available.

Message #17 received at 67711 <at> debbugs.gnu.org (full text, mbox):

From: ". shynur" <one.last.kiss <at> outlook.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: "67711 <at> debbugs.gnu.org" <67711 <at> debbugs.gnu.org>
Subject: Re: bug#67711
Date: Fri, 8 Dec 2023 14:56:12 +0000
> In any case, please report this to the Org developers first, and
> only if their analysis shows this is a core Emacs problem, come
> here.

Understood.  (I sent it here because the file ‘ob-C.el’ says “This
file is part of GNU Emacs.”)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#67711; Package emacs. (Fri, 08 Dec 2023 16:24:01 GMT) Full text and rfc822 format available.

Message #20 received at 67711 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: ". shynur" <one.last.kiss <at> outlook.com>
Cc: 67711 <at> debbugs.gnu.org
Subject: Re: bug#67711
Date: Fri, 08 Dec 2023 18:23:23 +0200
> From: ". shynur" <one.last.kiss <at> outlook.com>
> CC: "67711 <at> debbugs.gnu.org" <67711 <at> debbugs.gnu.org>
> Date: Fri, 8 Dec 2023 14:56:12 +0000
> msip_labels:
> 
> > In any case, please report this to the Org developers first, and
> > only if their analysis shows this is a core Emacs problem, come
> > here.
> 
> Understood.  (I sent it here because the file ‘ob-C.el’ says “This
> file is part of GNU Emacs.”)

Org is indeed part of Emacs, but is developed by a separate team, and
has its own forums for reporting problems.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Fri, 07 Feb 2025 22:17:03 GMT) Full text and rfc822 format available.

Notification sent to ". shynur" <one.last.kiss <at> outlook.com>:
bug acknowledged by developer. (Fri, 07 Feb 2025 22:17:03 GMT) Full text and rfc822 format available.

Message #25 received at 67711-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: ". shynur" <one.last.kiss <at> outlook.com>, 67711-done <at> debbugs.gnu.org
Subject: Re: bug#67711: Org Babel gives incomplete result when writing
 multi-thread code
Date: Fri, 7 Feb 2025 14:16:50 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: ". shynur" <one.last.kiss <at> outlook.com>
>> CC: "67711 <at> debbugs.gnu.org" <67711 <at> debbugs.gnu.org>
>> Date: Fri, 8 Dec 2023 14:56:12 +0000
>> msip_labels:
>>
>> > In any case, please report this to the Org developers first, and
>> > only if their analysis shows this is a core Emacs problem, come
>> > here.
>>
>> Understood.  (I sent it here because the file ‘ob-C.el’ says “This
>> file is part of GNU Emacs.”)
>
> Org is indeed part of Emacs, but is developed by a separate team, and
> has its own forums for reporting problems.

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 08 Mar 2025 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 117 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.