NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.01k stars 14.02k forks source link

Asymptote runtime problem in "three" module #31097

Closed bugaev closed 4 years ago

bugaev commented 6 years ago

Issue description

Processing source files with Asymptote causes the following error message: /nix/store/glmsg7w2vviw30868cca6m1cdymvxh3l-asymptote-2.41/share/asymptote/three.asy: 2905.13: runtime: There is nothing after the colon in

'runtime:'

The error condition is triggered by draw((0,0,0)--(2,0,0), blue); statement in the full listing of the input source file 'test.asy':

import three;
size(4cm,0);
draw((0,0,0)--(2,0,0), blue);

Steps to reproduce

> su -
nix-env -iA nixos.asymptote
> exit
asy test.asy

Technical details

Additional info

lukateras commented 6 years ago

Can't reproduce: test.asy.gz, test.eps.gz

7c6f434c commented 6 years ago

…but you install asymptote form NixOS channel anyway, so Nixpkgs version shouldn't matter.

(and I could not reproduce the issue as reported with exact same store path for asymptote)

Maybe run asy -vvvv test.asy and post the output?

bugaev commented 6 years ago

@7c6f434c:

asy -vvvv test.asy 1> test-std.log

test-std.log

asy -vvvv test.asy 2> test-err.log

test-err.log

7c6f434c commented 6 years ago

Hm. Maybe it runs out of memory? Could you try it inside nix-shell --pure?

bugaev commented 6 years ago

@7c6f434c: Could you please suggest how to run nix-shell? As an inexperienced user, I may be missing some crucial context to your advise.

I tried nix-shell --pure as is and got this:

error: getting status of ‘/home/bugaev/PROG/ASYMPTOTE/default.nix’: No such file or directory`

Then I copied Asymptote's default.nix into the current dir: cp /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/pkgs/tools/graphics/asymptote/default.nix . and tried nix-shell --pure again. This time I got the following error message:

error: cannot auto-call a function that has an argument without a default value (‘stdenv’)

7c6f434c commented 6 years ago

nix-shell --pure -p asymptote --run "asy -vv test.asy"

bugaev commented 6 years ago

@7c6f434c:

nix-shell --pure -p asymptote --run "asy -vv test.asy" results in test-pure.txt

7c6f434c commented 6 years ago

Hm. Maybe try -offscreen option to asy. Also, it looks like your video card model and the driver you use are relevant.

bugaev commented 6 years ago

@7c6f434c:

First, thank you for suggesting -offscreen! I managed to produce my test.eps.

Second, I upgraded the system (nix-channel --update nixos and time nixos-rebuild switch) and tried again. Details about my new system are at the bottom. nix-shell --pure -p asymptote --run "asy -vvvv test.asy"

I still have the run-time error:

libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
freeglut (asy):  ERROR:  Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow

The last line seems like a consequence of the first two.

My glxgears is working fine.

Technical details

7c6f434c commented 6 years ago

Well, I don't know how to debug complicated GL issues, but I think you could post some basic summary about your video card (model, kernel driver used, X driver used, DRI driver used). I mean, getting someone to reproduce the issue could make debugging simpler, and probably that requires having the same graphics setup.

bugaev commented 6 years ago

@7c6f434c:

could post some basic summary about your video card

Thanks, here is a possibly incomplete information about my video system:

I am not sure which other sources of information may be relevant.

vcunat commented 6 years ago

I'm running NixOS with nvidia (unstable), getting

freeglut (./result/bin/asy):  ERROR:  Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow

but no swrast errors – those would hint at bad configuration of LD_LIBRARY_PATH or something similar.

7c6f434c commented 6 years ago

I see you found a TORCS issue with similar enough symptoms…

I wonder if the root cause is that asymptote uses normal linking to Mesa instead of dlopen.

bugaev commented 6 years ago

@vcunat I gave a try to echo $LD_LIBRARY_PATH, got this:

/run/opengl-driver/lib

The contents of the above directory: opengl-driver-lib.txt

By the way, I didn't find swrast_dri.so in it. May be this is a cause of the problem?

vcunat commented 6 years ago

AFAIK nvidia's libGL isn't supposed to have or request swrast_dri. That's what mesa does as a last-resort driver.

vcunat commented 6 years ago

Does ls -l /run/opengl-driver/lib really point to *nvidia-libs*?

7c6f434c commented 6 years ago

Actually, what happens if you run nix-shell --pure -p asymptote --run "LD_PRELOAD=/run/opengl-drive/lib/libGL.so asy -vv test.asy" ?

vcunat commented 6 years ago

Ah, right, the opengl-driver contents above seems OK, but --pure shell removes all variables, including LD_LIBRARY_PATH. That makes the difference between our two errors, so "just" the FBConfig line remains...

bugaev commented 6 years ago

@vcunat

Does ls -l /run/opengl-driver/lib really point to nvidia-libs?

ls -l /run/opengl-driver/lib
/run/opengl-driver/lib -> /nix/store/hk7vdj5bi2v00f4xcpjyfn5hz4812jgd-nvidia-libs/lib

@7c6f434c

Actually, what happens if you run nix-shell --pure -p asymptote --run "LD_PRELOAD=/run/opengl-drive/lib/libGL.so asy -vv test.asy" ?

I tried this and the message about swrast_dri.so is gone. FBConfig error is still there: gl-preload.txt

7c6f434c commented 6 years ago

Hm. And if you just run asy -vv test.asy -offscreen, does it work now?

bugaev commented 6 years ago

@7c6f434c:

Hm. And if you just run asy -vv test.asy -offscreen, does it work now?

It kinda works. In a message earlier I reported that it works, but after I tried it again, I realized that it may take 1, 2 or event 5 attempts to succeed with the command asy -vv test.asy -offscreen. Curiosly, only if the command succeeds in creating test.eps, the message about freeglut pops up:

freeglut ERROR: Function called without first calling 'glutInit'`

If the the command fails, there is no message about freeglut. This makes me think that maybe freeglut thing is not really a reason for asy failing to create output.

7c6f434c commented 6 years ago

I start wondering if putting everything in /run/opengl-driver/lib into LD_PRELOAD is a bad idea to try…

matthuszagh commented 4 years ago

@bugaev did you ever get this working? I'm experiencing the same issue and the suggestions above don't fix it.

matthuszagh commented 4 years ago

nvm, updating asymptote fixes the issue. I'll have a PR for this shortly.

stale[bot] commented 4 years ago

Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on irc.freenode.net.
matthuszagh commented 4 years ago

Closing this issue as I believe this has long since been resolved. Please reopen if you're still experiencing this with 2.65.