alanxz / SimpleAmqpClient

Simple C++ Interface to rabbitmq-c
MIT License
397 stars 213 forks source link

Channel::OpenOpts::FromUri results in Access violation reading location 0x0000000000000000. #320

Open TheYoungBeast opened 1 year ago

TheYoungBeast commented 1 year ago
 try
    {
        Channel::OpenOpts ret = Channel::OpenOpts::FromUri("amqp://guest:guest@localhost:5672/");
        auto channel = Channel::Open(ret);
    }
    catch (exception e) {
        std::wcout << e.what() << std::endl;
    }

I use the RabbitMQ server on docker. It works fine with other clients e.g. C# RabbitMq.Client. It is painful to make this client work... Above code results in the exception 'Access violation reading location 0x0000000000000000.'

// Windows 10, VS 2022 (mvsc 19)

alanxz commented 1 year ago

Could you provide a stacktrace at the point where it crashes?

As an observation: auto channel is a shared_ptr<> meaning when it goes out of scope, it is destructed. As such, if you want to use it outside of the try block, you'll need to declare it before you enter that try block.

TheYoungBeast commented 1 year ago

As an observation: auto channel is a shared_ptr<> meaning when it goes out of scope, it is destructed. As such, if you want to use it outside of the try block, you'll need to declare it before you enter that try block.

That is correct. However, as you can see channel is declared inside the try block and would not be accessible outside of that block.

@alanxz The exception occurs at: ucrtbased.dll in function strncmp() obraz

strncmp() line 97: obraz

alanxz commented 1 year ago

Could you build and run it using the debug configuration? It’d be helpful to see the functions in the stacktrace.

Also, which versions of SimpleAmqpClient and rabbitmq-c are you using?

-Alan

On Sat, Jun 24, 2023 at 6:54 AM Dominik Dominik @.***> wrote:

As an observation: auto channel is a shared_ptr<> meaning when it goes out of scope, it is destructed. As such, if you want to use it outside of the try block, you'll need to declare it before you enter that try block.

That is correct. However, as you can see channel is declared inside the try block and would not be accessible outside of that block.

@alanxz https://github.com/alanxz The exception occurs at: ucrtbased.dll in function strncmp() [image: obraz] https://user-images.githubusercontent.com/19922252/248464985-009c55c4-4a72-4c0b-984f-b701baa09f39.png

strncmp() line 97: [image: obraz] https://user-images.githubusercontent.com/19922252/248465163-a8801150-792a-4bab-8a04-e70ba9a7a29f.png

— Reply to this email directly, view it on GitHub https://github.com/alanxz/SimpleAmqpClient/issues/320#issuecomment-1605388103, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADLNBCSPSOJDMJQLPYZKRDXM3BPHANCNFSM6AAAAAAY3KSEDQ . You are receiving this because you were mentioned.Message ID: @.***>