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

Windows Issue: The specified module could not be found #124

Closed
cocoa-xu opened this issue Jan 27, 2025 · 22 comments · Fixed by #125
Closed

Windows Issue: The specified module could not be found #124

cocoa-xu opened this issue Jan 27, 2025 · 22 comments · Fixed by #125
Assignees

Comments

@cocoa-xu
Copy link
Member

I get that same error on runtime when attempting to open a database connection
image

Originally posted by @DnOberon in #120 (comment)

@cocoa-xu cocoa-xu linked a pull request Jan 27, 2025 that will close this issue
@DnOberon
Copy link
Contributor

Testing now!

@cocoa-xu
Copy link
Member Author

I haven't shipped it yet but I think this should be everything (You can test it by placing the adbc_driver_manager.dll file in priv/bin directory)

@DnOberon
Copy link
Contributor

Seems to work! Thank you so much for your help!

@DnOberon
Copy link
Contributor

I'll keep my eye open for the release so I can switch, thanks again :)

@cocoa-xu
Copy link
Member Author

Going to release v0.7.7 and retire v0.7.4-v0.7.6.

@cocoa-xu cocoa-xu self-assigned this Jan 27, 2025
@cocoa-xu
Copy link
Member Author

Okay, v0.7.7 is shipped🤞

@DnOberon
Copy link
Contributor

@cocoa-xu SUCCESS

Image

Feel free to close :)

@cocoa-xu
Copy link
Member Author

That's great to hear! Closing this now

@DnOberon
Copy link
Contributor

DnOberon commented Jan 27, 2025

Seeing a new issue, intermittment on prod releases @cocoa-xu

What's odd is that this is on starting the application, where no code from this is actually running afaik. Sometimes it boots up my phoenix server ok, sometimes it gives me this error chain. Whats weird is that my system test script that actually uses ADBC works just fine...

{undef,[{'Elixir.Adbc.Nif.DLLLoader',add_dll_directory,[],[]},
        {'Elixir.Adbc.Nif',load_nif,0,[{file,"lib/adbc_nif.ex"},{line,13}]},
        {init,'-run_on_load_handler/2-fun-0-',1,
              [{file,"init.erl"},{line,1888}]}]}

=CRASH REPORT==== 27-Jan-2025::14:58:44.891000 ===
  crasher:
    initial call: kernel:init/1
    pid: <0.2299.0>
    registered_name: []
    exception exit: {on_load_function_failed,'Elixir.Adbc.Nif',
                        {undef,
                            [{'Elixir.Adbc.Nif.DLLLoader',add_dll_directory,
                                 [],[]},
                             {'Elixir.Adbc.Nif',load_nif,0,
                                 [{file,"lib/adbc_nif.ex"},{line,13}]},
                             {init,'-run_on_load_handler/2-fun-0-',1,
                                 [{file,"init.erl"},{line,1888}]}]}}
      in function  init:run_on_load_handlers/0 (init.erl, line 1858)
      in call from kernel:init/1 (kernel.erl, line 230)
    ancestors: [kernel_sup,<0.2292.0>]
    message_queue_len: 0
    messages: []
    links: [<0.2294.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 376
    stack_size: 29
    reductions: 52
  neighbours:

=SUPERVISOR REPORT==== 27-Jan-2025::14:58:44.892000 ===
    supervisor: {local,kernel_sup}
    errorContext: start_error
    reason: {on_load_function_failed,'Elixir.Adbc.Nif',
                {undef,
                    [{'Elixir.Adbc.Nif.DLLLoader',add_dll_directory,[],[]},
                     {'Elixir.Adbc.Nif',load_nif,0,
                         [{file,"lib/adbc_nif.ex"},{line,13}]},
                     {init,'-run_on_load_handler/2-fun-0-',1,
                         [{file,"init.erl"},{line,1888}]}]}}
    offender: [{pid,undefined},
               {id,on_load},
               {mfargs,{proc_lib,start_link,[kernel,init,[on_load]]}},
               {restart_type,transient},
               {significant,false},
               {shutdown,2000},
               {child_type,worker}]

=CRASH REPORT==== 27-Jan-2025::14:58:44.892000 ===
  crasher:
    initial call: application_master:init/3
    pid: <0.2291.0>
    registered_name: []
    exception exit: {{shutdown,
                      {failed_to_start_child,on_load,
                       {on_load_function_failed,'Elixir.Adbc.Nif',
                        {undef,
                         [{'Elixir.Adbc.Nif.DLLLoader',add_dll_directory,[],
                           []},
                          {'Elixir.Adbc.Nif',load_nif,0,
                           [{file,"lib/adbc_nif.ex"},{line,13}]},
                          {init,'-run_on_load_handler/2-fun-0-',1,
                           [{file,"init.erl"},{line,1888}]}]}}}},
                     {kernel,start,[normal,[]]}}
      in function  application_master:init/3 (application_master.erl, line 143)
    ancestors: [application_controller,<0.10.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.2292.0>,normal}]
    links: [<0.2290.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 376
    stack_size: 29
    reductions: 74
  neighbours:

=INFO REPORT==== 27-Jan-2025::14:58:44.892000 ===
    application: kernel
    exited: {{shutdown,
                 {failed_to_start_child,on_load,
                     {on_load_function_failed,'Elixir.Adbc.Nif',
                         {undef,
                             [{'Elixir.Adbc.Nif.DLLLoader',add_dll_directory,
                                  [],[]},
                              {'Elixir.Adbc.Nif',load_nif,0,
                                  [{file,"lib/adbc_nif.ex"},{line,13}]},
                              {init,'-run_on_load_handler/2-fun-0-',1,
                                  [{file,"init.erl"},{line,1888}]}]}}}},
             {kernel,start,[normal,[]]}}
    type: permanent

Kernel pid terminated (application_controller) ("{application_start_failure,kernel,{{shutdown,{failed_to_start_child,on_load,{on_load_function_failed,'Elixir.Adbc.Nif',{undef,[{'Elixir.Adbc.Nif.DLLLoader',add_dll_directory,[],[]},{'Elixir.Adbc.Nif',load_nif,0,[{file,\"lib/adbc_nif.ex\"},{line,13}]},{init,'-run_on_load_handler/2-fun-0-',1,[{file,\"init.erl\"},{line,1888}]}]}}}},{kernel,start,[normal,[]]}}}")

@josevalim
Copy link
Member

It may be related to the order NIF modules are loaded. I will take a look, it may be that some release scripts are changing the order of modules.

@DnOberon
Copy link
Contributor

DnOberon commented Jan 27, 2025

Thanks, I'm digging into it as well. @josevalim this is on a prod build btw

@josevalim
Copy link
Member

I can confirm that Erlang will load modules in random order in a release, so this will indeed only work from time to time. I am not sure of solutions at the moment.

@josevalim josevalim reopened this Jan 27, 2025
@DnOberon
Copy link
Contributor

DnOberon commented Jan 27, 2025 via email

@josevalim
Copy link
Member

@DnOberon I pushed a possible fix to main, untested, please give it a try.

@cocoa-xu do you think it would make sense to setup the DLL stuff within the NIF load callback and not even define a NIF function in the first place? Would that even be helpful?

@DnOberon
Copy link
Contributor

DnOberon commented Jan 27, 2025 via email

@cocoa-xu
Copy link
Member Author

do you think it would make sense to setup the DLL stuff within the NIF load callback and not even define a NIF function in the first place? Would that even be helpful?

That's unfortunately impossible because adbc_nif.dll depends on adbc_driver_manager.dll so Windows will have to load adbc_driver_manager.dll first and that was the reason the dll loader helper was a standalone NIF...

Unless we switch to use function pointers and dynamically search for the adbc_driver_manager.dll file and find the corresponding symbols (but things can easily go wrong in this approach)

Another approach is just statically link adbc_driver_manager if that's possible -- theoretically this should be the best solution here but will need to test it out.

@josevalim
Copy link
Member

We should be good on main. Please give it a try.

@cocoa-xu I meant something slightly different, here is a PR: #126. However, if we could statically load, maybe that's the best option here, as it would be by far the least amount of code?

@DnOberon
Copy link
Contributor

The latest fix works perfectly @josevalim and @cocoa-xu . Thank you - you've saved a huge project demo.

@josevalim
Copy link
Member

@cocoa-xu can you please do a new release or should I? I am pinging because both of us tend to be really fast, and therefore it is likely that we will both release at the same time. :D

@cocoa-xu
Copy link
Member Author

@cocoa-xu can you please do a new release or should I? I am pinging because both of us tend to be really fast, and therefore it is likely that we will both release at the same time. :D

Haha that's true, I'll do the release in a minute!

@cocoa-xu
Copy link
Member Author

Okay, tagged v0.7.8 and waiting for CI, should be ready and shipped in 5 minutes!

@cocoa-xu
Copy link
Member Author

cocoa-xu commented Jan 28, 2025

v0.7.8 is shipped, going to retire v0.7.7 as it sometimes won't work in a release, and closing this issue as it's finally resolved. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants