Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

std::bad_alloc exception running Q# code from Python #41

Closed
bettinaheim opened this issue Aug 19, 2019 · 1 comment
Closed

std::bad_alloc exception running Q# code from Python #41

bettinaheim opened this issue Aug 19, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@bettinaheim
Copy link
Contributor

Describe the bug

This is a bug report. I’m calling a toy Q# example repeatedly using the python wrappers, which results in an exception.
The source code that triggers the issue on my workstation is the following:
/*********** bug.qs */
namespace Microsoft.Bug
{
open Microsoft.Quantum.Intrinsic;
// open Microsoft.Quantum.Canon;
operation Set (desired: Result, q1: Qubit) : Unit {
if (desired != M(q1)) {
X(q1);
}
}
operation main() : Unit
{
using ((a, b, c) = (Qubit8, Qubit8, Qubit8))
{
}
}
}
/ end of bug.qs /
/
bug.py */
import qsharp
from Microsoft.Bug import main
for _ in range(256):
main.simulate()
print(_)
/ end of bug.py /
Calling python3 bug.py results in the following (abridged) output:
/
output ****/
1
2

40
41
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc
/
end of output ********/
Python then stops producing output. Removing the definition of Set (desired: Result, q1: Qubit) : Unit
from bug.qs results in python slowing down as the 42th iteration approaches, and then hanging (without
exception as far as I could see).
My machine is a Virtualbox 6.0.8 VM. My dotnet info is as follows:
$ dotnet iqsharp —version
Language kernel: 0.6.1905.301
Jupyter core: 1.1.13141.0
$ dotnet —info
.NET Core SDK (reflecting any global.json):
Version: 2.2.300
Commit: 73efd5bd87
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/2.2.300/
Host (useful for support):
Version: 2.2.5
Commit: 0a3c9209c0
.NET Core SDKs installed:
2.2.300 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
I’m happy to run further tests if needed.
Cheers
Fernando

Additional context
Transferred over from User Voice

@bettinaheim bettinaheim added the bug Something isn't working label Aug 19, 2019
@anpaz
Copy link
Member

anpaz commented Aug 30, 2019

Was not able to reproduce this running locally with:

  • iq#: 0.8.1907.1701
  • .net core: 2.2.401
  • Python: 3.7.0

and on binder with:
{'iqsharp': LooseVersion ('0.8.1907.1701'),
'Jupyter Core': LooseVersion ('1.1.14623.0'),
'qsharp': LooseVersion ('0.8.1907.1701')}

Ran it multiple times, all successfully finished all iterations. Never seen it before, suspect something on the environment.. Closing this issue, let us know if you can reproduce it.

@anpaz anpaz closed this as completed Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants